Skip to content

Commit

Permalink
Examples: convert some to not make their own scheduler calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Miller authored and lifflander committed Jun 10, 2020
1 parent af0ec76 commit f5680a1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 30 deletions.
23 changes: 6 additions & 17 deletions examples/collection/lb_iter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,6 @@ void IterCol::iterWork(IterMsg* msg) {
}
}

template <typename Callable>
void executeInEpoch(Callable&& fn) {
auto this_node = vt::theContext()->getNode();
auto ep = vt::theTerm()->makeEpochCollective();
vt::theMsg()->pushEpoch(ep);
if (this_node == 0) {
fn();
}
vt::theMsg()->popEpoch(ep);
vt::theTerm()->finishedEpoch(ep);
vt::runSchedulerThrough(ep);
}

int main(int argc, char** argv) {
vt::initialize(argc, argv);

Expand Down Expand Up @@ -151,17 +138,19 @@ int main(int argc, char** argv) {
for (int i = 0; i < num_iter; i++) {
auto cur_time = vt::timing::Timing::getCurrentTime();

executeInEpoch([=]{
proxy.broadcast<IterCol::IterMsg,&IterCol::iterWork>(10, i);
vt::runInEpochCollective([=]{
if (this_node == 0)
proxy.broadcast<IterCol::IterMsg,&IterCol::iterWork>(10, i);
});

auto total_time = vt::timing::Timing::getCurrentTime() - cur_time;
if (this_node == 0) {
fmt::print("iteration: iter={},time={}\n", i, total_time);
}

executeInEpoch([=]{
proxy.broadcast<IterCol::EmptyMsg,&IterCol::runLB>();
vt::runInEpochCollective([=]{
if (this_node == 0)
proxy.broadcast<IterCol::EmptyMsg,&IterCol::runLB>();
});

}
Expand Down
16 changes: 3 additions & 13 deletions examples/collection/migrate_collection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,6 @@ static void migrateToNext(ColMsg* msg, Hello* col) {
col->migrate(next_node);
}

template <typename Callable>
void executeInEpoch(Callable&& fn) {
auto ep = vt::theTerm()->makeEpochRooted();
vt::theMsg()->pushEpoch(ep);
fn();
vt::theMsg()->popEpoch(ep);
vt::theTerm()->finishedEpoch(ep);
vt::runSchedulerThrough(ep);
}

int main(int argc, char** argv) {
vt::initialize(argc, argv);

Expand All @@ -115,17 +105,17 @@ int main(int argc, char** argv) {
auto range = vt::Index1D(num_elms);
auto proxy = vt::theCollection()->construct<Hello>(range, this_node);

executeInEpoch([=]{
vt::runInEpochRooted([=]{
auto msg = vt::makeMessage<ColMsg>(this_node);
proxy.broadcast<ColMsg, doWork>(msg.get());
});

executeInEpoch([=]{
vt::runInEpochRooted([=]{
auto msg = vt::makeMessage<ColMsg>(this_node);
proxy.broadcast<ColMsg, migrateToNext>(msg.get());
});

executeInEpoch([=]{
vt::runInEpochRooted([=]{
auto msg = vt::makeMessage<ColMsg>(this_node);
proxy.broadcast<ColMsg, doWork>(msg.get());
});
Expand Down

0 comments on commit f5680a1

Please sign in to comment.