From 160a5f1edca7210ad0d1cc2c024817ac1a68da16 Mon Sep 17 00:00:00 2001 From: Jacob Domagala Date: Sat, 4 Mar 2023 13:26:05 +0100 Subject: [PATCH 1/6] #2036: Tests: Modify the Perf tests macros to support multiple tests per file --- tests/perf/common/test_harness.h | 22 +++-- tests/perf/common/test_harness_base.h | 29 +++++++ tests/perf/common/test_harness_macros.h | 111 +++++++++++++----------- 3 files changed, 97 insertions(+), 65 deletions(-) create mode 100644 tests/perf/common/test_harness_base.h diff --git a/tests/perf/common/test_harness.h b/tests/perf/common/test_harness.h index 5309e1825c..a1431519ec 100644 --- a/tests/perf/common/test_harness.h +++ b/tests/perf/common/test_harness.h @@ -44,7 +44,7 @@ #if !defined INCLUDED_PERF_COMMON_TEST_HARNESS_H #define INCLUDED_PERF_COMMON_TEST_HARNESS_H -#include "timers.h" +#include "test_harness_base.h" #include "test_harness_macros.h" #include @@ -64,9 +64,9 @@ struct TestResultHolder { T max_ = {}; }; -struct PerfTestHarness { +struct PerfTestHarness : TestHarnessBase { using TestName = std::string; - using TestResult = std::pair; + using FinalTestResult = std::pair>; using TestResults = std::vector>; using PerNodeResults = @@ -78,10 +78,8 @@ struct PerfTestHarness { using CombinedMemoryUse = std::unordered_map>>; - virtual ~PerfTestHarness() = default; - - virtual void SetUp(); - virtual void TearDown(); + void SetUp() override; + void TearDown() override; /** * \brief Initialize internal variables and parse args @@ -98,14 +96,14 @@ struct PerfTestHarness { * * \return name */ - std::string GetName() const; + std::string GetName() const override; /** * \brief Get the number of runs that this test will run * * \return Number of runs */ - uint32_t GetNumRuns() const; + uint32_t GetNumRuns() const override; /** * \brief Dump the test results to stdout and CSV files. @@ -114,14 +112,14 @@ struct PerfTestHarness { * * This is called at the end of running test suite. */ - void DumpResults(); + void DumpResults() override; /** * \brief Add a single test result (name-time pair) * * \param[in] test_result name-time pair of test result */ - void AddResult(TestResult const& test_result); + void AddResult(TestResult const& test_result) override; /** * \brief Add and start a timer with name \c name @@ -142,7 +140,7 @@ struct PerfTestHarness { * \brief Send the tests' results to root node. * This is called after each test run. */ - void SyncResults(); + void SyncResults() override; /** * \brief Copies the test results into combined structures. diff --git a/tests/perf/common/test_harness_base.h b/tests/perf/common/test_harness_base.h new file mode 100644 index 0000000000..f39d522ab7 --- /dev/null +++ b/tests/perf/common/test_harness_base.h @@ -0,0 +1,29 @@ +#if !defined INCLUDED_PERF_COMMON_TEST_HARNESS_BASE_H +#define INCLUDED_PERF_COMMON_TEST_HARNESS_BASE_H + +#include "timers.h" + +#include +#include + +namespace vt::tests::perf::common { + +struct TestHarnessBase { + using TestName = std::string; + using TestResult = std::pair; + + virtual void SetUp() = 0; + virtual void TearDown() = 0; + virtual std::string GetName() const = 0; + virtual uint32_t GetNumRuns() const = 0; + virtual void TestFunc() {} + virtual void AddResult(TestResult const& test_result) = 0; + virtual void DumpResults() = 0; + virtual void SyncResults() = 0; + + virtual ~TestHarnessBase() = default; +}; + +} // namespace vt::tests::perf::common + +#endif \ No newline at end of file diff --git a/tests/perf/common/test_harness_macros.h b/tests/perf/common/test_harness_macros.h index 728073f5f9..c17c71f7ce 100644 --- a/tests/perf/common/test_harness_macros.h +++ b/tests/perf/common/test_harness_macros.h @@ -44,6 +44,9 @@ #if !defined INCLUDED_PERF_COMMON_TEST_HARNESS_MACROS_H #define INCLUDED_PERF_COMMON_TEST_HARNESS_MACROS_H +#include "test_harness_base.h" + +#include namespace vt { namespace tests { namespace perf { namespace common { /** @@ -65,60 +68,62 @@ namespace vt { namespace tests { namespace perf { namespace common { * VT_PERF_TEST_MAIN() */ - #define VT_PERF_TEST(StructName, TestName) \ - struct StructName##TestName : StructName { \ - StructName##TestName() { name_ = #TestName; } \ - void SetUp() override { StructName::SetUp(); } \ - void TearDown() override { StructName::TearDown(); } \ - void TestFunc(); \ - }; \ - using TestType = StructName##TestName; \ - void StructName##TestName::TestFunc() - #define VT_PERF_TEST_MAIN() \ - int main(int argc, char** argv) { \ - using namespace vt::tests::perf::common; \ - \ - MPI_Init(&argc, &argv); \ - \ - int rank; \ - MPI_Comm_rank(MPI_COMM_WORLD, &rank); \ - \ - TestType test; \ - test.Initialize(argc, argv); \ - auto const num_runs = test.GetNumRuns(); \ - \ - StopWatch timer; \ - \ - if (rank == 0) { \ - fmt::print( \ - "{}RUNNING TEST:{} {} (Number of runs = {}) ...\n", \ - vt::debug::bold(), vt::debug::reset(), \ - vt::debug::reg(test.GetName()), \ - vt::debug::reg(fmt::format("{}", num_runs)) \ - ); \ - } \ - \ - for (uint32_t i = 1; i <= num_runs; ++i) { \ - test.SetUp(); \ - \ - timer.Start(); \ - test.TestFunc(); \ - PerfTestHarness::SpinScheduler(); \ - test.AddResult({test.GetName(), timer.Stop()}); \ - \ - if (i == num_runs) { \ - test.SyncResults(); \ - } \ - \ - test.TearDown(); \ - } \ - \ - test.DumpResults(); \ - MPI_Finalize(); \ - \ - return 0; \ - } +struct PerfTestRegistry{ + static void AddTest(TestHarnessBase* test){ + tests_.push_back(test); + } + + static const std::vector& + GetTests(){ + return tests_; + } + + private: + inline static std::vector tests_ = {}; +}; + +#define VT_PERF_TEST(StructName, TestName) \ + struct StructName##TestName : StructName { \ + StructName##TestName() { \ + PerfTestRegistry::AddTest(this); \ + name_ = #TestName; } \ + void SetUp() override { StructName::SetUp(); } \ + void TearDown() override { StructName::TearDown(); } \ + void TestFunc() override; \ + }; \ + void StructName##TestName::TestFunc() + +#define VT_PERF_TEST_MAIN() \ + int main(int argc, char** argv) { \ + using namespace vt::tests::perf::common; \ + MPI_Init(&argc, &argv); \ + int rank; \ + MPI_Comm_rank(MPI_COMM_WORLD, &rank); \ + for (const auto& test : PerfTestRegistry::GetTests()) { \ + auto const num_runs = test->GetNumRuns(); \ + StopWatch timer; \ + if (rank == 0) { \ + fmt::print("{}RUNNING TEST:{} {} (Number of runs = {}) ...\n", \ + vt::debug::bold(), vt::debug::reset(), vt::debug::reg(test->GetName()),\ + vt::debug::reg(fmt::format("{}", num_runs))); \ + } \ + for (uint32_t j = 1; j <= num_runs; ++j) { \ + test->SetUp(); \ + timer.Start(); \ + test->TestFunc(); \ + PerfTestHarness::SpinScheduler(); \ + test->AddResult({test->GetName(), timer.Stop()}); \ + if (j == num_runs) { \ + test->SyncResults(); \ + } \ + test->TearDown(); \ + } \ + test->DumpResults(); \ + } \ + MPI_Finalize(); \ + return 0; \ + } }}}} // namespace vt::tests::perf::common From b2b22d36999f3dbb00282d4cda3eec200c35309f Mon Sep 17 00:00:00 2001 From: Jacob Domagala Date: Sat, 4 Mar 2023 20:25:27 +0100 Subject: [PATCH 2/6] #2036: Tests: Remove duplication in collection_local_send perf tests by using updated macros in a single file --- tests/perf/collection_local_send.cc | 34 +++++++++++++++++++++--- tests/perf/common/test_harness.h | 16 ++++++----- tests/perf/common/test_harness_base.h | 22 +++++++--------- tests/perf/common/test_harness_macros.h | 35 ++++++++++++++++--------- 4 files changed, 73 insertions(+), 34 deletions(-) diff --git a/tests/perf/collection_local_send.cc b/tests/perf/collection_local_send.cc index 41d1df31da..50f1fd042a 100644 --- a/tests/perf/collection_local_send.cc +++ b/tests/perf/collection_local_send.cc @@ -67,8 +67,9 @@ struct NodeObj { struct ReduceMsg : vt::collective::ReduceNoneMsg { }; explicit NodeObj(MyTest* test_obj) : test_obj_(test_obj) { } - void initialize() { + void initialize(bool preallocate) { proxy_ = global_proxy = vt::theObjGroup()->getProxy(this); + preallocate_ = preallocate; auto range = vt::Index1D(8); col_proxy = vt::makeCollection("test") @@ -81,6 +82,20 @@ struct NodeObj { 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 perfMakeRunnable(MyMsg* in_msg) { theTerm()->disableTD(); @@ -93,7 +108,7 @@ struct NodeObj { void perfRunBenchmark() { for (int i = 0; i < num_iters; i++) { - auto m = makeMessage(); + auto m = preallocate_ ? msgs[i] : makeMessage(); col_proxy[0].template sendMsg<&TestCol::han>(m); vt::theSched()->runSchedulerOnceImpl(); } @@ -107,6 +122,7 @@ struct NodeObj { vt::CollectionProxy col_proxy; int reduce_counter_ = -1; int i = 0; + bool preallocate_ = false; }; VT_PERF_TEST(MyTest, test_collection_local_send) { @@ -114,11 +130,23 @@ VT_PERF_TEST(MyTest, test_collection_local_send) { "test_collection_local_send", this ); - grp_proxy[my_node_].invoke<&NodeObj::initialize>(); + grp_proxy[my_node_].invoke<&NodeObj::initialize>(false); if (theContext()->getNode() == 0) { grp_proxy[my_node_].send<&NodeObj::perfMakeRunnable>(); } } +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<&NodeObj::initialize>(true); + + if (theContext()->getNode() == 0) { + grp_proxy[my_node_].send(); + } +} + VT_PERF_TEST_MAIN() diff --git a/tests/perf/common/test_harness.h b/tests/perf/common/test_harness.h index a1431519ec..5504307658 100644 --- a/tests/perf/common/test_harness.h +++ b/tests/perf/common/test_harness.h @@ -44,6 +44,7 @@ #if !defined INCLUDED_PERF_COMMON_TEST_HARNESS_H #define INCLUDED_PERF_COMMON_TEST_HARNESS_H +#include "timers.h" #include "test_harness_base.h" #include "test_harness_macros.h" @@ -66,6 +67,7 @@ struct TestResultHolder { struct PerfTestHarness : TestHarnessBase { using TestName = std::string; + using TestResult = std::pair; using FinalTestResult = std::pair>; using TestResults = std::vector>; @@ -78,8 +80,8 @@ struct PerfTestHarness : TestHarnessBase { using CombinedMemoryUse = std::unordered_map>>; - void SetUp() override; - void TearDown() override; + virtual void SetUp(); + virtual void TearDown(); /** * \brief Initialize internal variables and parse args @@ -96,14 +98,14 @@ struct PerfTestHarness : TestHarnessBase { * * \return name */ - std::string GetName() const override; + std::string GetName() const; /** * \brief Get the number of runs that this test will run * * \return Number of runs */ - uint32_t GetNumRuns() const override; + uint32_t GetNumRuns() const; /** * \brief Dump the test results to stdout and CSV files. @@ -112,14 +114,14 @@ struct PerfTestHarness : TestHarnessBase { * * This is called at the end of running test suite. */ - void DumpResults() override; + void DumpResults(); /** * \brief Add a single test result (name-time pair) * * \param[in] test_result name-time pair of test result */ - void AddResult(TestResult const& test_result) override; + void AddResult(TestResult const& test_result); /** * \brief Add and start a timer with name \c name @@ -140,7 +142,7 @@ struct PerfTestHarness : TestHarnessBase { * \brief Send the tests' results to root node. * This is called after each test run. */ - void SyncResults() override; + void SyncResults(); /** * \brief Copies the test results into combined structures. diff --git a/tests/perf/common/test_harness_base.h b/tests/perf/common/test_harness_base.h index f39d522ab7..eb94085043 100644 --- a/tests/perf/common/test_harness_base.h +++ b/tests/perf/common/test_harness_base.h @@ -1,25 +1,23 @@ #if !defined INCLUDED_PERF_COMMON_TEST_HARNESS_BASE_H #define INCLUDED_PERF_COMMON_TEST_HARNESS_BASE_H -#include "timers.h" +// #include "timers.h" -#include -#include +// #include +// #include namespace vt::tests::perf::common { struct TestHarnessBase { - using TestName = std::string; - using TestResult = std::pair; - virtual void SetUp() = 0; - virtual void TearDown() = 0; - virtual std::string GetName() const = 0; - virtual uint32_t GetNumRuns() const = 0; + // virtual void SetUp() = 0; + // virtual void TearDown() = 0; + // virtual std::string GetName() const = 0; + // virtual uint32_t GetNumRuns() const = 0; virtual void TestFunc() {} - virtual void AddResult(TestResult const& test_result) = 0; - virtual void DumpResults() = 0; - virtual void SyncResults() = 0; + // virtual void AddResult(TestResult const& test_result) = 0; + // virtual void DumpResults() = 0; + // virtual void SyncResults() = 0; virtual ~TestHarnessBase() = default; }; diff --git a/tests/perf/common/test_harness_macros.h b/tests/perf/common/test_harness_macros.h index c17c71f7ce..28a15f4bd6 100644 --- a/tests/perf/common/test_harness_macros.h +++ b/tests/perf/common/test_harness_macros.h @@ -83,24 +83,32 @@ struct PerfTestRegistry{ inline static std::vector tests_ = {}; }; -#define VT_PERF_TEST(StructName, TestName) \ - struct StructName##TestName : StructName { \ - StructName##TestName() { \ - PerfTestRegistry::AddTest(this); \ - name_ = #TestName; } \ - void SetUp() override { StructName::SetUp(); } \ - void TearDown() override { StructName::TearDown(); } \ - void TestFunc() override; \ - }; \ +#define VT_PERF_TEST(StructName, TestName) \ + struct StructName##TestName : StructName { \ + StructName##TestName() { \ + name_ = #TestName; } \ + void SetUp() override { StructName::SetUp(); } \ + void TearDown() override { StructName::TearDown(); } \ + void TestFunc() override; \ + }; \ + \ + static struct StructName##TestName##_registerer_t { \ + StructName##TestName##_registerer_t() { \ + PerfTestRegistry::AddTest(new StructName##TestName());\ + } \ + } StructName##TestName##_registerer; \ void StructName##TestName::TestFunc() + #define VT_PERF_TEST_MAIN() \ int main(int argc, char** argv) { \ using namespace vt::tests::perf::common; \ MPI_Init(&argc, &argv); \ int rank; \ MPI_Comm_rank(MPI_COMM_WORLD, &rank); \ - for (const auto& test : PerfTestRegistry::GetTests()) { \ + for (const auto& test_base : PerfTestRegistry::GetTests()) { \ + auto* test = dynamic_cast(test_base); \ + test->Initialize(argc, argv); \ auto const num_runs = test->GetNumRuns(); \ StopWatch timer; \ if (rank == 0) { \ @@ -108,15 +116,18 @@ struct PerfTestRegistry{ vt::debug::bold(), vt::debug::reset(), vt::debug::reg(test->GetName()),\ vt::debug::reg(fmt::format("{}", num_runs))); \ } \ - for (uint32_t j = 1; j <= num_runs; ++j) { \ + for (uint32_t run_num = 1; run_num <= num_runs; ++run_num) { \ test->SetUp(); \ + \ timer.Start(); \ test->TestFunc(); \ PerfTestHarness::SpinScheduler(); \ test->AddResult({test->GetName(), timer.Stop()}); \ - if (j == num_runs) { \ + \ + if (run_num == num_runs) { \ test->SyncResults(); \ } \ + \ test->TearDown(); \ } \ test->DumpResults(); \ From 06fbd4c4d2f5dbe25117e5c40df71dd8cb5feaad Mon Sep 17 00:00:00 2001 From: Jacob Domagala Date: Sat, 4 Mar 2023 20:37:07 +0100 Subject: [PATCH 3/6] #2036: Tests: Cleanup perf test harness base --- tests/perf/common/test_harness_base.h | 55 ++++++++++++++++++++------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/tests/perf/common/test_harness_base.h b/tests/perf/common/test_harness_base.h index eb94085043..47e312eb3b 100644 --- a/tests/perf/common/test_harness_base.h +++ b/tests/perf/common/test_harness_base.h @@ -1,24 +1,51 @@ +//@HEADER +// ***************************************************************************** +// +// test_harness_base.h +// 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 + #if !defined INCLUDED_PERF_COMMON_TEST_HARNESS_BASE_H #define INCLUDED_PERF_COMMON_TEST_HARNESS_BASE_H -// #include "timers.h" - -// #include -// #include - namespace vt::tests::perf::common { struct TestHarnessBase { - - // virtual void SetUp() = 0; - // virtual void TearDown() = 0; - // virtual std::string GetName() const = 0; - // virtual uint32_t GetNumRuns() const = 0; virtual void TestFunc() {} - // virtual void AddResult(TestResult const& test_result) = 0; - // virtual void DumpResults() = 0; - // virtual void SyncResults() = 0; - virtual ~TestHarnessBase() = default; }; From a74949228d10b00755cba53c7633bc67b66c2cad Mon Sep 17 00:00:00 2001 From: Jacob Domagala Date: Wed, 5 Apr 2023 16:00:08 +0200 Subject: [PATCH 4/6] #2036: Tests: Remove collection_local_send.cc --- tests/perf/collection_local_send_prealloc.cc | 128 ------------------- 1 file changed, 128 deletions(-) delete mode 100644 tests/perf/collection_local_send_prealloc.cc diff --git a/tests/perf/collection_local_send_prealloc.cc b/tests/perf/collection_local_send_prealloc.cc deleted file mode 100644 index 32337253f8..0000000000 --- a/tests/perf/collection_local_send_prealloc.cc +++ /dev/null @@ -1,128 +0,0 @@ -/* -//@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<&TestCol::han>(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<&NodeObj::initialize>(); - - if (theContext()->getNode() == 0) { - grp_proxy[my_node_].send(); - } -} - -VT_PERF_TEST_MAIN() From 6b87f60e90a4b8e0442ba34952f04f58ffc5d8ee Mon Sep 17 00:00:00 2001 From: Jacob Domagala Date: Wed, 10 May 2023 20:39:53 +0200 Subject: [PATCH 5/6] #2036: Tests: Increase timeout of performance tests to 500sec --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7a8e4ba4ae..e0d10b060e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -271,7 +271,7 @@ foreach(PERF_TEST ${PROJECT_PERF_TESTS}) PROPERTIES PROCESSORS ${PERF_TEST_NUMPROC} RUN_SERIAL TRUE # do not run in parallel with any other tests - TIMEOUT 300 + TIMEOUT 500 LABELS "perf_test" ) endforeach() From 7d27c8f79cb806f0a2b60aba0f2331d45d1691af Mon Sep 17 00:00:00 2001 From: Jacob Domagala Date: Wed, 10 May 2023 20:40:57 +0200 Subject: [PATCH 6/6] #2036: Tests: Reuse the perfMakeRunnable function for collection_local_send perf test --- tests/perf/collection_local_send.cc | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/perf/collection_local_send.cc b/tests/perf/collection_local_send.cc index 50f1fd042a..a300485d8e 100644 --- a/tests/perf/collection_local_send.cc +++ b/tests/perf/collection_local_send.cc @@ -87,13 +87,7 @@ struct NodeObj { 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(); + perfMakeRunnable(in_msg); } void perfMakeRunnable(MyMsg* in_msg) {