Introduction
This lab was developed for the Intel(R) Xeon Phi(tm) Technology Conference held in May 8-9 2013 in the United Kingdom, which was attended by multiple Financial Services Institutions.
In this guided lab, we optimize the performance of a Monte Carlo European Option Pricing application for Intel® Xeon® Processors and show that the same optimizations are also effective for the Intel® Xeon Phi™ Coprocessor. We will use Intel® C/C++ Compiler, Intel® Math Kernel Library (Intel® MKL) and Intel® VTune Amplifier Performance Analyzer.
The Monte Carlo simulation is one of the most popular numerical tools for pricing financial derivative securities. The algorithm works by approximating a solution for the Black-Scholes equation for each option to be priced, which involves finding the expected value of the option. The expected value is approximated by the sample mean of the values obtained from the payoff function for European call options using random numbers as current stock samples. The accuracy of the solution relies on sample size; the large the sample size, the more accurate the approximation.
In this lab, we will be working on a C++ implementation of the Monte Carlo algorithm. The lab consists of five steps, each of which covers a specific opportunity for improving the application performance. At the beginning of each step, you can choose to use your own code from the previous step or choose to start from the provided code.
Implementation Files
The attached lab manual describes all of the activities and steps for this lab.
The source code for this lab is in the attached zip file and is organized in "steps". In each subdirectory, you will find 4 files
- MonteCarlo.h is a header file containing the problem size definitions. Parameters such as how many options to price and how long the path length is are defined here. You will need to increase the number of options to price in the last step.
- MonteCarloStepn.cpp is the implementation file for step n. It’s the focal point of this lab and you will have to modify it for each step.
- Driver.cpp contains the main function, the C/C++ entry point. It prepares the input data file by allocating the memory and initialize them with the generate data samples. You will need to change this file in step 4: vectorization. It also validates the result from the Monte Carlo simulation.
- Makefile is the build script for this lab. It invokes the compiler and linker and produces the executable file called MonteCarlo.
The solution to each step is also provided under a hidden directory in each lab (under .solution). The "extra"step converts the native Intel(R) Xeon Phi(tm) coprocessor application to, instead, being an offload application launched from the host. The user can set the environment variable OFFLOAD_INIT=on_start, and expect the offload application to run with about a 5% performance overhead.