Skip to content

Commit

Permalink
examples/reduce_integral: Run work in a closed epoch, rather than add…
Browse files Browse the repository at this point in the history
…ing an action to the global epoch
  • Loading branch information
Phil Miller authored and lifflander committed Jun 10, 2020
1 parent f5680a1 commit fde87f3
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions examples/collection/reduce_integral.cc
Original file line number Diff line number Diff line change
Expand Up @@ -221,27 +221,28 @@ int main(int argc, char** argv) {
}
}

if (this_node == 0) {
//
// Create the interval decomposition into objects
//
using BaseIndexType = typename vt::Index1D::DenseIndexType;
auto range = vt::Index1D(static_cast<BaseIndexType>(num_objs));

auto proxy = vt::theCollection()->construct<Integration1D>(range);
proxy.broadcast<Integration1D::InitMsg,&Integration1D::compute>(
num_objs, numIntPerObject
);
}
vt::runInEpochCollective([=]{
if (this_node == 0) {
//
// Create the interval decomposition into objects
//
using BaseIndexType = typename vt::Index1D::DenseIndexType;
auto range = vt::Index1D(static_cast<BaseIndexType>(num_objs));

auto proxy = vt::theCollection()->construct<Integration1D>(range);
proxy.broadcast<Integration1D::InitMsg,&Integration1D::compute>
(
num_objs, numIntPerObject
);
}
});

// Add something like this to validate the reduction.
// Create the variable root_reduce_finished as a static variable,
// which is only checked on one node.
vt::theTerm()->addAction([]{
if (vt::theContext()->getNode() == reduce_root_node) {
vtAssertExpr(root_reduce_finished == true);
}
});
if (vt::theContext()->getNode() == reduce_root_node) {
vtAssertExpr(root_reduce_finished == true);
}

vt::finalize();

Expand Down

0 comments on commit fde87f3

Please sign in to comment.