-
Notifications
You must be signed in to change notification settings - Fork 1
/
dissertation.txt
115 lines (79 loc) · 5.69 KB
/
dissertation.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
Introduction
NVIDIA GPU Hardware
Von Neumann Architecture CPU Architecture vs GPU Architecture
SIMT vs SIMD Execution Model (Vectorization)
Memory Distribution
CUDA Programming Model
-Intro to Prgoramming model (https://devblogs.nvidia.com/even-easier-introduction-cuda/)
-Block/Grid Partition
-Memory Bandwidtdh : Coalesced Data Access
-Memory Bandwidtdh : Shared Memory Access
-Synchronization
-Warp Divergence
-Latency Hiding (Multi Threading over caching)
-Ocupancy
-Streams
Monte Carlo Simulation numerical method
Financial problems are usually modelled using Stochastic Differential Equations (SDE). Most of the SDE
problems have a high dimensions integration problems and does not have a closed form solution. Hence,
Monte Carlo numerical methods in the area of stochastic simulations based on sampling methods
basically simulate independent realizations of the stochastic phenomenon under consideration and then to compute an
estimate for the expectation of interest via an appropriate estimator obtained from independent samples.
In other words, one runs N independent computer experiments replicating the random variable Z, and then computes z from the sample. Use of random sampling or a method for computing a expectation is often called the Monte Carlo method. The estimator of z = E[Z] is an average of independent identical distributed copies of Z. Based on the Law of Large Numbers
for a given N < +oo the stocastic simulation converge to z = 1/n sum[Z] and for N large enough hold that
En-1[Z] - En[Z] < epsilon. The epsilon value determine the converge criteria for the numerical methods and depends
on the accuracy required in the specific problem context.
Key Issues arising in Monte Carlo Simulation
- Uniform/Gaussian Random generators
- Large number of samplings
- Large floating point summation
- (Speeding up Convergence) using Variance Reduction (slow convergence rate)
- Convergence Criteria and Accuracy
- Hardware Acceleration to improve Long execution time
Case of Study Accelerating the calculation of IRS CVA with GPU
Heath-Jarrow-Morton framework
Instant forward rates is simulate f(t+dt)=f(t) + dfbar where SDE dfbar = m(t)*dt+SUM(Vol_i*phi*SQRT(dt))+dF/dtau*dt
Discount Factors Curve
Forward Rate Curve
Interest Rate Swap (Pricing)
Credit Valuation Adjustment (CVA)
Serial CPU CVA Calculation Implementation
step 1 - HJM Model Calibration
step 2 - Evolve Risk Factor in the Future using MC Simulation
step 3 - Generate the Discount Factors and Forward Rates on each pricing point
step 4 - Perform IRS Mark to Market across pricing points
step 5 - Generate an Exposure Profile
step 6 - Run 2 through 6 N times ( N > 1000)
step 7 - Calculate the Expected Exposure profile averaging N-Exposure Curves across all simulation points
step 8 - Run 2 through 6 N times ( N >> 1000 )
step 9 - Calculate the Expected Exposure profile averaging N-Exposure Curves across all simulation points
step 10 - Perform a difference across simulation point for the EE calculated obtained in step 7 and step 9
step 11 - Each for each simulation point the difference is less than a threshold then stop simulation
step 12 - Repeat step 8 through 9 till the simulation converge
GPU accelerated CVA Calculation implementation
• Use CURAND to generate the Gaussian Variates inside the GPU
• Simulations in loop are independent: loop can be parallelised
• Strategy: carve up the N iterations between our P CPU threads, so that each thread computes N/P iterations
• Thread safety: have to take care when collecting running sums from P threads at the end (synchronisation?)
• Run partial reduction in the GPU
• Each thread copy one element of the vector back to the memory cpu
Benchmark GPU Accelerated solutions against CPU
Conclusions
References
[1] Pykhtin, Michael, and Steven Zhu, A Guide to Modeling Counterparty Credit Risk, GARP, July/August 2007, issue 37, pp. 16-22.
[2] Mathworks. Counterparty Credit Risk and CVA. https://de.mathworks.com/help/fininst/examples/counterparty-credit-risk-and-cva.html
[3] Glasserman, Paul. Importance Sampling in the Heath-Jarrow-Morton framework. https://www0.gsb.columbia.edu/faculty/pglasserman/Other/ghs_jderiv.pdf
[4] Lerche, Ian and Mudford, Brett S. How many Monte Carlo simulations do I need to do?https://journals.sagepub.com/doi/pdf/10.1260/014459805776986876
[5] Jaeckel, Peter. Monte Carlo Methods in Finance
[6] Willmot,Paul. Introduces Quantitative Finance.
[7] Higham, Nicholas J. (2002). Accuracy and Stability of Numerical Algorithms. 2nd Edition. SIAM. pp. 110–123;
[8] Savigne, Antoine. Modern Computational Finance, AAD and Parallel Simulations.
[9] Joshi, Mark. C++ Design Pattern and Derivatives Pricing. 2nd Edition.
[10] Harris, Mark. An even easy introduction to CUDA. https://devblogs.nvidia.com/even-easier-introduction-cuda/
[11] Wen Wei and Kirk. Programming Massively Parallel Processors. 3rd edition.
[12] Kindratenko, Vlodymyr. Numerical Computations with GPUs. chapter 12, 13, 14
[13] Mudigere, Dheevatsa. Data access optimized applications on the GPU using NVIDIA CUDA. https://www5.in.tum.de/pub/mudigere09.pdf
[14] Podlozhnyuk, Victor and Harris, Mark. Monte Carlo Option Pricing. http://developer.download.nvidia.com/compute/cuda/1_1/Website/projects/MonteCarlo/doc/MonteCarlo.pdf
[15] NVIDIA Curand User Guide. https://docs.nvidia.com/cuda/curand/index.html
[16] NVIDIA CUDA C Programming Guide. https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html
[17] NVIDIA CUDA Best Practices Guide. https://docs.nvidia.com/cuda/cuda-c-best-practices-guide/index.html