Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <hpx/hpx_main.hpp>
- #include <hpx/include/lcos.hpp>
- #include <hpx/include/actions.hpp>
- #include <hpx/include/components.hpp>
- #include <hpx/include/iostreams.hpp>
- #include <boost/format.hpp>
- #include <cstddef>
- #include <list>
- #include <mutex>
- #include <set>
- #include <vector>
- std::size_t total_tasks;
- void task_worker(std::size_t id)
- {
- printf("task: %d rank: %d\n", (int)id, hpx::get_locality_id());
- }
- HPX_PLAIN_ACTION(task_worker, task_worker_action);
- int main(int argc, char **argv)
- {
- std::vector<hpx::id_type> localities = hpx::find_all_localities();
- std::vector<hpx::future<void> > futures;
- futures.reserve(localities.size() + 1);
- printf("There are localities: %d\n", localities.size());
- task_worker_action an_action;
- std::size_t id = 0;
- for (hpx::id_type const& node : localities)
- {
- if(id != 0) {
- //futures.push_back(hpx::async<action_type>(node, id));
- futures.push_back(futures[id-1].then(
- // capture id,here by value
- // capture action by reference
- [id, node, &an_action](hpx::future<void> &&f) {
- // call the action again as a continuation on the other one
- an_action(node, id);
- }));
- } else {
- futures.push_back(hpx::async(an_action, node, id));
- }
- id++;
- }
- //futures.push_back(hpx::async<action_type>(node, id));
- hpx::id_type const& node = localities[0];
- futures.push_back(futures[id-1].then(
- // capture id,here by value
- // capture action by reference
- [id, node, &an_action](hpx::future<void> &&f) {
- // call the action again as a continuation on the other one
- an_action(node, id);
- }));
- hpx::wait_all(futures);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement