Skip to content

Commit

Permalink
#1930: split collection_local_send
Browse files Browse the repository at this point in the history
  • Loading branch information
stmcgovern authored and cz4rs committed Dec 28, 2022
1 parent 09af369 commit 36e16bf
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 6 deletions.
6 changes: 0 additions & 6 deletions tests/perf/collection_local_send.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ struct NodeObj {
}

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

theTerm()->disableTD();

test_obj_->StartTimer(fmt::format("colSend {}", num_iters));
Expand All @@ -96,10 +92,8 @@ struct NodeObj {
}

void perfRunBenchmark() {
// fmt::print("ptr={}\n", print_ptr(col_proxy.lm));
for (int i = 0; i < num_iters; i++) {
auto m = makeMessage<TestCol::ColMsg>();
//auto m = msgs[i];
col_proxy[0].template sendMsg<TestCol::ColMsg, &TestCol::han>(m);
vt::theSched()->runSchedulerOnceImpl();
}
Expand Down
128 changes: 128 additions & 0 deletions tests/perf/collection_local_send_prealloc.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
//@HEADER
// *****************************************************************************
//
// collection_local_send_prealloc.cc
// DARMA/vt => Virtual Transport
//
// Copyright 2019-2021 National Technology & Engineering Solutions of Sandia, LLC
// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S.
// Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact darma@sandia.gov
//
// *****************************************************************************
//@HEADER
*/
#include "common/test_harness.h"
#include <vt/transport.h>

#include <fmt-vt/core.h>

using namespace vt;
using namespace vt::tests::perf::common;

static constexpr int num_iters = 1000000;

struct MyTest : PerfTestHarness { };
struct MyMsg : vt::Message {};

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

void dummyHandler(MyMsg*) {}

struct TestCol : vt::Collection<TestCol, vt::Index1D> {
using ColMsg = vt::CollectionMessage<TestCol>;
void han(ColMsg* 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);

auto range = vt::Index1D(8);
col_proxy = vt::makeCollection<TestCol>("test")
.bounds(range)
.bulkInsert()
.wait();
// fmt::print("ptr={}\n", print_ptr(col_proxy.lm));
}

void complete() {
}


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

theTerm()->disableTD();

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

theTerm()->enableTD();
}
void perfRunBenchmark() {
for (int i = 0; i < num_iters; i++) {
auto m = msgs[i];
col_proxy[0].template sendMsg<TestCol::ColMsg, &TestCol::han>(m);
vt::theSched()->runSchedulerOnceImpl();
}
}

private:
std::vector<MsgSharedPtr<TestCol::ColMsg>> msgs;
HandlerType han;
MyTest* test_obj_ = nullptr;
vt::objgroup::proxy::Proxy<NodeObj> proxy_ = {};
vt::CollectionProxy<TestCol> col_proxy;
int reduce_counter_ = -1;
int i = 0;
};

VT_PERF_TEST(MyTest, test_collection_local_send_preallocate) {
auto grp_proxy = vt::theObjGroup()->makeCollective<NodeObj>(
"test_collection_local_send_preallocate", this
);

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

if (theContext()->getNode() == 0) {
grp_proxy[my_node_].send<MyMsg, &NodeObj::perfMakeRunnablePreAllocate>();
}
}

VT_PERF_TEST_MAIN()

0 comments on commit 36e16bf

Please sign in to comment.