Skip to content

Instantly share code, notes, and snippets.

@ltroska
Created February 24, 2016 14:44
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 ltroska/080e7a41572c454a1a65 to your computer and use it in GitHub Desktop.
Save ltroska/080e7a41572c454a1a65 to your computer and use it in GitHub Desktop.
gather segfault
#include <hpx/hpx_init.hpp>
#include <hpx/hpx.hpp>
#include <hpx/lcos/gather.hpp>
char const* gather_basename = "/test/gather/";
HPX_REGISTER_GATHER(double, test_gather);
int hpx_main(int argc, char* argv[])
{
for (uint i = 0; i < 10; i++)
{
hpx::future<double> value = hpx::make_ready_future(static_cast<double>(hpx::get_locality_id()));
if (hpx::get_locality_id() == 0)
{
hpx::future<std::vector<double> > overall_result =
hpx::lcos::gather_here(gather_basename, std::move(value), hpx::get_num_localities_sync());
std::vector<double> sol = overall_result.get();
for (int i = 0; i < sol.size(); i++)
{
std::cout << "got residual " << sol[i] << " from " << i << std::endl;
}
}
else
{
hpx::lcos::gather_there(gather_basename, std::move(value)).wait();
}
}
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