Skip to content

Commit

Permalink
#1930: tests: improve tests, align with develop
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander committed Dec 7, 2022
1 parent 7ccfb7a commit b58f7de
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 43 deletions.
22 changes: 8 additions & 14 deletions tests/perf/make_runnable_micro.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//@HEADER
// *****************************************************************************
//
// reduce.cc
// make_runnable_micro.cc
// DARMA/vt => Virtual Transport
//
// Copyright 2019-2021 National Technology & Engineering Solutions of Sandia, LLC
Expand Down Expand Up @@ -40,6 +40,7 @@
// *****************************************************************************
//@HEADER
*/

#include "common/test_harness.h"
#include <vt/collective/collective_ops.h>
#include <vt/objgroup/manager.h>
Expand Down Expand Up @@ -68,35 +69,28 @@ struct NodeObj {
proxy_ = global_proxy = vt::theObjGroup()->getProxy<NodeObj>(this);
}

void complete() {
}

void perfMakeRunnable(MyMsg* in_msg) {
for (int i = 0; i < num_iters; i++) {
msgs.emplace_back(makeMessage<MyMsg>());
}

han = auto_registry::makeAutoHandler<MyMsg, &dummyHandler>();

theTerm()->any_epoch_state_.incrementDependency();
theTerm()->disableTD();

test_obj_->StartTimer(fmt::format("makeRunnable {}", num_iters));
perfRunBenchmark();
test_obj_->StopTimer(fmt::format("makeRunnable {}", num_iters));

theTerm()->any_epoch_state_.decrementDependency();
theTerm()->enableTD();
}

