Skip to content

Commit

Permalink
Merge pull request openucx#5955 from shamisp/topic/ucp/gtest_wfe_v2
Browse files Browse the repository at this point in the history
GTEST: Moving memory_wait test to perf
  • Loading branch information
yosefe authored Dec 1, 2020
2 parents a2769c4 + a495417 commit 86755f6
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 142 deletions.
3 changes: 2 additions & 1 deletion src/tools/perf/api/libperf.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ typedef enum {

typedef enum {
UCX_PERF_TEST_TYPE_PINGPONG, /* Ping-pong mode */
UCX_PERF_TEST_TYPE_PINGPONG_WFE, /* Ping-pong mode with wait for event */
UCX_PERF_TEST_TYPE_PINGPONG_WAIT_MEM,/* Ping-pong mode with
ucp_worker_wait_mem() */
UCX_PERF_TEST_TYPE_STREAM_UNI, /* Unidirectional stream */
UCX_PERF_TEST_TYPE_STREAM_BI, /* Bidirectional stream */
UCX_PERF_TEST_TYPE_LAST
Expand Down
2 changes: 1 addition & 1 deletion src/tools/perf/lib/libperf.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ void ucx_perf_calc_result(ucx_perf_context_t *perf, ucx_perf_result_t *result)
double factor;

if ((perf->params.test_type == UCX_PERF_TEST_TYPE_PINGPONG) ||
(perf->params.test_type == UCX_PERF_TEST_TYPE_PINGPONG_WFE)) {
(perf->params.test_type == UCX_PERF_TEST_TYPE_PINGPONG_WAIT_MEM)) {
factor = 2.0;
} else {
factor = 1.0;
Expand Down
20 changes: 10 additions & 10 deletions src/tools/perf/lib/ucp_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class ucp_perf_test_runner {
/* coverity[switch_selector_expr_is_constant] */
switch (TYPE) {
case UCX_PERF_TEST_TYPE_PINGPONG:
case UCX_PERF_TEST_TYPE_PINGPONG_WFE:
case UCX_PERF_TEST_TYPE_PINGPONG_WAIT_MEM:
*((uint8_t*)buffer + length - 1) = sn;
break;
case UCX_PERF_TEST_TYPE_STREAM_UNI:
Expand Down Expand Up @@ -287,13 +287,13 @@ class ucp_perf_test_runner {
progress_responder();
}
return UCS_OK;
case UCX_PERF_TEST_TYPE_PINGPONG_WFE:
ptr = (volatile uint8_t*)buffer + length - 1;
while (*ptr != sn) {
ucp_worker_wait_mem(worker, (void *)ptr);
progress_responder();
}
return UCS_OK;
case UCX_PERF_TEST_TYPE_PINGPONG_WAIT_MEM:
ptr = (volatile uint8_t*)buffer + length - 1;
while (*ptr != sn) {
ucp_worker_wait_mem(worker, (void *)ptr);
progress_responder();
}
return UCS_OK;
case UCX_PERF_TEST_TYPE_STREAM_UNI:
return UCS_OK;
default:
Expand Down Expand Up @@ -519,7 +519,7 @@ class ucp_perf_test_runner {
/* coverity[switch_selector_expr_is_constant] */
switch (TYPE) {
case UCX_PERF_TEST_TYPE_PINGPONG:
case UCX_PERF_TEST_TYPE_PINGPONG_WFE:
case UCX_PERF_TEST_TYPE_PINGPONG_WAIT_MEM:
return run_pingpong();
case UCX_PERF_TEST_TYPE_STREAM_UNI:
return run_stream_uni();
Expand Down Expand Up @@ -635,7 +635,7 @@ ucs_status_t ucp_perf_test_dispatch(ucx_perf_context_t *perf)
{
UCS_PP_FOREACH(TEST_CASE_ALL_OSD, perf,
(UCX_PERF_CMD_PUT, UCX_PERF_TEST_TYPE_PINGPONG),
(UCX_PERF_CMD_PUT, UCX_PERF_TEST_TYPE_PINGPONG_WFE),
(UCX_PERF_CMD_PUT, UCX_PERF_TEST_TYPE_PINGPONG_WAIT_MEM),
(UCX_PERF_CMD_PUT, UCX_PERF_TEST_TYPE_STREAM_UNI),
(UCX_PERF_CMD_GET, UCX_PERF_TEST_TYPE_STREAM_UNI),
(UCX_PERF_CMD_ADD, UCX_PERF_TEST_TYPE_STREAM_UNI),
Expand Down
4 changes: 2 additions & 2 deletions src/tools/perf/lib/uct_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class uct_perf_test_runner {
}
case UCX_PERF_CMD_PUT:
if ((TYPE == UCX_PERF_TEST_TYPE_PINGPONG) ||
(TYPE == UCX_PERF_TEST_TYPE_PINGPONG_WFE)) {
(TYPE == UCX_PERF_TEST_TYPE_PINGPONG_WAIT_MEM)) {
/* Put the control word at the latest byte of the IOV message */
set_sn(UCS_PTR_BYTE_OFFSET(buffer,
uct_perf_get_buffer_extent(&m_perf.params) - 1),
Expand Down Expand Up @@ -623,7 +623,7 @@ class uct_perf_test_runner {
/* coverity[switch_selector_expr_is_constant] */
switch (TYPE) {
case UCX_PERF_TEST_TYPE_PINGPONG:
case UCX_PERF_TEST_TYPE_PINGPONG_WFE:
case UCX_PERF_TEST_TYPE_PINGPONG_WAIT_MEM:
return run_pingpong();
case UCX_PERF_TEST_TYPE_STREAM_UNI:
/* coverity[switch_selector_expr_is_constant] */
Expand Down
1 change: 0 additions & 1 deletion test/gtest/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ gtest_SOURCES = \
ucp/test_ucp_mmap.cc \
ucp/test_ucp_mem_type.cc \
ucp/test_ucp_perf.cc \
ucp/test_ucp_wfe.cc \
ucp/test_ucp_proto.cc \
ucp/test_ucp_rma.cc \
ucp/test_ucp_rma_mt.cc \
Expand Down
27 changes: 14 additions & 13 deletions test/gtest/common/test_perf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ extern "C" {
#include <vector>


#define UCP_ARM_PERF_TEST_MULTIPLIER 2
#define UCT_ARM_PERF_TEST_MULTIPLIER 15
#define UCT_PERF_TEST_MULTIPLIER 5


test_perf::rte_comm::rte_comm() {
pthread_mutex_init(&m_mutex, NULL);
}
Expand Down Expand Up @@ -252,9 +257,8 @@ test_perf::test_result test_perf::run_multi_threaded(const test_spec &test, unsi
return result;
}

void test_perf::run_test(const test_spec& test, unsigned flags, bool check_perf,
const std::string &tl_name, const std::string &dev_name,
double *perf_value)
double test_perf::run_test(const test_spec& test, unsigned flags, bool check_perf,
const std::string &tl_name, const std::string &dev_name)
{
std::vector<int> cpus = get_affinity();
if (cpus.size() < 2) {
Expand All @@ -272,7 +276,7 @@ void test_perf::run_test(const test_spec& test, unsigned flags, bool check_perf,
if ((result.status == UCS_ERR_UNSUPPORTED) ||
(result.status == UCS_ERR_UNREACHABLE))
{
return; /* Skipped */
return 0.0; /* Skipped */
}

ASSERT_UCS_OK(result.status);
Expand All @@ -292,20 +296,17 @@ void test_perf::run_test(const test_spec& test, unsigned flags, bool check_perf,
UCS_TEST_MESSAGE << result_str << " (attempt " << i << ")";
}

if (perf_value != NULL) {
*perf_value = value;
}

if (!check_perf) {
return; /* Skip */
return value; /* Skip */
} else if ((value >= test.min) && (value <= test.max)) {
return; /* Success */
return value; /* Success */
} else {
ucs::safe_sleep(ucs::perf_retry_interval);
}
}

ADD_FAILURE() << "Invalid " << test.title << " performance, expected: " <<
std::setprecision(3) << test.min << ".." << test.max;
}
ADD_FAILURE() << "Invalid " << test.title << " performance, expected: "
<< std::setprecision(3) << test.min << ".." << test.max;

return 0.0;
}
5 changes: 2 additions & 3 deletions test/gtest/common/test_perf.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ class test_perf {

static std::vector<int> get_affinity();

void run_test(const test_spec& test, unsigned flags, bool check_perf, const
std::string &tl_name, const std::string &dev_name, double
*perf_value = NULL);
double run_test(const test_spec& test, unsigned flags, bool check_perf, const
std::string &tl_name, const std::string &dev_name);

private:
class rte_comm {
Expand Down
61 changes: 55 additions & 6 deletions test/gtest/ucp/test_ucp_perf.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/**
* Copyright (C) Mellanox Technologies Ltd. 2001-2014. ALL RIGHTS RESERVED.
*
* Copyright (C) UT-Battelle, LLC. 2015. ALL RIGHTS RESERVED.
* Copyright (C) ARM Ltd. 2020. ALL RIGHTS RESERVED.
*
* See file LICENSE for terms.
*/

Expand All @@ -11,7 +12,9 @@


#define MB pow(1024.0, -2)
#define UCP_ARM_PERF_TEST_MULTIPLIER 2
#define UCT_PERF_TEST_MULTIPLIER 5
#define UCT_ARM_PERF_TEST_MULTIPLIER 15

class test_ucp_perf : public ucp_test, public test_perf {
public:
static void get_test_variants(std::vector<ucp_test_variant>& variants) {
Expand All @@ -37,7 +40,7 @@ class test_ucp_perf : public ucp_test, public test_perf {
// Ignore errors that transport cannot reach peer
if (level == UCS_LOG_LEVEL_ERROR) {
std::string err_str = format_message(message, ap);
if (strstr(err_str.c_str(), ucs_status_string(UCS_ERR_UNREACHABLE)) ||
if (strstr(err_str.c_str(), ucs_status_string(UCS_ERR_UNREACHABLE)) ||
strstr(err_str.c_str(), ucs_status_string(UCS_ERR_UNSUPPORTED))) {
UCS_TEST_MESSAGE << err_str;
return UCS_LOG_FUNC_RC_STOP;
Expand Down Expand Up @@ -187,16 +190,62 @@ UCS_TEST_P(test_ucp_perf, envelope) {
ucs::scoped_setenv warn_invalid("UCX_WARN_INVALID_CONFIG", "no");

/* Run all tests */
for (const test_spec *test_iter = tests; test_iter->title != NULL; ++test_iter) {
for (const test_spec *test_iter = tests; test_iter->title != NULL;
++test_iter) {
test_spec test = *test_iter;

if (ucs_arch_get_cpu_model() == UCS_CPU_MODEL_ARM_AARCH64) {
test.max *= UCP_ARM_PERF_TEST_MULTIPLIER;
test.min /= UCP_ARM_PERF_TEST_MULTIPLIER;
test.max *= UCT_ARM_PERF_TEST_MULTIPLIER;
test.min /= UCT_ARM_PERF_TEST_MULTIPLIER;
} else {
test.max *= UCT_PERF_TEST_MULTIPLIER;
test.min /= UCT_PERF_TEST_MULTIPLIER;
}
test.iters = ucs_min(test.iters, max_iter);

run_test(test, 0, check_perf, "", "");
}
}

UCP_INSTANTIATE_TEST_CASE(test_ucp_perf)


class test_ucp_wait_mem : public test_ucp_perf {};

UCS_TEST_P(test_ucp_wait_mem, envelope) {
double perf_avg = 0;
double perf_iter = 0;
const int max_iter = ucs_max(ucs::perf_retry_count, 1);
int i;

/* Run ping-pong with no WFE and get latency reference values */
const test_spec test1 = { "put latency reference", "usec",
UCX_PERF_API_UCP, UCX_PERF_CMD_PUT,
UCX_PERF_TEST_TYPE_PINGPONG,
UCP_PERF_DATATYPE_CONTIG,
0, 1, { 8 }, 1, 1000lu,
ucs_offsetof(ucx_perf_result_t,
latency.total_average),
1e6, 0.001, 30.0, 0 };
for (i = 0; i < max_iter; i++) {
perf_iter = run_test(test1, 0, false, "", "");
perf_avg += perf_iter;
}
perf_avg /= max_iter;

/* Run ping-pong with WFE while re-using previous run numbers as
* a min/max boundary. The latency of the WFE run should stay nearly
* identical with 200 percent margin. When WFE does not work as expected
* the slow down is typically 10x-100x */
const test_spec test2 = { "put latency with ucp_worker_wait_mem()",
"usec", UCX_PERF_API_UCP, UCX_PERF_CMD_PUT,
UCX_PERF_TEST_TYPE_PINGPONG_WAIT_MEM,
UCP_PERF_DATATYPE_CONTIG,
0, 1, { 8 }, 1, 1000lu,
ucs_offsetof(ucx_perf_result_t,
latency.total_average),
1e6, perf_avg * 0.7, perf_avg * 2, 0 };
run_test(test2, 0, true, "", "");
}

UCP_INSTANTIATE_TEST_CASE_TLS(test_ucp_wait_mem, shm, "shm")
105 changes: 0 additions & 105 deletions test/gtest/ucp/test_ucp_wfe.cc

This file was deleted.

0 comments on commit 86755f6

Please sign in to comment.