Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2036 Update PerfTestHarness to allow for multiple tests in a single file #2097

Merged
merged 6 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Increased the timeout, as we now run multiple tests inside single test file

LABELS "perf_test"
)
endforeach()
28 changes: 25 additions & 3 deletions tests/perf/collection_local_send.cc
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JacobDomagala @lifflander I'm trying to understand what the collection_local_send.cc perf tests actually do. Is it true that only rank 0 runs the timed perf test, and only does a send to collection element 0, which is assumed to be local to rank 0 but not verified? It seems like some stuff could be simplified, like (a) consistently using my_node_ instead of theContext()->getNode(), (b) also only pre-allocating on rank 0, and (c) using preallocate_ to conditionally pre-allocate based on what happened in initialiaze instead of having the separate perfMakeRunnable and perfMakeRunnablePreAllocate calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#2155 should address those issues

Original file line number Diff line number Diff line change
Expand Up @@ -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<NodeObj>(this);
preallocate_ = preallocate;

auto range = vt::Index1D(8);
col_proxy = vt::makeCollection<TestCol>("test")
Expand All @@ -81,6 +82,14 @@ struct NodeObj {
void complete() {
}

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

perfMakeRunnable(in_msg);
}

void perfMakeRunnable(MyMsg* in_msg) {
theTerm()->disableTD();

Expand All @@ -93,7 +102,7 @@ struct NodeObj {

void perfRunBenchmark() {
for (int i = 0; i < num_iters; i++) {
auto m = makeMessage<TestCol::ColMsg>();
auto m = preallocate_ ? msgs[i] : makeMessage<TestCol::ColMsg>();
col_proxy[0].template sendMsg<&TestCol::han>(m);
vt::theSched()->runSchedulerOnceImpl();
}
Expand All @@ -107,18 +116,31 @@ struct NodeObj {
vt::CollectionProxy<TestCol> col_proxy;
int reduce_counter_ = -1;
int i = 0;
bool preallocate_ = false;
};

VT_PERF_TEST(MyTest, test_collection_local_send) {
auto grp_proxy = vt::theObjGroup()->makeCollective<NodeObj>(
"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<NodeObj>(
"test_collection_local_send_preallocate", this
);

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

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

VT_PERF_TEST_MAIN()
128 changes: 0 additions & 128 deletions tests/perf/collection_local_send_prealloc.cc

This file was deleted.

6 changes: 3 additions & 3 deletions tests/perf/common/test_harness.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#define INCLUDED_PERF_COMMON_TEST_HARNESS_H

#include "timers.h"
#include "test_harness_base.h"
#include "test_harness_macros.h"

#include <vt/configs/types/types_type.h>
Expand All @@ -64,9 +65,10 @@ struct TestResultHolder {
T max_ = {};
};

struct PerfTestHarness {
struct PerfTestHarness : TestHarnessBase {
using TestName = std::string;
using TestResult = std::pair<TestName, TimeType>;

using FinalTestResult = std::pair<TestName, TestResultHolder<TimeType>>;
using TestResults = std::vector<std::vector<TestResult>>;
using PerNodeResults =
Expand All @@ -78,8 +80,6 @@ struct PerfTestHarness {
using CombinedMemoryUse =
std::unordered_map<NodeType, std::vector<TestResultHolder<std::size_t>>>;

virtual ~PerfTestHarness() = default;

virtual void SetUp();
virtual void TearDown();

Expand Down
54 changes: 54 additions & 0 deletions tests/perf/common/test_harness_base.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//@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

namespace vt::tests::perf::common {

struct TestHarnessBase {
virtual void TestFunc() {}
virtual ~TestHarnessBase() = default;
};

} // namespace vt::tests::perf::common

#endif
Loading