Skip to content

Commit

Permalink
#955 remove addAction usage from test_callback_bcast_collection.exten…
Browse files Browse the repository at this point in the history
…ded.cc
  • Loading branch information
cz4rs committed Aug 18, 2020
1 parent 3dfddb2 commit 82d50b7
Showing 1 changed file with 61 additions and 41 deletions.
102 changes: 61 additions & 41 deletions tests/unit/pipe/test_callback_bcast_collection.extended.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,9 @@ struct TestCallbackBcastCollection : TestParallelHarness {
struct TestCol : vt::Collection<TestCol, vt::Index1D> {
TestCol() = default;

virtual ~TestCol() {
// fmt::print(
// "{}: destroying {}: val={}\n",
// theContext()->getNode(), this->getIndex(), val
// );
virtual ~TestCol() = default;

void check(DataMsg* msg) {
if (other) {
EXPECT_EQ(val, 29);
} else {
Expand Down Expand Up @@ -130,18 +128,26 @@ static void cb3(DataMsg* msg, TestCol* col) {

TEST_F(TestCallbackBcastCollection, test_callback_bcast_collection_1) {
auto const& this_node = theContext()->getNode();

if (this_node == 0) {
auto const& range = Index1D(32);
auto proxy = theCollection()->construct<TestCol>(range);
auto cb = theCB()->makeBcast<TestCol,DataMsg,&TestCol::cb1>(proxy);
auto nmsg = makeMessage<DataMsg>(8,9,10);
cb.send(nmsg.get());

theTerm()->addAction([=]{
proxy.destroy();
});
}
auto const& range = Index1D(32);
auto proxy = theCollection()->construct<TestCol>(range);

runInEpochCollective([&]{
if (this_node == 0) {
auto cb = theCB()->makeBcast<TestCol,DataMsg,&TestCol::cb1>(proxy);
auto nmsg = makeMessage<DataMsg>(8,9,10);
cb.send(nmsg.get());
}
});

runInEpochCollective([&]{
if (this_node == 0) {
for (auto i = 0; i < 32; i++) {
auto cb = theCB()->makeBcast<TestCol,DataMsg,&TestCol::check>(proxy);
auto nmsg = makeMessage<DataMsg>();
cb.send(nmsg.get());
}
}
});
}

TEST_F(TestCallbackBcastCollection, test_callback_bcast_collection_2) {
Expand All @@ -152,18 +158,25 @@ TEST_F(TestCallbackBcastCollection, test_callback_bcast_collection_2) {
return;
}

if (this_node == 0) {
auto const& range = Index1D(32);
auto proxy = theCollection()->construct<TestCol>(range);
auto next = this_node + 1 < num_nodes ? this_node + 1 : 0;
auto cb = theCB()->makeBcast<TestCol,DataMsg,&TestCol::cb2>(proxy);
auto msg = makeMessage<CallbackDataMsg>(cb);
theMsg()->sendMsg<CallbackDataMsg, testHandler>(next, msg.get());

theTerm()->addAction([=]{
proxy.destroy();
});
}
auto const& range = Index1D(32);
auto proxy = theCollection()->construct<TestCol>(range);

runInEpochCollective([&]{
if (this_node == 0) {
auto next = this_node + 1 < num_nodes ? this_node + 1 : 0;
auto cb = theCB()->makeBcast<TestCol,DataMsg,&TestCol::cb2>(proxy);
auto msg = makeMessage<CallbackDataMsg>(cb);
theMsg()->sendMsg<CallbackDataMsg, testHandler>(next, msg.get());
}
});

runInEpochCollective([&]{
if (this_node == 0) {
auto cb = theCB()->makeBcast<TestCol,DataMsg,&TestCol::check>(proxy);
auto nmsg = makeMessage<DataMsg>();
cb.send(nmsg.get());
}
});
}

TEST_F(TestCallbackBcastCollection, test_callback_bcast_collection_3) {
Expand All @@ -174,18 +187,25 @@ TEST_F(TestCallbackBcastCollection, test_callback_bcast_collection_3) {
return;
}

if (this_node == 0) {
auto const& range = Index1D(32);
auto proxy = theCollection()->construct<TestCol>(range);
auto next = this_node + 1 < num_nodes ? this_node + 1 : 0;
auto cb = theCB()->makeBcast<TestCol,DataMsg,cb3>(proxy);
auto msg = makeMessage<CallbackDataMsg>(cb);
theMsg()->sendMsg<CallbackDataMsg, testHandler>(next, msg.get());

theTerm()->addAction([=]{
proxy.destroy();
});
}
auto const& range = Index1D(32);
auto proxy = theCollection()->construct<TestCol>(range);

runInEpochCollective([&]{
if (this_node == 0) {
auto next = this_node + 1 < num_nodes ? this_node + 1 : 0;
auto cb = theCB()->makeBcast<TestCol,DataMsg,cb3>(proxy);
auto msg = makeMessage<CallbackDataMsg>(cb);
theMsg()->sendMsg<CallbackDataMsg, testHandler>(next, msg.get());
}
});

runInEpochCollective([&]{
if (this_node == 0) {
auto cb = theCB()->makeBcast<TestCol,DataMsg,&TestCol::check>(proxy);
auto nmsg = makeMessage<DataMsg>();
cb.send(nmsg.get());
}
});
}

}}} // end namespace vt::tests::unit

0 comments on commit 82d50b7

Please sign in to comment.