Skip to content

Commit

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

#955 clear out uses of addAction in tests
  • Loading branch information
lifflander authored Sep 18, 2020
2 parents fb8f234 + c213b7f commit c1e55fd
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 190 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dockerimage-gcc-5-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
message("::set-output name=timestamp::${current_date}")
- uses: actions/cache@v1
env:
cache-name: ubuntu-gcc-5-cache
cache-name: ubuntu-gcc-5-cache-new
with:
path: ${{ env.BUILD_ROOT }}/ccache
key: ${{ runner.os }}-${{ env.cache-name }}-${{ steps.cache_ts.outputs.timestamp }}
Expand Down
1 change: 1 addition & 0 deletions scripts/workflows.ini
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ test_configuration = "gcc-5, ubuntu, mpich"
compiler_type = gnu
compiler = gcc-5
output_name = .github/workflows/dockerimage-gcc-5-ubuntu-mpich.yml
cache_name = "[% linux %]-[% compiler %]-cache-new"

[PR-tests-gcc-6]
test_configuration = "gcc-6, ubuntu, mpich"
Expand Down
24 changes: 13 additions & 11 deletions tests/unit/active/test_active_send.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,20 @@ TEST_F(TestActiveSend, test_type_safe_active_fn_send) {
fmt::print("test_type_safe_active_fn_send: node={}\n", my_node);
#endif

if (my_node == from_node) {
for (int i = 0; i < num_msg_sent; i++) {
#if DEBUG_TEST_HARNESS_PRINT
fmt::print("{}: sendMsg: i={}\n", my_node, i);
#endif
auto msg = makeMessage<TestMsg>();
theMsg()->sendMsg<TestMsg, test_handler>(to_node, msg);
vt::runInEpochCollective([&]{
if (my_node == from_node) {
for (int i = 0; i < num_msg_sent; i++) {
#if DEBUG_TEST_HARNESS_PRINT
fmt::print("{}: sendMsg: i={}\n", my_node, i);
#endif
auto msg = makeMessage<TestMsg>();
theMsg()->sendMsg<TestMsg, test_handler>(1, msg);
}
}
} else if (my_node == to_node) {
theTerm()->addAction([=]{
EXPECT_EQ(handler_count, num_msg_sent);
});
});

if (my_node == to_node) {
EXPECT_EQ(handler_count, num_msg_sent);
}

// Spin here so test_vec does not go out of scope before the send completes
Expand Down
13 changes: 6 additions & 7 deletions tests/unit/active/test_pending_send.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ TEST_F(TestPendingSend, test_pending_send_hold) {
delivered = false;

std::vector<messaging::PendingSend> pending;
bool done = false;
auto ep = theTerm()->makeEpochCollective();
theMsg()->pushEpoch(ep);

Expand All @@ -92,13 +91,13 @@ TEST_F(TestPendingSend, test_pending_send_hold) {
EXPECT_EQ(envelopeGetEpoch(msg_hold->env), ep);

theMsg()->popEpoch(ep);
theTerm()->addAction(ep, [&done] { done = true; });
theTerm()->finishedEpoch(ep);

// It should not break out of this loop because of `done`, thus `k` is used to
// It should not break out of this loop because of
// !theTerm()->isEpochTermianted(ep), thus `k` is used to
// break out
int k = 0;
while (not done) {
while (!theTerm()->isEpochTerminated(ep)) {
k++;
vt::runScheduler();
if (k > 10) {
Expand All @@ -107,15 +106,15 @@ TEST_F(TestPendingSend, test_pending_send_hold) {
}

// Epoch should not end with a valid pending send created in an live epoch
EXPECT_EQ(done, false);
EXPECT_EQ(theTerm()->isEpochTerminated(ep), false);
EXPECT_EQ(delivered, false);

// Now we send the message off!
pending.clear();

do vt::runScheduler(); while (not done);
vt::runSchedulerThrough(ep);

EXPECT_EQ(done, true);
EXPECT_EQ(theTerm()->isEpochTerminated(ep), true);
EXPECT_EQ(delivered, true);
}

Expand Down
19 changes: 4 additions & 15 deletions tests/unit/collection/test_checkpoint.extended.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,6 @@ struct TestCol : vt::Collection<TestCol,vt::Index3D> {
std::shared_ptr<int> token;
};

static void runInEpoch(std::function<void()> fn) {
vt::EpochType ep = vt::theTerm()->makeEpochCollective();
vt::theMsg()->pushEpoch(ep);
fn();
vt::theMsg()->popEpoch(ep);
vt::theTerm()->finishedEpoch(ep);
bool done = false;
vt::theTerm()->addAction(ep, [&]{ done = true; });
vt::theSched()->runSchedulerWhile([&] { return not done; });
}

using TestCheckpoint = TestParallelHarness;

static constexpr int32_t const num_elms = 8;
Expand All @@ -178,14 +167,14 @@ TEST_F(TestCheckpoint, test_checkpoint_1) {
}
);

runInEpoch([&]{
vt::runInEpochCollective([&]{
if (this_node == 0) {
proxy.broadcast<TestCol::NullMsg,&TestCol::init>();
}
});

for (int i = 0; i < 5; i++) {
runInEpoch([&]{
vt::runInEpochCollective([&]{
if (this_node == 0) {
proxy.template broadcast<TestCol::NullMsg,&TestCol::doIter>();
}
Expand All @@ -198,14 +187,14 @@ TEST_F(TestCheckpoint, test_checkpoint_1) {
vt::theCollective()->barrier();

// Null the token to ensure we don't end up getting the same instance
runInEpoch([&]{
vt::runInEpochCollective([&]{
if (this_node == 0) {
proxy.broadcast<TestCol::NullMsg,&TestCol::nullToken>();
}
});

// Destroy the collection
runInEpoch([&]{
vt::runInEpochCollective([&]{
if (this_node == 0) {
proxy.destroy();
}
Expand Down
21 changes: 11 additions & 10 deletions tests/unit/collection/test_destroy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,19 @@ static constexpr int32_t const num_elms_per_node = 8;
TEST_F(TestDestroy, test_destroy_1) {
auto const& this_node = theContext()->getNode();
auto const& num_nodes = theContext()->getNumNodes();
if (this_node == 0) {
auto const& range = Index1D(num_nodes * num_elms_per_node);
auto proxy = theCollection()->construct<DestroyTest>(range);
auto msg = makeMessage<WorkMsg>();
// ::fmt::print("broadcasting proxy={:x}\n", proxy.getProxy());
proxy.broadcast<WorkMsg,DestroyTest::work>(msg.get());
}
theTerm()->addAction([]{

vt::runInEpochCollective([&]{
if (this_node == 0) {
auto const& range = Index1D(num_nodes * num_elms_per_node);
auto proxy = theCollection()->construct<DestroyTest>(range);
auto msg = makeMessage<WorkMsg>();
// ::fmt::print("broadcasting proxy={:x}\n", proxy.getProxy());
proxy.broadcast<WorkMsg,DestroyTest::work>(msg.get());
}
});
// ::fmt::print("num destroyed={}\n", num_destroyed);
// Relies on default mapping equally distributing
EXPECT_EQ(num_destroyed, num_elms_per_node);
});
EXPECT_EQ(num_destroyed, num_elms_per_node);
}

}}} // end namespace vt::tests::unit
168 changes: 86 additions & 82 deletions tests/unit/collection/test_insert.extended.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct InsertTest : InsertableCollection<InsertTest,Index1D> {
};

void InsertTest::work(WorkMsg* msg) {
// ::fmt::print("node={}: num_work={}\n", theContext()->getNode(), num_work);
//::fmt::print("node={}: num_work={}\n", theContext()->getNode(), num_work);
num_work++;
}

Expand All @@ -89,126 +89,130 @@ static constexpr int32_t const num_elms_per_node = 8;
TEST_F(TestInsert, test_insert_dense_1) {
auto const& this_node = theContext()->getNode();
auto const& num_nodes = theContext()->getNumNodes();
if (this_node == 0) {
auto const& range = Index1D(num_nodes * num_elms_per_node);
auto proxy = theCollection()->construct<InsertTest>(range);
for (auto i = 0; i < range.x(); i++) {
proxy[i].insert();

vt::runInEpochCollective([&]{
if (this_node == 0) {
auto const& range = Index1D(num_nodes * num_elms_per_node);
auto proxy = theCollection()->construct<InsertTest>(range);
for (auto i = 0; i < range.x(); i++) {
proxy[i].insert();
}
}
}
theTerm()->addAction([]{
/// ::fmt::print("num inserted={}\n", num_inserted);
// Relies on default mapping equally distributing
EXPECT_EQ(num_inserted, num_elms_per_node);
num_inserted = 0;
});
EXPECT_EQ(num_inserted, num_elms_per_node);
num_inserted = 0;
}

TEST_F(TestInsert, test_insert_sparse_1) {
auto const& this_node = theContext()->getNode();
auto const& num_nodes = theContext()->getNumNodes();
if (this_node == 0) {
auto const& range = Index1D(num_nodes * num_elms_per_node * 16);
auto proxy = theCollection()->construct<InsertTest>(range);
for (auto i = 0; i < range.x(); i+=16) {
proxy[i].insert();

vt::runInEpochCollective([&]{
if (this_node == 0) {
auto const& range = Index1D(num_nodes * num_elms_per_node * 16);
auto proxy = theCollection()->construct<InsertTest>(range);
for (auto i = 0; i < range.x(); i+=16) {
proxy[i].insert();
}
}
}
theTerm()->addAction([]{
/// ::fmt::print("num inserted={}\n", num_inserted);
// Relies on default mapping equally distributing
EXPECT_EQ(num_inserted, num_elms_per_node);
num_inserted = 0;
});
/// ::fmt::print("num inserted={}\n", num_inserted);
// Relies on default mapping equally distributing
EXPECT_EQ(num_inserted, num_elms_per_node);
num_inserted = 0;
}

TEST_F(TestInsert, test_insert_dense_node_1) {
auto const& this_node = theContext()->getNode();
auto const& num_nodes = theContext()->getNumNodes();
if (this_node == 0) {
auto const& range = Index1D(num_nodes * num_elms_per_node);
auto proxy = theCollection()->construct<InsertTest>(range);
for (auto i = 0; i < range.x(); i++) {
proxy[i].insert(this_node);
}
}
theTerm()->addAction([=]{
/// ::fmt::print("num inserted={}\n", num_inserted);
// Relies on default mapping equally distributing

vt::runInEpochCollective([&]{
if (this_node == 0) {
EXPECT_EQ(num_inserted, num_elms_per_node * num_nodes);
auto const& range = Index1D(num_nodes * num_elms_per_node);
auto proxy = theCollection()->construct<InsertTest>(range);
for (auto i = 0; i < range.x(); i++) {
proxy[i].insert(this_node);
}
}
num_inserted = 0;
});
/// ::fmt::print("num inserted={}\n", num_inserted);
// Relies on default mapping equally distributing
if (this_node == 0) {
EXPECT_EQ(num_inserted, num_elms_per_node * num_nodes);
}
num_inserted = 0;
}

TEST_F(TestInsert, test_insert_sparse_node_1) {
auto const& this_node = theContext()->getNode();
auto const& num_nodes = theContext()->getNumNodes();
if (this_node == 0) {
auto const& range = Index1D(num_nodes * num_elms_per_node * 16);
auto proxy = theCollection()->construct<InsertTest>(range);
for (auto i = 0; i < range.x(); i+=16) {
proxy[i].insert(this_node);
}
}
theTerm()->addAction([=]{
/// ::fmt::print("num inserted={}\n", num_inserted);
// Relies on default mapping equally distributing

vt::runInEpochCollective([&]{
if (this_node == 0) {
EXPECT_EQ(num_inserted, num_elms_per_node * num_nodes);
auto const& range = Index1D(num_nodes * num_elms_per_node * 16);
auto proxy = theCollection()->construct<InsertTest>(range);
for (auto i = 0; i < range.x(); i+=16) {
proxy[i].insert(this_node);
}
}
num_inserted = 0;
});
/// ::fmt::print("num inserted={}\n", num_inserted);
// Relies on default mapping equally distributing
if (this_node == 0) {
EXPECT_EQ(num_inserted, num_elms_per_node * num_nodes);
}
num_inserted = 0;
}

TEST_F(TestInsert, test_insert_send_dense_node_1) {
auto const& this_node = theContext()->getNode();
auto const& num_nodes = theContext()->getNumNodes();
if (this_node == 0) {
auto const& range = Index1D(num_nodes * num_elms_per_node);
auto proxy = theCollection()->construct<InsertTest>(range);
for (auto i = 0; i < range.x(); i++) {
proxy[i].insert((this_node + 1) % num_nodes);
auto msg = makeMessage<WorkMsg>();
proxy[i].send<WorkMsg,&InsertTest::work>(msg.get());
// ::fmt::print("sending to {}\n", i);
}
}
theTerm()->addAction([=]{
/// ::fmt::print("num inserted={}\n", num_inserted);
// Relies on default mapping equally distributing
if (this_node == 1 || (this_node == 0 && num_nodes == 1)) {
EXPECT_EQ(num_inserted, num_elms_per_node * num_nodes);
EXPECT_EQ(num_work, num_elms_per_node * num_nodes);

vt::runInEpochCollective([&]{
if (this_node == 0) {
auto const& range = Index1D(num_nodes * num_elms_per_node);
auto proxy = theCollection()->construct<InsertTest>(range);
for (auto i = 0; i < range.x(); i++) {
proxy[i].insert((this_node + 1) % num_nodes);
auto msg = makeMessage<WorkMsg>();
proxy[i].send<WorkMsg,&InsertTest::work>(msg.get());
// ::fmt::print("sending to {}\n", i);
}
}
num_inserted = 0;
num_work = 0;
});
/// ::fmt::print("num inserted={}\n", num_inserted);
// Relies on default mapping equally distributing
if (this_node == 1 || (this_node == 0 && num_nodes == 1)) {
EXPECT_EQ(num_inserted, num_elms_per_node * num_nodes);
EXPECT_EQ(num_work, num_elms_per_node * num_nodes);
}
num_inserted = 0;
num_work = 0;
}

TEST_F(TestInsert, test_insert_send_sparse_node_1) {
auto const& this_node = theContext()->getNode();
auto const& num_nodes = theContext()->getNumNodes();
if (this_node == 0) {
auto const& range = Index1D(num_nodes * num_elms_per_node * 16);
auto proxy = theCollection()->construct<InsertTest>(range);
for (auto i = 0; i < range.x(); i+=16) {
proxy[i].insert((this_node + 1) % num_nodes);
auto msg = makeMessage<WorkMsg>();
proxy[i].send<WorkMsg,&InsertTest::work>(msg.get());
}
}
theTerm()->addAction([=]{
/// ::fmt::print("num inserted={}\n", num_inserted);
// Relies on default mapping equally distributing
if (this_node == 1 || (this_node == 0 && num_nodes == 1)) {
EXPECT_EQ(num_inserted, num_elms_per_node * num_nodes);
EXPECT_EQ(num_work, num_elms_per_node * num_nodes);

vt::runInEpochCollective([&]{
if (this_node == 0) {
auto const& range = Index1D(num_nodes * num_elms_per_node * 16);
auto proxy = theCollection()->construct<InsertTest>(range);
for (auto i = 0; i < range.x(); i+=16) {
proxy[i].insert((this_node + 1) % num_nodes);
auto msg = makeMessage<WorkMsg>();
proxy[i].send<WorkMsg,&InsertTest::work>(msg.get());
}
}
num_inserted = 0;
num_work = 0;
});
/// ::fmt::print("num inserted={}\n", num_inserted);
// Relies on default mapping equally distributing
if (this_node == 1 || (this_node == 0 && num_nodes == 1)) {
EXPECT_EQ(num_inserted, num_elms_per_node * num_nodes);
EXPECT_EQ(num_work, num_elms_per_node * num_nodes);
}
num_inserted = 0;
num_work = 0;
}

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

0 comments on commit c1e55fd

Please sign in to comment.