I'm doing some experiments with hpx::dataflow and would like to recursively
"chain" a dataflow for execution over a distributed vector of size_t
elements.

Sample code is provided below (apologies if it's not a perfect compile):

static void run(
  std::string nom,
  size_t v) {
  hpx::cout << v << hpx::endl;
}

HPX_PLAIN_ACTION(run, run_action);

static hpx::future<void> run_dataflow(
  std::string nom,
  hpx::partitioned_vector<size_t> &arr,
  std::vector<hpx::id_type> locs,
  std::vector<size_t>::iterator curr,
  std::vector<size_t>::iterator end) {

hpx::future<void> res = (curr != end) ? run_dataflow(nom, arr, locs,
std::next(curr), end) : hpx::make_ready_future();

return hpx::dataflow(
  hpx::util::unwrapped([nom, &arr, localities, &curr] () ->
hpx::future<void> {
    size_t v = *c;
    return hpx::async<run_action>(localities[arr.get_partition(v)], nom, v);
  }),
  std::move(res) );

}

int main(int argc, char **argv) {

... /* dvec_size is defined up here */ ...

std::vector<hpx::id_type> locs = hpx::find_all_localities();

std::string nom = "arr_nom";
hpx::partitioned_vector<size_t> arr(dvec_size, hpx::container_layout(locs));
arr.register_as(nom);

std::vector<size_t> pos;
std::iota(
  std::begin(pos),
  std::end(pos),
  dvec_size);

hpx::future<void> fd = run_dataflow(
  nom,
  arr,
  std::begin(pos),
  std::end(pos) );

fd.wait();

}

I've been getting a runtime errors for this code (segmentation fault) -
this is probably a semi-trivial bug or misunderstanding on my part - any
help/assistance would be appreciated. (I'm compiling against HPX with MPI)

V/r,

Chris
_______________________________________________
hpx-users mailing list
[email protected]
https://mail.cct.lsu.edu/mailman/listinfo/hpx-users

Reply via email to