diff --git a/tests/perf/collection_local_send.cc b/tests/perf/collection_local_send.cc index 5e8a07973d..08da1cd0da 100644 --- a/tests/perf/collection_local_send.cc +++ b/tests/perf/collection_local_send.cc @@ -82,10 +82,6 @@ struct NodeObj { } void perfMakeRunnable(MyMsg* in_msg) { - for (int i = 0; i < num_iters; i++) { - //msgs.emplace_back(makeMessage()); - } - theTerm()->disableTD(); test_obj_->StartTimer(fmt::format("colSend {}", num_iters)); @@ -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(); - //auto m = msgs[i]; col_proxy[0].template sendMsg(m); vt::theSched()->runSchedulerOnceImpl(); } diff --git a/tests/perf/collection_local_send_prealloc.cc b/tests/perf/collection_local_send_prealloc.cc new file mode 100644 index 0000000000..2eb7ccbc5e --- /dev/null +++ b/tests/perf/collection_local_send_prealloc.cc @@ -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 + +#include + +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 global_proxy; + +void dummyHandler(MyMsg*) {} + +struct TestCol : vt::Collection { + using ColMsg = vt::CollectionMessage; + 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(this); + + auto range = vt::Index1D(8); + col_proxy = vt::makeCollection("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()); + } + + 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(m); + vt::theSched()->runSchedulerOnceImpl(); + } + } + +private: + std::vector> msgs; + HandlerType han; + MyTest* test_obj_ = nullptr; + vt::objgroup::proxy::Proxy proxy_ = {}; + vt::CollectionProxy col_proxy; + int reduce_counter_ = -1; + int i = 0; +}; + +VT_PERF_TEST(MyTest, test_collection_local_send_preallocate) { + auto grp_proxy = vt::theObjGroup()->makeCollective( + "test_collection_local_send_preallocate", this + ); + + grp_proxy[my_node_].invoke(); + + if (theContext()->getNode() == 0) { + grp_proxy[my_node_].send(); + } +} + +VT_PERF_TEST_MAIN()