From 7d80b9fd469d59e740d7c0b3056716706a0d074f Mon Sep 17 00:00:00 2001 From: Jakub Domagala Date: Sun, 16 Aug 2020 19:24:29 +0200 Subject: [PATCH 1/4] #955 Clear out uses of addAction in tests --- tests/unit/pipe/test_callback_func.cc | 16 +-- tests/unit/pipe/test_callback_func_ctx.cc | 41 ++++--- tests/unit/pipe/test_callback_send.cc | 70 ++++++----- .../test_callback_send_collection.extended.cc | 110 +++++++++-------- .../test_rdma_collection_handle.extended.cc | 24 ++-- .../unit/sequencer/test_sequencer.extended.cc | 112 ++++++++--------- .../test_sequencer_extensive.extended.cc | 46 +++---- .../sequencer/test_sequencer_for.extended.cc | 22 ++-- .../test_sequencer_nested.extended.cc | 27 +++-- .../test_sequencer_parallel.extended.cc | 51 ++++---- .../sequencer/test_sequencer_vrt.extended.cc | 113 +++++++++--------- 11 files changed, 326 insertions(+), 306 deletions(-) diff --git a/tests/unit/pipe/test_callback_func.cc b/tests/unit/pipe/test_callback_func.cc index 94f726851c..438a9f8e9b 100644 --- a/tests/unit/pipe/test_callback_func.cc +++ b/tests/unit/pipe/test_callback_func.cc @@ -88,14 +88,16 @@ TEST_F(TestCallbackFunc, test_callback_func_2) { called = 0; - if (this_node == 0) { - auto cb = theCB()->makeFunc([]{ called = 400; }); - auto msg = makeMessage(cb); - theMsg()->sendMsg(1, msg.get()); + runInEpochCollective([=] { + if (this_node == 0) { + auto cb = theCB()->makeFunc([] { called = 400; }); + auto msg = makeMessage(cb); + theMsg()->sendMsg(1, msg.get()); + } + }); - theTerm()->addAction([=]{ - EXPECT_EQ(called, 400); - }); + if (this_node == 0) { + EXPECT_EQ(called, 400); } } diff --git a/tests/unit/pipe/test_callback_func_ctx.cc b/tests/unit/pipe/test_callback_func_ctx.cc index 71e50b420b..c91a90c06c 100644 --- a/tests/unit/pipe/test_callback_func_ctx.cc +++ b/tests/unit/pipe/test_callback_func_ctx.cc @@ -115,28 +115,27 @@ TEST_F(TestCallbackFuncCtx, test_callback_func_ctx_2) { return; } - ctx = std::make_unique(); - ctx->val = this_node; - - auto next = this_node + 1 < num_nodes ? this_node + 1 : 0; - auto cb = theCB()->makeFunc( - ctx.get(), [next](DataMsg* msg, Context* my_ctx){ - called = 500; - EXPECT_EQ(my_ctx->val, theContext()->getNode()); - //fmt::print("{}: a={},b={},c={}\n",n,msg->a,msg->b,msg->c); - EXPECT_EQ(msg->a, next+1); - EXPECT_EQ(msg->b, next+2); - EXPECT_EQ(msg->c, next+3); - } - ); - //fmt::print("{}: next={}\n", this_node, next); - auto msg = makeMessage(cb); - theMsg()->sendMsg(next, msg.get()); - - theTerm()->addAction([=]{ - //fmt::print("{}: called={}\n", this_node, called); - EXPECT_EQ(called, 500); + runInEpochCollective([=] { + ctx = std::make_unique(); + ctx->val = this_node; + + auto next = this_node + 1 < num_nodes ? this_node + 1 : 0; + auto cb = theCB()->makeFunc( + ctx.get(), [next](DataMsg* msg, Context* my_ctx) { + called = 500; + EXPECT_EQ(my_ctx->val, theContext()->getNode()); + // fmt::print("{}: a={},b={},c={}\n",n,msg->a,msg->b,msg->c); + EXPECT_EQ(msg->a, next + 1); + EXPECT_EQ(msg->b, next + 2); + EXPECT_EQ(msg->c, next + 3); + }); + // fmt::print("{}: next={}\n", this_node, next); + auto msg = makeMessage(cb); + theMsg()->sendMsg(next, msg.get()); }); + + // fmt::print("{}: called={}\n", this_node, called); + EXPECT_EQ(called, 500); } }}} // end namespace vt::tests::unit diff --git a/tests/unit/pipe/test_callback_send.cc b/tests/unit/pipe/test_callback_send.cc index 605127e30d..e5798c19ca 100644 --- a/tests/unit/pipe/test_callback_send.cc +++ b/tests/unit/pipe/test_callback_send.cc @@ -114,36 +114,39 @@ TEST_F(TestCallbackSend, test_callback_send_1) { auto const& this_node = theContext()->getNode(); called = 0; - auto cb = theCB()->makeSend(this_node); - auto nmsg = makeMessage(1,2,3); - cb.send(nmsg.get()); - theTerm()->addAction([=]{ - EXPECT_EQ(called, 100); + runInEpochCollective([=] { + auto cb = theCB()->makeSend(this_node); + auto nmsg = makeMessage(1, 2, 3); + cb.send(nmsg.get()); }); + + EXPECT_EQ(called, 100); } TEST_F(TestCallbackSend, test_callback_send_2) { auto const& this_node = theContext()->getNode(); called = 0; - auto cb = theCB()->makeSend(this_node); - auto nmsg = makeMessage(1,2,3); - cb.send(nmsg.get()); - theTerm()->addAction([=]{ - EXPECT_EQ(called, 200); + runInEpochCollective([=] { + auto cb = theCB()->makeSend(this_node); + auto nmsg = makeMessage(1, 2, 3); + cb.send(nmsg.get()); }); + + EXPECT_EQ(called, 200); } TEST_F(TestCallbackSend, test_callback_send_3) { auto const& this_node = theContext()->getNode(); called = 0; - auto cb = theCB()->makeSend(this_node); - cb.send(); - theTerm()->addAction([=]{ - EXPECT_EQ(called, 300); + runInEpochCollective([=] { + auto cb = theCB()->makeSend(this_node); + cb.send(); }); + + EXPECT_EQ(called, 300); } TEST_F(TestCallbackSend, test_callback_send_remote_1) { @@ -151,14 +154,15 @@ TEST_F(TestCallbackSend, test_callback_send_remote_1) { auto const& num_nodes = theContext()->getNumNodes(); called = 0; - auto next = this_node + 1 < num_nodes ? this_node + 1 : 0; - auto cb = theCB()->makeSend(this_node); - auto msg = makeMessage(cb); - theMsg()->sendMsg(next, msg.get()); - theTerm()->addAction([=]{ - EXPECT_EQ(called, 100); + runInEpochCollective([=] { + auto next = this_node + 1 < num_nodes ? this_node + 1 : 0; + auto cb = theCB()->makeSend(this_node); + auto msg = makeMessage(cb); + theMsg()->sendMsg(next, msg.get()); }); + + EXPECT_EQ(called, 100); } TEST_F(TestCallbackSend, test_callback_send_remote_2) { @@ -166,14 +170,15 @@ TEST_F(TestCallbackSend, test_callback_send_remote_2) { auto const& num_nodes = theContext()->getNumNodes(); called = 0; - auto next = this_node + 1 < num_nodes ? this_node + 1 : 0; - auto cb = theCB()->makeSend(this_node); - auto msg = makeMessage(cb); - theMsg()->sendMsg(next, msg.get()); - theTerm()->addAction([=]{ - EXPECT_EQ(called, 200); + runInEpochCollective([=] { + auto next = this_node + 1 < num_nodes ? this_node + 1 : 0; + auto cb = theCB()->makeSend(this_node); + auto msg = makeMessage(cb); + theMsg()->sendMsg(next, msg.get()); }); + + EXPECT_EQ(called, 200); } TEST_F(TestCallbackSend, test_callback_send_remote_3) { @@ -181,14 +186,15 @@ TEST_F(TestCallbackSend, test_callback_send_remote_3) { auto const& num_nodes = theContext()->getNumNodes(); called = 0; - auto next = this_node + 1 < num_nodes ? this_node + 1 : 0; - auto cb = theCB()->makeSend(this_node); - auto msg = makeMessage(cb); - theMsg()->sendMsg(next, msg.get()); - theTerm()->addAction([=]{ - EXPECT_EQ(called, 300); + runInEpochCollective([=] { + auto next = this_node + 1 < num_nodes ? this_node + 1 : 0; + auto cb = theCB()->makeSend(this_node); + auto msg = makeMessage(cb); + theMsg()->sendMsg(next, msg.get()); }); + + EXPECT_EQ(called, 300); } diff --git a/tests/unit/pipe/test_callback_send_collection.extended.cc b/tests/unit/pipe/test_callback_send_collection.extended.cc index 7cdc66d9af..a9a02a9144 100644 --- a/tests/unit/pipe/test_callback_send_collection.extended.cc +++ b/tests/unit/pipe/test_callback_send_collection.extended.cc @@ -128,25 +128,29 @@ static void cb3(DataMsg* msg, TestCol* col) { TEST_F(TestCallbackSendCollection, test_callback_send_collection_1) { auto const& this_node = theContext()->getNode(); - if (this_node == 0) { - auto const& range = Index1D(32); - auto proxy = theCollection()->construct(range); - - for (auto i = 0; i < 32; i++) { - if (i % 2 == 0) { - auto cb = theCB()->makeSend(proxy(i)); - auto nmsg = makeMessage(8,9,10); - cb.send(nmsg.get()); - } else { - auto cb = theCB()->makeSend(proxy(i)); - auto nmsg = makeMessage(8,9,10); - cb.send(nmsg.get()); + runInEpochCollective([=] { + if (this_node == 0) { + auto const& range = Index1D(32); + auto proxy = theCollection()->construct(range); + + for (auto i = 0; i < 32; i++) { + if (i % 2 == 0) { + auto cb = + theCB()->makeSend(proxy(i)); + auto nmsg = makeMessage(8, 9, 10); + cb.send(nmsg.get()); + } else { + auto cb = + theCB()->makeSend(proxy(i)); + auto nmsg = makeMessage(8, 9, 10); + cb.send(nmsg.get()); + } } } + }); - theTerm()->addAction([=]{ - proxy.destroy(); - }); + if (this_node == 0) { + theCollection()->destroyCollections(); } } @@ -158,52 +162,58 @@ TEST_F(TestCallbackSendCollection, test_callback_send_collection_2) { return; } - if (this_node == 0) { - auto const& range = Index1D(32); - auto proxy = theCollection()->construct(range); - - for (auto i = 0; i < 32; i++) { - auto next = this_node + 1 < num_nodes ? this_node + 1 : 0; - if (i % 2 == 0) { - auto cb = theCB()->makeSend(proxy(i)); - auto msg = makeMessage(cb); - theMsg()->sendMsg(next, msg.get()); - } else { - auto cb = theCB()->makeSend(proxy(i)); - auto msg = makeMessage(cb); - theMsg()->sendMsg(next, msg.get()); + runInEpochCollective([=] { + if (this_node == 0) { + auto const& range = Index1D(32); + auto proxy = theCollection()->construct(range); + + for (auto i = 0; i < 32; i++) { + auto next = this_node + 1 < num_nodes ? this_node + 1 : 0; + if (i % 2 == 0) { + auto cb = + theCB()->makeSend(proxy(i)); + auto msg = makeMessage(cb); + theMsg()->sendMsg(next, msg.get()); + } else { + auto cb = + theCB()->makeSend(proxy(i)); + auto msg = makeMessage(cb); + theMsg()->sendMsg(next, msg.get()); + } } } + }); - theTerm()->addAction([=]{ - proxy.destroy(); - }); + if (this_node == 0) { + theCollection()->destroyCollections(); } - } TEST_F(TestCallbackSendCollection, test_callback_send_collection_3) { auto const& this_node = theContext()->getNode(); - if (this_node == 0) { - auto const& range = Index1D(32); - auto proxy = theCollection()->construct(range); - - for (auto i = 0; i < 32; i++) { - if (i % 2 == 0) { - auto cb = theCB()->makeSend(proxy(i)); - auto nmsg = makeMessage(8,9,10); - cb.send(nmsg.get()); - } else { - auto cb = theCB()->makeSend(proxy(i)); - auto nmsg = makeMessage(8,9,10); - cb.send(nmsg.get()); + runInEpochCollective([=] { + if (this_node == 0) { + auto const& range = Index1D(32); + auto proxy = theCollection()->construct(range); + + for (auto i = 0; i < 32; i++) { + if (i % 2 == 0) { + auto cb = + theCB()->makeSend(proxy(i)); + auto nmsg = makeMessage(8, 9, 10); + cb.send(nmsg.get()); + } else { + auto cb = theCB()->makeSend(proxy(i)); + auto nmsg = makeMessage(8, 9, 10); + cb.send(nmsg.get()); + } } } + }); - theTerm()->addAction([=]{ - proxy.destroy(); - }); + if (this_node == 0) { + theCollection()->destroyCollections(); } } diff --git a/tests/unit/rdma/test_rdma_collection_handle.extended.cc b/tests/unit/rdma/test_rdma_collection_handle.extended.cc index 9ccdd91ddd..91b72eb61a 100644 --- a/tests/unit/rdma/test_rdma_collection_handle.extended.cc +++ b/tests/unit/rdma/test_rdma_collection_handle.extended.cc @@ -202,21 +202,19 @@ TYPED_TEST_P(TestRDMAHandleCollection, test_rdma_handle_collection_1) { } ); - auto migrate_epoch = theTerm()->makeEpochCollective(); - if (theContext()->getNode() == 0) { - theTerm()->produce(migrate_epoch); - proxy.template broadcast< - typename TestCol::TestMsg, &TestCol::initialize - >(migrate_epoch); - theTerm()->addAction(migrate_epoch,[=]{ + runInEpochCollective([=] { + if (theContext()->getNode() == 0) { proxy.template broadcast< - typename TestCol::TestMsg, &TestCol::afterMigrate - >(); - }); - } - theTerm()->finishedEpoch(migrate_epoch); + typename TestCol::TestMsg, &TestCol::initialize>(); + } + }); - do vt::runScheduler(); while (not vt::rt->isTerminated()); + runInEpochCollective([=] { + if (theContext()->getNode() == 0) { + proxy.template broadcast< + typename TestCol::TestMsg, &TestCol::afterMigrate>(); + } + }); } using RDMACollectionTestTypes = testing::Types< diff --git a/tests/unit/sequencer/test_sequencer.extended.cc b/tests/unit/sequencer/test_sequencer.extended.cc index 38f669b805..ce24309acf 100644 --- a/tests/unit/sequencer/test_sequencer.extended.cc +++ b/tests/unit/sequencer/test_sequencer.extended.cc @@ -158,84 +158,88 @@ struct TestSequencer : TestParallelHarness { TEST_F(TestSequencer, test_single_wait) { auto const& my_node = theContext()->getNode(); - #if DEBUG_TEST_HARNESS_PRINT - fmt::print("test_seq_handler: node={}\n", my_node); - #endif +#if DEBUG_TEST_HARNESS_PRINT + fmt::print("test_seq_handler: node={}\n", my_node); +#endif + + runInEpochCollective([=] { + if (my_node == 1) { + auto msg = makeMessage(); + theMsg()->sendMsg(0, msg.get()); + } - if (my_node == 1) { - auto msg = makeMessage(); - theMsg()->sendMsg(0, msg.get()); - } + if (my_node == 0) { - if (my_node == 0) { - SeqType const& seq_id = theSeq()->nextSeq(); - theSeq()->sequenced(seq_id, testSingleWaitFn); + SeqType const& seq_id = theSeq()->nextSeq(); + theSeq()->sequenced(seq_id, testSingleWaitFn); + } + }); - theTerm()->addAction([=]{ - testSingleWaitFn(-1); - }); + if (my_node == 0) { + testSingleWaitFn(-1); } } TEST_F(TestSequencer, test_single_wait_tagged) { auto const& my_node = theContext()->getNode(); - if (my_node == 0) { - SeqType const& seq_id = theSeq()->nextSeq(); - theSeq()->sequenced(seq_id, testSingleTaggedWaitFn); + runInEpochCollective([=] { + if (my_node == 0) { + SeqType const& seq_id = theSeq()->nextSeq(); + theSeq()->sequenced(seq_id, testSingleTaggedWaitFn); + } else if (my_node == 1) { + auto msg = makeMessage(); + theMsg()->sendMsg( + 0, msg.get(), single_tag); + } + }); - theTerm()->addAction([=]{ - testSingleTaggedWaitFn(-1); - }); - } else if (my_node == 1) { - auto msg = makeMessage(); - theMsg()->sendMsg( - 0, msg.get(), single_tag - ); + if (my_node == 0) { + testSingleTaggedWaitFn(-1); } } TEST_F(TestSequencer, test_multi_wait) { auto const& my_node = theContext()->getNode(); - if (my_node == 0) { - SeqType const& seq_id = theSeq()->nextSeq(); - theSeq()->sequenced(seq_id, testMultiWaitFn); + runInEpochCollective([=] { + if (my_node == 0) { + SeqType const& seq_id = theSeq()->nextSeq(); + theSeq()->sequenced(seq_id, testMultiWaitFn); + } else if (my_node == 1) { + auto msg1 = makeMessage(); + theMsg()->sendMsg( + 0, msg1.get()); + auto msg2 = makeMessage(); + theMsg()->sendMsg( + 0, msg2.get()); + } + }); - theTerm()->addAction([=]{ - testMultiWaitFn(-1); - }); - } else if (my_node == 1) { - auto msg1 = makeMessage(); - theMsg()->sendMsg( - 0, msg1.get() - ); - auto msg2 = makeMessage(); - theMsg()->sendMsg( - 0, msg2.get() - ); + if (my_node == 0) { + testMultiWaitFn(-1); } } TEST_F(TestSequencer, test_multi_wait_tagged) { auto const& my_node = theContext()->getNode(); - if (my_node == 0) { - SeqType const& seq_id = theSeq()->nextSeq(); - theSeq()->sequenced(seq_id, testMultiTaggedWaitFn); + runInEpochCollective([=] { + if (my_node == 0) { + SeqType const& seq_id = theSeq()->nextSeq(); + theSeq()->sequenced(seq_id, testMultiTaggedWaitFn); + } else if (my_node == 1) { + auto msg1 = makeMessage(); + theMsg()->sendMsg( + 0, msg1.get(), single_tag); + auto msg2 = makeMessage(); + theMsg()->sendMsg( + 0, msg2.get(), single_tag_2); + } + }); - theTerm()->addAction([=]{ - testMultiTaggedWaitFn(-1); - }); - } else if (my_node == 1) { - auto msg1 = makeMessage(); - theMsg()->sendMsg( - 0, msg1.get(), single_tag - ); - auto msg2 = makeMessage(); - theMsg()->sendMsg( - 0, msg2.get(), single_tag_2 - ); + if (my_node == 0) { + testMultiTaggedWaitFn(-1); } } diff --git a/tests/unit/sequencer/test_sequencer_extensive.extended.cc b/tests/unit/sequencer/test_sequencer_extensive.extended.cc index 8b26d013a7..015072716d 100644 --- a/tests/unit/sequencer/test_sequencer_extensive.extended.cc +++ b/tests/unit/sequencer/test_sequencer_extensive.extended.cc @@ -98,31 +98,33 @@ static constexpr CountType const max_seq_depth = 8; CountType const& wait_post = std::get<2>(param); \ CountType const& seg_cnt = std::get<3>(param); \ CountType const& depth = std::get<4>(param); \ - if (node == (NODE)) { \ - SeqType const& seq_id = theSeq()->nextSeq(); \ - SEQ_FN(ResetAtomicValue); \ - theSeq()->sequenced(seq_id, (SEQ_FN)); \ - theTerm()->addAction([=]{ \ - SEQ_FN(FinalizeAtomicValue); \ - }); \ - } else if (node == 1) { \ - CountType in[param_size] = { \ - wait_cnt, wait_pre, wait_post, seg_cnt, depth \ - }; \ - auto msg = makeMessage(in); \ - theMsg()->sendMsg( \ - (NODE), msg.get() \ - ); \ - auto const total = (wait_cnt * seg_cnt) + wait_pre + wait_post; \ - for (CountType i = 0; i < total; i++) { \ - TagType const tag = (IS_TAG) ? i+1 : no_tag; \ - auto nmsg = makeMessage(); \ - theMsg()->sendMsg( \ - (NODE), nmsg.get(), tag \ + runInEpochCollective([=]{ \ + if (node == (NODE)) { \ + SeqType const& seq_id = theSeq()->nextSeq(); \ + SEQ_FN(ResetAtomicValue); \ + theSeq()->sequenced(seq_id, (SEQ_FN)); \ + } else if (node == 1) { \ + CountType in[param_size] = { \ + wait_cnt, wait_pre, wait_post, seg_cnt, depth \ + }; \ + auto msg = makeMessage(in); \ + theMsg()->sendMsg( \ + (NODE), msg.get() \ ); \ + auto const total = (wait_cnt * seg_cnt) + wait_pre + wait_post; \ + for (CountType i = 0; i < total; i++) { \ + TagType const tag = (IS_TAG) ? i+1 : no_tag; \ + auto nmsg = makeMessage(); \ + theMsg()->sendMsg( \ + (NODE), nmsg.get(), tag \ + ); \ + } \ } \ + }); \ + if (node == (NODE)) { \ + SEQ_FN(FinalizeAtomicValue); \ } \ - } while (false); + } while (false); \ #define FN_APPLY(SEQ_HAN, SEQ_FN, NODE, MSG_TYPE, ___, IS_TAG) \ static void SEQ_FN(SeqType const& seq_id) { \ diff --git a/tests/unit/sequencer/test_sequencer_for.extended.cc b/tests/unit/sequencer/test_sequencer_for.extended.cc index d3360034fa..7dd75410f4 100644 --- a/tests/unit/sequencer/test_sequencer_for.extended.cc +++ b/tests/unit/sequencer/test_sequencer_for.extended.cc @@ -99,21 +99,21 @@ TEST_F(TestSequencerFor, test_for) { SeqType const& seq_id = theSeq()->nextSeq(); - if (my_node == 0) { - theSeq()->sequenced(seq_id, testSeqForFn); - } + runInEpochCollective([=] { + if (my_node == 0) { + theSeq()->sequenced(seq_id, testSeqForFn); + } - for (int i = 0; i < end_range; i++) { - if (my_node == 1) { - auto msg = makeMessage(); - theMsg()->sendMsg(0, msg.get()); + for (int i = 0; i < end_range; i++) { + if (my_node == 1) { + auto msg = makeMessage(); + theMsg()->sendMsg(0, msg.get()); + } } - } + }); if (my_node == 0) { - theTerm()->addAction([=]{ - testSeqForFn(-1); - }); + testSeqForFn(-1); } } diff --git a/tests/unit/sequencer/test_sequencer_nested.extended.cc b/tests/unit/sequencer/test_sequencer_nested.extended.cc index 1402603096..0313a37506 100644 --- a/tests/unit/sequencer/test_sequencer_nested.extended.cc +++ b/tests/unit/sequencer/test_sequencer_nested.extended.cc @@ -264,22 +264,23 @@ struct TestSequencerNested : TestParallelHarness { #define SEQ_EXPAND(SEQ_HAN, SEQ_FN, NODE, MSG_TYPE, NUM_MSGS, IS_TAG) \ do { \ SeqType const& seq_id = theSeq()->nextSeq(); \ - if ((NODE) == 0) { \ - theSeq()->sequenced(seq_id, (SEQ_FN)); \ - } \ - for (int i = 0; i < (NUM_MSGS); i++) { \ - TagType const tag = (IS_TAG) ? i+1 : no_tag; \ - if ((NODE) == 1) { \ - auto msg = makeMessage(); \ - theMsg()->sendMsg( \ - 0, msg.get(), tag \ - ); \ + \ + runInEpochCollective([=]{ \ + if ((NODE) == 0) { \ + theSeq()->sequenced(seq_id, (SEQ_FN)); \ } \ - } \ + for (int i = 0; i < (NUM_MSGS); i++) { \ + TagType const tag = (IS_TAG) ? i+1 : no_tag; \ + if ((NODE) == 1) { \ + auto msg = makeMessage(); \ + theMsg()->sendMsg( \ + 0, msg.get(), tag \ + ); \ + } \ + } \ + }); \ if ((NODE) == 0) { \ - theTerm()->addAction([=]{ \ SEQ_FN(-1); \ - }); \ } \ } while (false); diff --git a/tests/unit/sequencer/test_sequencer_parallel.extended.cc b/tests/unit/sequencer/test_sequencer_parallel.extended.cc index 9669ad9630..1f69382324 100644 --- a/tests/unit/sequencer/test_sequencer_parallel.extended.cc +++ b/tests/unit/sequencer/test_sequencer_parallel.extended.cc @@ -149,24 +149,23 @@ TEST_P(TestSequencerParallelParam, test_seq_parallel_param) { SeqType const& seq_id = theSeq()->nextSeq(); auto seq_par_cnt_fn = std::bind(seqParFnN, _1, par_count); - if (node == 0) { - seq_par_cnt_fn(SeqParResetAtomicValue); - theSeq()->sequenced(seq_id, seq_par_cnt_fn); - } + runInEpochCollective([=] { + if (node == 0) { + seq_par_cnt_fn(SeqParResetAtomicValue); + theSeq()->sequenced(seq_id, seq_par_cnt_fn); + } - for (CountType i = 0; i < par_count; i++) { - if (node == 1) { - auto msg = makeMessage(); - theMsg()->sendMsg(0, msg.get()); + for (CountType i = 0; i < par_count; i++) { + if (node == 1) { + auto msg = makeMessage(); + theMsg()->sendMsg(0, msg.get()); + } } - } + }); if (node == 0) { - theTerm()->addAction([=]{ - seq_par_cnt_fn(SeqParFinalizeAtomicValue); - }); + seq_par_cnt_fn(SeqParFinalizeAtomicValue); } - } INSTANTIATE_TEST_SUITE_P( @@ -317,22 +316,22 @@ struct TestSequencerParallel : TestParallelHarness { #define PAR_EXPAND(SEQ_HAN, SEQ_FN, NODE, MSG_TYPE, NUM_MSGS, IS_TAG) \ do { \ SeqType const& seq_id = theSeq()->nextSeq(); \ - if ((NODE) == 0) { \ - theSeq()->sequenced(seq_id, (SEQ_FN)); \ - } \ - for (int i = 0; i < (NUM_MSGS); i++) { \ - TagType const tag = (IS_TAG) ? i+1 : no_tag; \ - if ((NODE) == 1) { \ - auto msg = makeMessage(); \ - theMsg()->sendMsg( \ - 0, msg.get(), tag \ - ); \ + runInEpochCollective([=]{ \ + if ((NODE) == 0) { \ + theSeq()->sequenced(seq_id, (SEQ_FN)); \ } \ - } \ + for (int i = 0; i < (NUM_MSGS); i++) { \ + TagType const tag = (IS_TAG) ? i+1 : no_tag; \ + if ((NODE) == 1) { \ + auto msg = makeMessage(); \ + theMsg()->sendMsg( \ + 0, msg.get(), tag \ + ); \ + } \ + } \ + }); \ if ((NODE) == 0) { \ - theTerm()->addAction([=]{ \ SEQ_FN(-1); \ - }); \ } \ } while (false); diff --git a/tests/unit/sequencer/test_sequencer_vrt.extended.cc b/tests/unit/sequencer/test_sequencer_vrt.extended.cc index 8237080bc3..8627fbe468 100644 --- a/tests/unit/sequencer/test_sequencer_vrt.extended.cc +++ b/tests/unit/sequencer/test_sequencer_vrt.extended.cc @@ -182,85 +182,84 @@ struct TestSequencerVirtual : TestParallelHarness { TEST_F(TestSequencerVirtual, test_seq_vc_1) { auto const& my_node = theContext()->getNode(); - if (my_node == 0) { - auto proxy = theVirtualManager()->makeVirtual(29); - SeqType const& seq_id = theVirtualSeq()->createVirtualSeq(proxy); - auto vrt_ptr = theVirtualManager()->getVirtualByProxy(proxy); + runInEpochCollective([=] { + if (my_node == 0) { + auto proxy = theVirtualManager()->makeVirtual(29); + SeqType const& seq_id = theVirtualSeq()->createVirtualSeq(proxy); + auto vrt_ptr = theVirtualManager()->getVirtualByProxy(proxy); - test_vrt_ptr = static_cast(vrt_ptr); - //fmt::print("vrt ptr={}\n", test_vrt_ptr); + test_vrt_ptr = static_cast(vrt_ptr); + // fmt::print("vrt ptr={}\n", test_vrt_ptr); - theVirtualSeq()->sequenced(seq_id, testSeqFn1); + theVirtualSeq()->sequenced(seq_id, testSeqFn1); - auto msg = makeMessage(); - theVirtualManager()->sendMsg( - proxy, msg.get() - ); + auto msg = makeMessage(); + theVirtualManager()->sendMsg( + proxy, msg.get()); + } + }); - theTerm()->addAction([=]{ - testSeqFn1(FinalizeAtomicValue); - }); + if (my_node == 0) { + testSeqFn1(FinalizeAtomicValue); } } TEST_F(TestSequencerVirtual, test_seq_vc_2) { auto const& my_node = theContext()->getNode(); - if (my_node == 0) { - auto proxy = theVirtualManager()->makeVirtual(85); - SeqType const& seq_id = theVirtualSeq()->createVirtualSeq(proxy); - auto vrt_ptr = theVirtualManager()->getVirtualByProxy(proxy); + runInEpochCollective([=] { + if (my_node == 0) { + auto proxy = theVirtualManager()->makeVirtual(85); + SeqType const& seq_id = theVirtualSeq()->createVirtualSeq(proxy); + auto vrt_ptr = theVirtualManager()->getVirtualByProxy(proxy); - test_vrt_ptr = static_cast(vrt_ptr); + test_vrt_ptr = static_cast(vrt_ptr); - theVirtualSeq()->sequenced(seq_id, testSeqFn2); + theVirtualSeq()->sequenced(seq_id, testSeqFn2); - for (int i = 0; i < 2; i++) { - auto msg = makeMessage(); - theVirtualManager()->sendMsg( - proxy, msg.get() - ); + for (int i = 0; i < 2; i++) { + auto msg = makeMessage(); + theVirtualManager()->sendMsg( + proxy, msg.get()); + } } + }); - theTerm()->addAction([=]{ - testSeqFn2(FinalizeAtomicValue); - }); + if (my_node == 0) { + testSeqFn2(FinalizeAtomicValue); } } TEST_F(TestSequencerVirtual, test_seq_vc_distinct_inst_3) { auto const& my_node = theContext()->getNode(); + runInEpochCollective([=] { + if (my_node == 0) { + auto proxy_a = theVirtualManager()->makeVirtual(85); + SeqType const& seq_id_a = theVirtualSeq()->createVirtualSeq(proxy_a); + auto vrt_ptr_a = theVirtualManager()->getVirtualByProxy(proxy_a); + test_vrt_ptr_a = static_cast(vrt_ptr_a); + + auto proxy_b = theVirtualManager()->makeVirtual(23); + SeqType const& seq_id_b = theVirtualSeq()->createVirtualSeq(proxy_b); + auto vrt_ptr_b = theVirtualManager()->getVirtualByProxy(proxy_b); + test_vrt_ptr_b = static_cast(vrt_ptr_b); + + theVirtualSeq()->sequenced(seq_id_a, testSeqFn3a); + theVirtualSeq()->sequenced(seq_id_b, testSeqFn3b); + + auto msg1 = makeMessage(); + theVirtualManager()->sendMsg( + proxy_a, msg1.get()); + auto msg2 = makeMessage(); + theVirtualManager()->sendMsg( + proxy_b, msg2.get()); + } + }); + if (my_node == 0) { - auto proxy_a = theVirtualManager()->makeVirtual(85); - SeqType const& seq_id_a = theVirtualSeq()->createVirtualSeq(proxy_a); - auto vrt_ptr_a = theVirtualManager()->getVirtualByProxy(proxy_a); - test_vrt_ptr_a = static_cast(vrt_ptr_a); - - auto proxy_b = theVirtualManager()->makeVirtual(23); - SeqType const& seq_id_b = theVirtualSeq()->createVirtualSeq(proxy_b); - auto vrt_ptr_b = theVirtualManager()->getVirtualByProxy(proxy_b); - test_vrt_ptr_b = static_cast(vrt_ptr_b); - - theVirtualSeq()->sequenced(seq_id_a, testSeqFn3a); - theVirtualSeq()->sequenced(seq_id_b, testSeqFn3b); - - auto msg1 = makeMessage(); - theVirtualManager()->sendMsg( - proxy_a, msg1.get() - ); - auto msg2 = makeMessage(); - theVirtualManager()->sendMsg( - proxy_b, msg2.get() - ); - - // @todo: fix this it is getting triggered early (a termination detector - // bug?) - theTerm()->addAction([=]{ - // testSeqFn3a(FinalizeAtomicValue); - // testSeqFn3b(FinalizeAtomicValue); - }); + testSeqFn3a(FinalizeAtomicValue); + testSeqFn3b(FinalizeAtomicValue); } } - }}} // end namespace vt::tests::unit From 9e9b3b12b2a8e75d52b0ec718e96e37588a8a009 Mon Sep 17 00:00:00 2001 From: Jakub Domagala Date: Mon, 17 Aug 2020 10:52:55 +0200 Subject: [PATCH 2/4] #955 Change to explicit lambda capture in 'runInEpochCollective' when applicable and fix lambda formatting --- tests/unit/pipe/test_callback_func.cc | 4 ++-- tests/unit/pipe/test_callback_func_ctx.cc | 2 +- tests/unit/pipe/test_callback_send.cc | 12 ++++++------ .../pipe/test_callback_send_collection.extended.cc | 6 +++--- .../rdma/test_rdma_collection_handle.extended.cc | 4 ++-- tests/unit/sequencer/test_sequencer.extended.cc | 8 ++++---- tests/unit/sequencer/test_sequencer_for.extended.cc | 2 +- .../sequencer/test_sequencer_parallel.extended.cc | 2 +- tests/unit/sequencer/test_sequencer_vrt.extended.cc | 6 +++--- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/tests/unit/pipe/test_callback_func.cc b/tests/unit/pipe/test_callback_func.cc index 438a9f8e9b..4b1a91d7bf 100644 --- a/tests/unit/pipe/test_callback_func.cc +++ b/tests/unit/pipe/test_callback_func.cc @@ -88,9 +88,9 @@ TEST_F(TestCallbackFunc, test_callback_func_2) { called = 0; - runInEpochCollective([=] { + runInEpochCollective([this_node]{ if (this_node == 0) { - auto cb = theCB()->makeFunc([] { called = 400; }); + auto cb = theCB()->makeFunc([]{ called = 400; }); auto msg = makeMessage(cb); theMsg()->sendMsg(1, msg.get()); } diff --git a/tests/unit/pipe/test_callback_func_ctx.cc b/tests/unit/pipe/test_callback_func_ctx.cc index c91a90c06c..b2821ba3b6 100644 --- a/tests/unit/pipe/test_callback_func_ctx.cc +++ b/tests/unit/pipe/test_callback_func_ctx.cc @@ -115,7 +115,7 @@ TEST_F(TestCallbackFuncCtx, test_callback_func_ctx_2) { return; } - runInEpochCollective([=] { + runInEpochCollective([this_node, num_nodes]{ ctx = std::make_unique(); ctx->val = this_node; diff --git a/tests/unit/pipe/test_callback_send.cc b/tests/unit/pipe/test_callback_send.cc index e5798c19ca..67dd567f98 100644 --- a/tests/unit/pipe/test_callback_send.cc +++ b/tests/unit/pipe/test_callback_send.cc @@ -115,7 +115,7 @@ TEST_F(TestCallbackSend, test_callback_send_1) { called = 0; - runInEpochCollective([=] { + runInEpochCollective([this_node]{ auto cb = theCB()->makeSend(this_node); auto nmsg = makeMessage(1, 2, 3); cb.send(nmsg.get()); @@ -128,7 +128,7 @@ TEST_F(TestCallbackSend, test_callback_send_2) { auto const& this_node = theContext()->getNode(); called = 0; - runInEpochCollective([=] { + runInEpochCollective([this_node]{ auto cb = theCB()->makeSend(this_node); auto nmsg = makeMessage(1, 2, 3); cb.send(nmsg.get()); @@ -141,7 +141,7 @@ TEST_F(TestCallbackSend, test_callback_send_3) { auto const& this_node = theContext()->getNode(); called = 0; - runInEpochCollective([=] { + runInEpochCollective([this_node]{ auto cb = theCB()->makeSend(this_node); cb.send(); }); @@ -155,7 +155,7 @@ TEST_F(TestCallbackSend, test_callback_send_remote_1) { called = 0; - runInEpochCollective([=] { + runInEpochCollective([this_node, num_nodes]{ auto next = this_node + 1 < num_nodes ? this_node + 1 : 0; auto cb = theCB()->makeSend(this_node); auto msg = makeMessage(cb); @@ -171,7 +171,7 @@ TEST_F(TestCallbackSend, test_callback_send_remote_2) { called = 0; - runInEpochCollective([=] { + runInEpochCollective([this_node, num_nodes]{ auto next = this_node + 1 < num_nodes ? this_node + 1 : 0; auto cb = theCB()->makeSend(this_node); auto msg = makeMessage(cb); @@ -187,7 +187,7 @@ TEST_F(TestCallbackSend, test_callback_send_remote_3) { called = 0; - runInEpochCollective([=] { + runInEpochCollective([this_node, num_nodes]{ auto next = this_node + 1 < num_nodes ? this_node + 1 : 0; auto cb = theCB()->makeSend(this_node); auto msg = makeMessage(cb); diff --git a/tests/unit/pipe/test_callback_send_collection.extended.cc b/tests/unit/pipe/test_callback_send_collection.extended.cc index a9a02a9144..0f613b1e75 100644 --- a/tests/unit/pipe/test_callback_send_collection.extended.cc +++ b/tests/unit/pipe/test_callback_send_collection.extended.cc @@ -128,7 +128,7 @@ static void cb3(DataMsg* msg, TestCol* col) { TEST_F(TestCallbackSendCollection, test_callback_send_collection_1) { auto const& this_node = theContext()->getNode(); - runInEpochCollective([=] { + runInEpochCollective([this_node]{ if (this_node == 0) { auto const& range = Index1D(32); auto proxy = theCollection()->construct(range); @@ -162,7 +162,7 @@ TEST_F(TestCallbackSendCollection, test_callback_send_collection_2) { return; } - runInEpochCollective([=] { + runInEpochCollective([this_node, num_nodes]{ if (this_node == 0) { auto const& range = Index1D(32); auto proxy = theCollection()->construct(range); @@ -192,7 +192,7 @@ TEST_F(TestCallbackSendCollection, test_callback_send_collection_2) { TEST_F(TestCallbackSendCollection, test_callback_send_collection_3) { auto const& this_node = theContext()->getNode(); - runInEpochCollective([=] { + runInEpochCollective([this_node]{ if (this_node == 0) { auto const& range = Index1D(32); auto proxy = theCollection()->construct(range); diff --git a/tests/unit/rdma/test_rdma_collection_handle.extended.cc b/tests/unit/rdma/test_rdma_collection_handle.extended.cc index 91b72eb61a..ba9e2ca068 100644 --- a/tests/unit/rdma/test_rdma_collection_handle.extended.cc +++ b/tests/unit/rdma/test_rdma_collection_handle.extended.cc @@ -202,14 +202,14 @@ TYPED_TEST_P(TestRDMAHandleCollection, test_rdma_handle_collection_1) { } ); - runInEpochCollective([=] { + runInEpochCollective([proxy]{ if (theContext()->getNode() == 0) { proxy.template broadcast< typename TestCol::TestMsg, &TestCol::initialize>(); } }); - runInEpochCollective([=] { + runInEpochCollective([proxy]{ if (theContext()->getNode() == 0) { proxy.template broadcast< typename TestCol::TestMsg, &TestCol::afterMigrate>(); diff --git a/tests/unit/sequencer/test_sequencer.extended.cc b/tests/unit/sequencer/test_sequencer.extended.cc index ce24309acf..7644882af9 100644 --- a/tests/unit/sequencer/test_sequencer.extended.cc +++ b/tests/unit/sequencer/test_sequencer.extended.cc @@ -162,7 +162,7 @@ TEST_F(TestSequencer, test_single_wait) { fmt::print("test_seq_handler: node={}\n", my_node); #endif - runInEpochCollective([=] { + runInEpochCollective([my_node]{ if (my_node == 1) { auto msg = makeMessage(); theMsg()->sendMsg(0, msg.get()); @@ -183,7 +183,7 @@ TEST_F(TestSequencer, test_single_wait) { TEST_F(TestSequencer, test_single_wait_tagged) { auto const& my_node = theContext()->getNode(); - runInEpochCollective([=] { + runInEpochCollective([my_node]{ if (my_node == 0) { SeqType const& seq_id = theSeq()->nextSeq(); theSeq()->sequenced(seq_id, testSingleTaggedWaitFn); @@ -202,7 +202,7 @@ TEST_F(TestSequencer, test_single_wait_tagged) { TEST_F(TestSequencer, test_multi_wait) { auto const& my_node = theContext()->getNode(); - runInEpochCollective([=] { + runInEpochCollective([my_node]{ if (my_node == 0) { SeqType const& seq_id = theSeq()->nextSeq(); theSeq()->sequenced(seq_id, testMultiWaitFn); @@ -224,7 +224,7 @@ TEST_F(TestSequencer, test_multi_wait) { TEST_F(TestSequencer, test_multi_wait_tagged) { auto const& my_node = theContext()->getNode(); - runInEpochCollective([=] { + runInEpochCollective([my_node]{ if (my_node == 0) { SeqType const& seq_id = theSeq()->nextSeq(); theSeq()->sequenced(seq_id, testMultiTaggedWaitFn); diff --git a/tests/unit/sequencer/test_sequencer_for.extended.cc b/tests/unit/sequencer/test_sequencer_for.extended.cc index 7dd75410f4..8b50f25ab6 100644 --- a/tests/unit/sequencer/test_sequencer_for.extended.cc +++ b/tests/unit/sequencer/test_sequencer_for.extended.cc @@ -99,7 +99,7 @@ TEST_F(TestSequencerFor, test_for) { SeqType const& seq_id = theSeq()->nextSeq(); - runInEpochCollective([=] { + runInEpochCollective([seq_id, my_node]{ if (my_node == 0) { theSeq()->sequenced(seq_id, testSeqForFn); } diff --git a/tests/unit/sequencer/test_sequencer_parallel.extended.cc b/tests/unit/sequencer/test_sequencer_parallel.extended.cc index 1f69382324..a744206aca 100644 --- a/tests/unit/sequencer/test_sequencer_parallel.extended.cc +++ b/tests/unit/sequencer/test_sequencer_parallel.extended.cc @@ -149,7 +149,7 @@ TEST_P(TestSequencerParallelParam, test_seq_parallel_param) { SeqType const& seq_id = theSeq()->nextSeq(); auto seq_par_cnt_fn = std::bind(seqParFnN, _1, par_count); - runInEpochCollective([=] { + runInEpochCollective([=]{ if (node == 0) { seq_par_cnt_fn(SeqParResetAtomicValue); theSeq()->sequenced(seq_id, seq_par_cnt_fn); diff --git a/tests/unit/sequencer/test_sequencer_vrt.extended.cc b/tests/unit/sequencer/test_sequencer_vrt.extended.cc index 8627fbe468..64f5fbfa0c 100644 --- a/tests/unit/sequencer/test_sequencer_vrt.extended.cc +++ b/tests/unit/sequencer/test_sequencer_vrt.extended.cc @@ -182,7 +182,7 @@ struct TestSequencerVirtual : TestParallelHarness { TEST_F(TestSequencerVirtual, test_seq_vc_1) { auto const& my_node = theContext()->getNode(); - runInEpochCollective([=] { + runInEpochCollective([my_node]{ if (my_node == 0) { auto proxy = theVirtualManager()->makeVirtual(29); SeqType const& seq_id = theVirtualSeq()->createVirtualSeq(proxy); @@ -207,7 +207,7 @@ TEST_F(TestSequencerVirtual, test_seq_vc_1) { TEST_F(TestSequencerVirtual, test_seq_vc_2) { auto const& my_node = theContext()->getNode(); - runInEpochCollective([=] { + runInEpochCollective([my_node]{ if (my_node == 0) { auto proxy = theVirtualManager()->makeVirtual(85); SeqType const& seq_id = theVirtualSeq()->createVirtualSeq(proxy); @@ -233,7 +233,7 @@ TEST_F(TestSequencerVirtual, test_seq_vc_2) { TEST_F(TestSequencerVirtual, test_seq_vc_distinct_inst_3) { auto const& my_node = theContext()->getNode(); - runInEpochCollective([=] { + runInEpochCollective([my_node]{ if (my_node == 0) { auto proxy_a = theVirtualManager()->makeVirtual(85); SeqType const& seq_id_a = theVirtualSeq()->createVirtualSeq(proxy_a); From 3441de5baa7000737ae21ce14acc959ac75be536 Mon Sep 17 00:00:00 2001 From: Jakub Domagala Date: Mon, 17 Aug 2020 19:16:15 +0200 Subject: [PATCH 3/4] #955 Use subsequent runInEpochCollective call to check result of TestCallbackSendCollection instead of checking them during Collection destruction --- .../test_callback_send_collection.extended.cc | 67 ++++++++++++------- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/tests/unit/pipe/test_callback_send_collection.extended.cc b/tests/unit/pipe/test_callback_send_collection.extended.cc index 0f613b1e75..fdda6e9c0e 100644 --- a/tests/unit/pipe/test_callback_send_collection.extended.cc +++ b/tests/unit/pipe/test_callback_send_collection.extended.cc @@ -88,11 +88,9 @@ struct TestCallbackSendCollection : TestParallelHarness { struct TestCol : vt::Collection { TestCol() = default; + virtual ~TestCol() = default; - virtual ~TestCol() { - // fmt::print( - // "{}: destroying {}\n", theContext()->getNode(), this->getIndex() - // ); + void check(DataMsg* msg) { if (this->getIndex().x() % 2 == 0) { EXPECT_EQ(val, 29); } else { @@ -127,12 +125,11 @@ static void cb3(DataMsg* msg, TestCol* col) { TEST_F(TestCallbackSendCollection, test_callback_send_collection_1) { auto const& this_node = theContext()->getNode(); + auto const& range = Index1D(32); + auto proxy = theCollection()->construct(range); - runInEpochCollective([this_node]{ + runInEpochCollective([this_node, proxy]{ if (this_node == 0) { - auto const& range = Index1D(32); - auto proxy = theCollection()->construct(range); - for (auto i = 0; i < 32; i++) { if (i % 2 == 0) { auto cb = @@ -149,9 +146,16 @@ TEST_F(TestCallbackSendCollection, test_callback_send_collection_1) { } }); - if (this_node == 0) { - theCollection()->destroyCollections(); - } + runInEpochCollective([this_node, proxy] { + if (this_node == 0) { + for (auto i = 0; i < 32; i++) { + auto cb = + theCB()->makeSend(proxy(i)); + auto nmsg = makeMessage(); + cb.send(nmsg.get()); + } + } + }); } TEST_F(TestCallbackSendCollection, test_callback_send_collection_2) { @@ -162,11 +166,11 @@ TEST_F(TestCallbackSendCollection, test_callback_send_collection_2) { return; } - runInEpochCollective([this_node, num_nodes]{ - if (this_node == 0) { - auto const& range = Index1D(32); - auto proxy = theCollection()->construct(range); + auto const& range = Index1D(32); + auto proxy = theCollection()->construct(range); + runInEpochCollective([this_node, num_nodes, proxy]{ + if (this_node == 0) { for (auto i = 0; i < 32; i++) { auto next = this_node + 1 < num_nodes ? this_node + 1 : 0; if (i % 2 == 0) { @@ -184,19 +188,25 @@ TEST_F(TestCallbackSendCollection, test_callback_send_collection_2) { } }); - if (this_node == 0) { - theCollection()->destroyCollections(); - } + runInEpochCollective([this_node, proxy]{ + if (this_node == 0) { + for (auto i = 0; i < 32; i++) { + auto cb = + theCB()->makeSend(proxy(i)); + auto nmsg = makeMessage(); + cb.send(nmsg.get()); + } + } + }); } TEST_F(TestCallbackSendCollection, test_callback_send_collection_3) { auto const& this_node = theContext()->getNode(); + auto const& range = Index1D(32); + auto proxy = theCollection()->construct(range); - runInEpochCollective([this_node]{ + runInEpochCollective([this_node, proxy]{ if (this_node == 0) { - auto const& range = Index1D(32); - auto proxy = theCollection()->construct(range); - for (auto i = 0; i < 32; i++) { if (i % 2 == 0) { auto cb = @@ -212,9 +222,16 @@ TEST_F(TestCallbackSendCollection, test_callback_send_collection_3) { } }); - if (this_node == 0) { - theCollection()->destroyCollections(); - } + runInEpochCollective([this_node, proxy]{ + if (this_node == 0) { + for (auto i = 0; i < 32; i++) { + auto cb = + theCB()->makeSend(proxy(i)); + auto nmsg = makeMessage(); + cb.send(nmsg.get()); + } + } + }); } From fa708547ecef63be9ed60164a75259efa1cd730e Mon Sep 17 00:00:00 2001 From: Jakub Domagala Date: Tue, 18 Aug 2020 16:32:49 +0200 Subject: [PATCH 4/4] #955 Use collection broadcast message instead of sending callbacks for checking TestCallbackSendCollection test results --- .../test_callback_send_collection.extended.cc | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/tests/unit/pipe/test_callback_send_collection.extended.cc b/tests/unit/pipe/test_callback_send_collection.extended.cc index fdda6e9c0e..e6873aa1ea 100644 --- a/tests/unit/pipe/test_callback_send_collection.extended.cc +++ b/tests/unit/pipe/test_callback_send_collection.extended.cc @@ -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) { } @@ -90,7 +92,7 @@ struct TestCol : vt::Collection { TestCol() = default; virtual ~TestCol() = default; - void check(DataMsg* msg) { + void check(TestColMsg* msg) { if (this->getIndex().x() % 2 == 0) { EXPECT_EQ(val, 29); } else { @@ -123,6 +125,8 @@ static void cb3(DataMsg* msg, TestCol* col) { col->val = 13; } +struct TestColMsg : ::vt::CollectionMessage {}; + TEST_F(TestCallbackSendCollection, test_callback_send_collection_1) { auto const& this_node = theContext()->getNode(); auto const& range = Index1D(32); @@ -146,14 +150,10 @@ TEST_F(TestCallbackSendCollection, test_callback_send_collection_1) { } }); - runInEpochCollective([this_node, proxy] { + runInEpochCollective([this_node, proxy]{ if (this_node == 0) { - for (auto i = 0; i < 32; i++) { - auto cb = - theCB()->makeSend(proxy(i)); - auto nmsg = makeMessage(); - cb.send(nmsg.get()); - } + auto msg = makeMessage(); + proxy.broadcast(msg.get()); } }); } @@ -190,12 +190,8 @@ TEST_F(TestCallbackSendCollection, test_callback_send_collection_2) { runInEpochCollective([this_node, proxy]{ if (this_node == 0) { - for (auto i = 0; i < 32; i++) { - auto cb = - theCB()->makeSend(proxy(i)); - auto nmsg = makeMessage(); - cb.send(nmsg.get()); - } + auto msg = makeMessage(); + proxy.broadcast(msg.get()); } }); } @@ -224,12 +220,8 @@ TEST_F(TestCallbackSendCollection, test_callback_send_collection_3) { runInEpochCollective([this_node, proxy]{ if (this_node == 0) { - for (auto i = 0; i < 32; i++) { - auto cb = - theCB()->makeSend(proxy(i)); - auto nmsg = makeMessage(); - cb.send(nmsg.get()); - } + auto msg = makeMessage(); + proxy.broadcast(msg.get()); } }); }