CHAPTER 7Parallel Implementation
In this chapter, we extend the code from the previous chapter with parallel simulations, applying everything we learned in Part I. It is generally not an easy task to parallelize an existing engine, because odds are that various parts were developed without thread safety in mind. We developed our engine from scratch in the previous chapter, knowing that we would eventually extend it with parallelism, so our work here is substantially less challenging than in real life.
It follows that we will not modify base or concrete models or products in any way, but we will need a substantial extension in the base and concrete RNGs.
The parallel algorithm is implemented in a parallel version of the template algorithm of the previous chapter, , also in mcBase.h in our repository.
7.1 PARALLEL CODE AND SKIP AHEAD
Parallel simulation design
With serial path-wise MC, we processed the paths sequentially in a loop, the processing of every path consisting in the three following steps:
- Generate a random Gaussian vector in dimension with a call to .
- Consume the random vector to generate a scenario for the market observations on the event dates with a call to .
- Compute ...
Get Modern Computational Finance now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.