Guest User

Untitled

a guest
Nov 19th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <hpx/hpx.hpp>
  2. #include <hpx/dataflow.hpp>
  3. #include <hpx/parallel/executors/thread_pool_executors.hpp>
  4.  
  5. #include <iostream>
  6.  
  7. using hpx::threads::executors::local_priority_queue_executor;
  8. using hpx::shared_future;
  9. using hpx::dataflow;
  10. using hpx::async;
  11. using hpx::util::unwrapping;
  12.  
  13.  
  14. int add(int a, int b) {
  15. return a+b;
  16. }
  17.  
  18. int hpx_main()
  19. {
  20. {
  21. local_priority_queue_executor exec;
  22.  
  23. shared_future<int> f1 = async(exec, add, 2, 3);
  24. shared_future<int> f2 = async(exec, add, 4, 5);
  25. shared_future<int> f3 = dataflow(exec, unwrapping(add), f1, f2);
  26.  
  27. std::cout << f3.get() << std::endl;
  28. }
  29.  
  30. return hpx::finalize();
  31. }
  32.  
  33. int main(int argc, char ** argv)
  34. {
  35. return hpx::init(argc, argv);
  36. }
Add Comment
Please, Sign In to add comment