/********************************************************************** Copyright ©2012 Advanced Micro Devices, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ********************************************************************/ #ifndef MONTECARLOASIANDP_H_ #define MONTECARLOASIANDP_H_ #define GROUP_SIZE 256 #include #include #include #include #include #include #include /** * MonteCarloAsian * Class implements OpenCL Monte Carlo Simution sample for Asian Option pricing using double * Derived from SDKSample base class */ class MonteCarloAsianDP : public SDKSample { cl_int steps; /**< Steps for Asian Monte Carlo simution */ cl_double initPrice; /**< Initial price */ cl_double strikePrice; /**< Stirke price */ cl_double interest; /**< Interest rate */ cl_double maturity; /**< maturity */ cl_int noOfSum; /**< Number of excersize points */ cl_int noOfTraj; /**< Number of samples */ cl_double setupTime; /**< time taken to setup OpenCL resources and building kernel */ cl_double kernelTime; /**< time taken to run kernel and read result back */ cl_double *sigma; /**< Array of sigma values */ cl_double *price; /**< Array of price values */ cl_double *vega; /**< Array of vega values */ cl_double *refPrice; /**< Array of reference price values */ cl_double *refVega; /**< Array of reference vega values */ cl_uint *randNum; /**< Array of random numbers */ cl_double *priceVals; /**< Array of price values for given samples */ cl_double *priceDeriv; /**< Array of price derivative values for given samples */ cl_context context; /**< CL context */ cl_device_id *devices; /**< CL device list */ cl_mem priceBuf; /**< CL memory buffer for sigma */ cl_mem priceDerivBuf; /**< CL memory buffer for price */ cl_mem randBuf; /**< CL memroy buffer for random number */ cl_command_queue commandQueue; /**< CL command queue */ cl_program program; /**< CL program */ cl_kernel kernel; /**< CL kernel */ cl_int width; cl_int height; //size_t kernelWorkGroupSize; /**< Group size returned by kernel */ size_t blockSizeX; /**< Group-size in x-direction */ size_t blockSizeY; /**< Group-size in y-direction */ int iterations; /**< Number of iterations for kernel execution */ cl_mem priceBufAsync; /**< CL memory buffer for sigma */ cl_mem priceDerivBufAsync; /**< CL memory buffer for price */ cl_mem randBufAsync; /**< CL memroy buffer for random number */ streamsdk::SDKDeviceInfo deviceInfo; /**