Advertisement
Guest User

Untitled

a guest
May 26th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.47 KB | None | 0 0
  1. double do_sth(int n){
  2.  
  3.     double result = 0.;
  4.  
  5.     hpx::cout << "hpx_thread = " << std::hex
  6.               << hpx::this_thread::get_id()
  7.               << " os_thread = " << std::hex
  8.               << std::this_thread::get_id() << std::endl;
  9.  
  10.     for(int i = 0; i<n; ++i){
  11.         result = ((result + 1.)*result)/(result - 0.8*result);
  12.     }
  13.     return result;
  14. }
  15.  
  16. int main(int argc, char* argv[])
  17. {
  18.     namespace po = boost::program_options;
  19.  
  20.     po::options_description desc_commandline;
  21.     desc_commandline.add_options()
  22.         ("results", "print generated results (default: false)")
  23.         ("m1_nrows", po::value<std::uint64_t>()->default_value(100), "Number of rows of first matrix")
  24.         ("m1_ncols", po::value<std::uint64_t>()->default_value(50), "Number of columns of first matrix")
  25.         ("m2_nrows", po::value<std::uint64_t>()->default_value(50), "Number of rows of second matrix")
  26.         ("m2_ncols", po::value<std::uint64_t>()->default_value(80),"Number of columns of second matrix")
  27.         ("no-header", "do not print out the csv header row")
  28.         ("seed", po::value<unsigned int>()->default_value(42), "Seed for randomness");
  29.  
  30.     int my_argc = 1;
  31.     char** my_argv = new char*[my_argc];
  32.     my_argv[0] = const_cast<char *>(std::string("parallel_for_").c_str());
  33.     hpx::start(nullptr, my_argc, my_argv);
  34.  
  35.     hpx::future<double> result_f = hpx::async(&do_sth, 500);
  36.  
  37.     hpx::cout << "Result = " << result_f.get();
  38.  
  39.     return hpx::stop();
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement