Skip to content

Instantly share code, notes, and snippets.

@kempj
Created November 18, 2017 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kempj/4f7122d7afdc5646033a5494777d832f to your computer and use it in GitHub Desktop.
Save kempj/4f7122d7afdc5646033a5494777d832f to your computer and use it in GitHub Desktop.
dataflow with executor example
#include <hpx/hpx.hpp>
#include <hpx/dataflow.hpp>
#include <hpx/parallel/executors/thread_pool_executors.hpp>
#include <iostream>
using hpx::threads::executors::local_priority_queue_executor;
using hpx::shared_future;
using hpx::dataflow;
using hpx::async;
using hpx::util::unwrapping;
int add(int a, int b) {
return a+b;
}
int hpx_main()
{
{
local_priority_queue_executor exec;
shared_future<int> f1 = async(exec, add, 2, 3);
shared_future<int> f2 = async(exec, add, 4, 5);
shared_future<int> f3 = dataflow(exec, unwrapping(add), f1, f2);
std::cout << f3.get() << std::endl;
}
return hpx::finalize();
}
int main(int argc, char ** argv)
{
return hpx::init(argc, argv);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment