// Copyright (c) 2007 Intel Corp. // Black-Scholes // Analytical method for calculating European Options // // Reference Source: Options, Futures, and Other Derivatives, 3rd Edition, Prentice // Hall, John C. Hull, // // Modified from // https://parsec.cs.princeton.edu/ #include "common.hpp" #include // extern global variables OptionData *optdata = nullptr; float *prices = nullptr; int numOptions = 0; int NUM_RUNS = 1; int* otype = nullptr; float* sptprice = nullptr; float* strike = nullptr; float* rate = nullptr; float* volatility = nullptr; float* otime = nullptr; int numError = 0; float* BUFFER = nullptr; int* BUFFER2 = nullptr; void black_scholes( const std::string& model, const unsigned num_threads, const unsigned num_rounds ) { std::cout << std::setw(12) << "size" << std::setw(12) << "runtime" << std::endl; for(size_t N = 1000; N<=10000; N+=1000) { generate_options(N); double runtime {0.0}; for(unsigned j=0; jcheck([] (const std::string& m) { if(m != "tbb" && m != "tf" && m != "omp") { return "model name should be \"tbb\", \"omp\", or \"tf\""; } return ""; }); CLI11_PARSE(app, argc, argv); std::cout << "model=" << model << ' ' << "num_threads=" << num_threads << ' ' << "num_rounds=" << num_rounds << ' ' << std::endl; black_scholes(model, num_threads, num_rounds); // Compare with sequential version to check correctness //if(cmp_seq) { // auto seq_prices = static_cast(malloc(numOptions*sizeof(FPTYPE))); // bs_seq(seq_prices); // for(auto i=0; i