/////////////////////////////////////////////////////////////////////////// Main program ///////////////////////////////////////////////////////////////////////////
| 72 | // Main program |
| 73 | //////////////////////////////////////////////////////////////////////////////// |
| 74 | int main(int argc, char **argv) |
| 75 | { |
| 76 | printf("[%s] - Starting...\n", argv[0]); |
| 77 | |
| 78 | int devID = findCudaDevice(argc, (const char **)argv); |
| 79 | |
| 80 | const int OPT_N = MAX_OPTIONS; |
| 81 | |
| 82 | TOptionData optionData[MAX_OPTIONS]; |
| 83 | real callValueBS[MAX_OPTIONS], callValueGPU[MAX_OPTIONS], callValueCPU[MAX_OPTIONS]; |
| 84 | |
| 85 | real sumDelta, sumRef, gpuTime, errorVal; |
| 86 | |
| 87 | StopWatchInterface *hTimer = NULL; |
| 88 | int i; |
| 89 | |
| 90 | sdkCreateTimer(&hTimer); |
| 91 | |
| 92 | printf("Generating input data...\n"); |
| 93 | // Generate options set |
| 94 | srand(123); |
| 95 | |
| 96 | for (i = 0; i < OPT_N; i++) { |
| 97 | optionData[i].S = randData(5.0f, 30.0f); |
| 98 | optionData[i].X = randData(1.0f, 100.0f); |
| 99 | optionData[i].T = randData(0.25f, 10.0f); |
| 100 | optionData[i].R = 0.06f; |
| 101 | optionData[i].V = 0.10f; |
| 102 | BlackScholesCall(callValueBS[i], optionData[i]); |
| 103 | } |
| 104 | |
| 105 | printf("Running GPU binomial tree...\n"); |
| 106 | checkCudaErrors(cudaDeviceSynchronize()); |
| 107 | sdkResetTimer(&hTimer); |
| 108 | sdkStartTimer(&hTimer); |
| 109 | |
| 110 | binomialOptionsGPU(callValueGPU, optionData, OPT_N); |
| 111 | |
| 112 | checkCudaErrors(cudaDeviceSynchronize()); |
| 113 | sdkStopTimer(&hTimer); |
| 114 | gpuTime = sdkGetTimerValue(&hTimer); |
| 115 | printf("Options count : %i \n", OPT_N); |
| 116 | printf("Time steps : %i \n", NUM_STEPS); |
| 117 | printf("binomialOptionsGPU() time: %f msec\n", gpuTime); |
| 118 | printf("Options per second : %f \n", OPT_N / (gpuTime * 0.001)); |
| 119 | |
| 120 | printf("Running CPU binomial tree...\n"); |
| 121 | |
| 122 | for (i = 0; i < OPT_N; i++) { |
| 123 | binomialOptionsCPU(callValueCPU[i], optionData[i]); |
| 124 | } |
| 125 | |
| 126 | printf("Comparing the results...\n"); |
| 127 | sumDelta = 0; |
| 128 | sumRef = 0; |
| 129 | printf("GPU binomial vs. Black-Scholes\n"); |
| 130 | |
| 131 | for (i = 0; i < OPT_N; i++) { |
nothing calls this directly
no test coverage detected