void perfRunBenchmark() {
for (int i = 0; i < num_iters; i++) {
{
bool add_context = true;
auto r = runnable::makeRunnable(msgs[i], false, han, 0, add_context)
.withContinuation(nullptr)
.withTag(TagType{0})
.withTDEpochFromMsg(false);
r.enqueue();
}
auto r = runnable::makeRunnable(msgs[i], false, han, 0)
.withContinuation(nullptr)
.withTDEpochFromMsg(false);
r.enqueue();
vt::theSched()->runSchedulerOnceImpl();
}
}
Expand Down
5 changes: 2 additions & 3 deletions tests/perf/ping_pong.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ struct NodeObj {
template <>
void NodeObj::finishedPing<max_bytes>(FinishedPingMsg<max_bytes>* msg) {
addPerfStats(max_bytes);

theTerm()->any_epoch_state_.decrementDependency();
theTerm()->enableTD();
}

VT_PERF_TEST(MyTest, test_ping_pong) {
Expand All @@ -151,7 +150,7 @@ VT_PERF_TEST(MyTest, test_ping_pong) {
.invoke<decltype(&NodeObj::initialize), &NodeObj::initialize>();

if (theContext()->getNode() == 0) {
theTerm()->any_epoch_state_.incrementDependency();
theTerm()->disableTD();
}

StartTimer(fmt::format("{} Bytes", min_bytes));
Expand Down
35 changes: 13 additions & 22 deletions tests/perf/ping_pong_am.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//@HEADER
// *****************************************************************************
//
// reduce.cc
// ping_pong_am.cc
// DARMA/vt => Virtual Transport
//
// Copyright 2019-2021 National Technology & Engineering Solutions of Sandia, LLC
Expand Down Expand Up @@ -40,6 +40,7 @@
// *****************************************************************************
//@HEADER
*/

#include "common/test_harness.h"
#include <vt/collective/collective_ops.h>
#include <vt/objgroup/manager.h>
Expand All @@ -50,44 +51,41 @@
using namespace vt;
using namespace vt::tests::perf::common;

static constexpr int num_iters = 1000;
//static constexpr int num_iters = 1000000;
static constexpr int num_iters = 10000;
static int i = 0;

struct MyTest : PerfTestHarness { };

struct MyMsg : vt::Message {};

std::vector<MsgSharedPtr<MyMsg>> msgs;

struct NodeObj;

vt::objgroup::proxy::Proxy<NodeObj> global_proxy;

void handlerFinished(MyMsg* msg);

void handler(MyMsg* in_msg) {
//fmt::print("{} handler\n", theContext()->getNode());
auto msg = makeMessage<MyMsg>();
// auto msg = msgs.back();
// msgs.pop_back();
theMsg()->sendMsg<MyMsg, &handlerFinished>(0, msg);
}

struct NodeObj {
struct ReduceMsg : vt::collective::ReduceNoneMsg { };

explicit NodeObj(MyTest* test_obj) : test_obj_(test_obj) { }
void initialize() { proxy_ = global_proxy = vt::theObjGroup()->getProxy<NodeObj>(this); }

void initialize() {
proxy_ = global_proxy = vt::theObjGroup()->getProxy<NodeObj>(this);
}

void complete() {
fmt::print("{} complete\n", theContext()->getNode());
test_obj_->StopTimer(fmt::format("{} ping-pong", i));
if (theContext()->getNode() == 0) {
theTerm()->any_epoch_state_.decrementDependency();
theTerm()->enableTD();
}
msgs.clear();
}

void perfPingPong(MyMsg* in_msg) {
fmt::print("{} perfPingPong\n", theContext()->getNode());
test_obj_->StartTimer(fmt::format("{} ping-pong", i));
auto msg = makeMessage<MyMsg>();
theMsg()->sendMsg<MyMsg, &handler>(1, msg);
Expand All @@ -101,14 +99,11 @@ struct NodeObj {
};

void handlerFinished(MyMsg* msg) {
//fmt::print("{} handlerFinished i={}\n", theContext()->getNode(), i);
if (i >= num_iters) {
global_proxy[0].invoke<decltype(&NodeObj::complete), &NodeObj::complete>();
} else {
i++;
auto msg = makeMessage<MyMsg>();
// auto msg = msgs.back();
// msgs.pop_back();
theMsg()->sendMsg<MyMsg, &handler>(1, msg);
}
}
Expand All @@ -119,13 +114,9 @@ VT_PERF_TEST(MyTest, test_ping_pong) {
);

if (theContext()->getNode() == 0) {
theTerm()->any_epoch_state_.incrementDependency();
theTerm()->disableTD();
}

// for (int x = 0; x < num_iters+1; x++) {
// msgs.emplace_back(makeMessage<MyMsg>());
// }

grp_proxy[my_node_].invoke<decltype(&NodeObj::initialize), &NodeObj::initialize>();

if (theContext()->getNode() == 0) {
Expand Down
9 changes: 5 additions & 4 deletions tests/perf/reduce.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@
using namespace vt;
using namespace vt::tests::perf::common;

static constexpr int num_iters = 10;
static constexpr int num_iters = 100;

struct MyTest : PerfTestHarness { };

struct NodeObj {
struct ReduceMsg : vt::collective::ReduceNoneMsg { };

explicit NodeObj(MyTest* test_obj) : test_obj_(test_obj) { }

void initialize() { proxy_ = vt::theObjGroup()->getProxy<NodeObj>(this); }

struct MyMsg : vt::Message {};
Expand All @@ -71,10 +72,10 @@ struct NodeObj {
auto this_node = theContext()->getNode();
proxy_[this_node].send<MyMsg, &NodeObj::perfReduce>();
} else if (theContext()->getNode() == 0) {
theTerm()->any_epoch_state_.decrementDependency();
theTerm()->enableTD();
}
}

void perfReduce(MyMsg* in_msg) {
test_obj_->StartTimer(fmt::format("{} reduce", i));
auto cb = theCB()->makeBcast<NodeObj, ReduceMsg, &NodeObj::reduceComplete>(proxy_);
Expand All @@ -95,7 +96,7 @@ VT_PERF_TEST(MyTest, test_ping_pong) {
);

if (theContext()->getNode() == 0) {
theTerm()->any_epoch_state_.incrementDependency();
theTerm()->disableTD();
}

grp_proxy[my_node_].invoke<decltype(&NodeObj::initialize), &NodeObj::initialize>();
Expand Down

0 comments on commit b58f7de

Please sign in to comment.