Guest User

Untitled

a guest
May 26th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 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.     int my_argc = 1;
  19.     char** my_argv = new char*[my_argc];
  20.     my_argv[0] = const_cast<char *>(std::string("parallel_for_").c_str());
  21.     hpx::start(nullptr, my_argc, my_argv);
  22.  
  23.     hpx::future<double> result_f = hpx::async(&do_sth, 500);
  24.  
  25.     hpx::cout << "Result = " << result_f.get();
  26.  
  27.     return hpx::stop();
  28. }
Advertisement
Add Comment
Please, Sign In to add comment