Skip to content

Commit

Permalink
Merge pull request #989 from DARMA-tasking/955-clear-out-uses-of-addA…
Browse files Browse the repository at this point in the history
…ction-in-tests-part4

955 clear out uses of addAction from tests
  • Loading branch information
lifflander authored Aug 25, 2020
2 parents 6928cc1 + 42c49cf commit b5e7503
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 81 deletions.
80 changes: 39 additions & 41 deletions tests/unit/location/test_location_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,53 +147,51 @@ void verifyCacheConsistency(
) {

for (int iter = 0; iter < nb_rounds; ++iter) {
// create an epoch for the current round, and
// perform the checks only at the end of the epoch
// to ensure that all entity messages have been
// correctly delivered before.
runInEpochCollective([&]{
// create an entity message to route
auto msg = vt::makeMessage<MsgT>(entity, my_node);
// check if should be serialized or not
bool serialize = msg->getSerialize();

if (my_node not_eq home) {
// check the routing protocol to be used by the manager.
bool is_eager = theLocMan()->virtual_loc->useEagerProtocol(msg);

// check for cache updates
bool is_entity_cached = isCached(entity);

vt_debug_print(
location, node,
"verifyCacheConsistency: iter={}, entityID={}, home={}, bytes={}, "
"in cache={}, serialize={}\n",
iter, entity, msg->from_, sizeof(*msg), is_entity_cached, serialize
);

if (not is_eager) {
// On non eager case: the location is first explicitly resolved
// and then the message is routed and the cache updated.
// Hence, the entity is not yet registered in cache after the
// first send, but will be for next ones.
EXPECT_TRUE(iter < 1 or is_entity_cached);
} else if(my_node not_eq new_home) {
// On eager case: the message is directly routed to the
// implicitly resolved location.
// Thus the cache is not updated in this case.
EXPECT_FALSE(is_entity_cached);
}
} else /* my_node == home */ {
// The entity should be registered in the cache of the home node,
// regardless of the protocol (eager or not)
EXPECT_TRUE(isCached(entity));
}
// create an entity message to route
auto msg = vt::makeMessage<MsgT>(entity, my_node);
// check if should be serialized or not
bool serialize = msg->getSerialize();

// perform the checks only after all entity messages have been
// correctly delivered
runInEpochCollective([&]{
if (my_node not_eq home) {
// route entity message
vt::theLocMan()->virtual_loc->routeMsg<MsgT>(entity, home, msg, serialize);
}
});

if (my_node not_eq home) {
// check the routing protocol to be used by the manager.
bool is_eager = theLocMan()->virtual_loc->useEagerProtocol(msg);

// check for cache updates
bool is_entity_cached = isCached(entity);

vt_debug_print(
location, node,
"verifyCacheConsistency: iter={}, entityID={}, home={}, bytes={}, "
"in cache={}, serialize={}\n",
iter, entity, msg->from_, sizeof(*msg), is_entity_cached, serialize
);

if (not is_eager) {
// On non eager case: the location is first explicitly resolved
// and then the message is routed and the cache updated.
// Hence, the entity is not yet registered in cache after the
// first send, but will be for next ones.
EXPECT_TRUE(iter < 1 or is_entity_cached);
} else if(my_node not_eq new_home) {
// On eager case: the message is directly routed to the
// implicitly resolved location.
// Thus the cache is not updated in this case.
EXPECT_FALSE(is_entity_cached);
}
} else /* my_node == home */ {
// The entity should be registered in the cache of the home node,
// regardless of the protocol (eager or not)
EXPECT_TRUE(isCached(entity));
}
}
}

Expand Down
99 changes: 59 additions & 40 deletions tests/unit/pipe/test_callback_bcast_collection.extended.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ namespace vt { namespace tests { namespace unit {
using namespace vt;
using namespace vt::tests::unit;

struct TestColMsg;

struct CallbackMsg : vt::Message {
CallbackMsg() = default;
explicit CallbackMsg(Callback<> in_cb) : cb_(in_cb) { }
Expand Down Expand Up @@ -89,11 +91,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(TestColMsg* msg) {
if (other) {
EXPECT_EQ(val, 29);
} else {
Expand Down Expand Up @@ -128,20 +128,27 @@ static void cb3(DataMsg* msg, TestCol* col) {
col->val = 13;
}

struct TestColMsg : ::vt::CollectionMessage<TestCol> {};

TEST_F(TestCallbackBcastCollection, test_callback_bcast_collection_1) {
auto const& this_node = theContext()->getNode();
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());
}
});

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();
});
}
runInEpochCollective([&]{
if (this_node == 0) {
auto msg = makeMessage<TestColMsg>();
proxy.broadcast<TestColMsg, &TestCol::check>(msg.get());
}
});
}

TEST_F(TestCallbackBcastCollection, test_callback_bcast_collection_2) {
Expand All @@ -152,18 +159,24 @@ 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 msg = makeMessage<TestColMsg>();
proxy.broadcast<TestColMsg, &TestCol::check>(msg.get());
}
});
}

TEST_F(TestCallbackBcastCollection, test_callback_bcast_collection_3) {
Expand All @@ -174,18 +187,24 @@ 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 msg = makeMessage<TestColMsg>();
proxy.broadcast<TestColMsg, &TestCol::check>(msg.get());
}
});
}

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

0 comments on commit b5e7503

Please sign in to comment.