Skip to content

Commit

Permalink
Merge pull request #10274 from michal-shalev/reduce-stack-usage-in-uc…
Browse files Browse the repository at this point in the history
…t-perf-test-dispatch

TEST/PERF: Reduce stack usage in uct_perf_test_dispatch()
  • Loading branch information
michal-shalev authored Nov 14, 2024
2 parents 837a96e + 39c534a commit 0efde8e
Showing 1 changed file with 39 additions and 14 deletions.
53 changes: 39 additions & 14 deletions src/tools/perf/lib/uct_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -783,21 +783,46 @@ class uct_perf_test_runner {
TEST_CASE_ALL_OSD(_perf, _case, UCT_PERF_DATA_LAYOUT_BCOPY) \
TEST_CASE_ALL_OSD(_perf, _case, UCT_PERF_DATA_LAYOUT_ZCOPY)

#define DEFINE_DISPATCH_FUNC(_case, _cmd, _type) \
static ucs_status_t uct_perf_dispatch_##_case(ucx_perf_context_t *perf) { \
TEST_CASE_ALL_DATA(perf, (_cmd, _type)); \
return UCS_ERR_INVALID_PARAM; \
}

#define DISPATCH_FUNC_ENTRY(_case, _cmd, _type) uct_perf_dispatch_##_case,

#define ITERATE_TEST_CASES(_macro) \
_macro(pingpong_am, UCX_PERF_CMD_AM, UCX_PERF_TEST_TYPE_PINGPONG) \
_macro(pingpong_put, UCX_PERF_CMD_PUT, UCX_PERF_TEST_TYPE_PINGPONG) \
_macro(pingpong_add, UCX_PERF_CMD_ADD, UCX_PERF_TEST_TYPE_PINGPONG) \
_macro(stream_uni_am, UCX_PERF_CMD_AM, UCX_PERF_TEST_TYPE_STREAM_UNI) \
_macro(stream_uni_put, UCX_PERF_CMD_PUT, UCX_PERF_TEST_TYPE_STREAM_UNI) \
_macro(stream_uni_get, UCX_PERF_CMD_GET, UCX_PERF_TEST_TYPE_STREAM_UNI) \
_macro(stream_uni_add, UCX_PERF_CMD_ADD, UCX_PERF_TEST_TYPE_STREAM_UNI) \
_macro(stream_uni_fadd, UCX_PERF_CMD_FADD, UCX_PERF_TEST_TYPE_STREAM_UNI) \
_macro(stream_uni_swap, UCX_PERF_CMD_SWAP, UCX_PERF_TEST_TYPE_STREAM_UNI) \
_macro(stream_uni_cswap,UCX_PERF_CMD_CSWAP, UCX_PERF_TEST_TYPE_STREAM_UNI)

ITERATE_TEST_CASES(DEFINE_DISPATCH_FUNC)

ucs_status_t uct_perf_test_dispatch(ucx_perf_context_t *perf)
{
UCS_PP_FOREACH(TEST_CASE_ALL_DATA, perf,
(UCX_PERF_CMD_AM, UCX_PERF_TEST_TYPE_PINGPONG),
(UCX_PERF_CMD_PUT, UCX_PERF_TEST_TYPE_PINGPONG),
(UCX_PERF_CMD_ADD, UCX_PERF_TEST_TYPE_PINGPONG),
(UCX_PERF_CMD_AM, UCX_PERF_TEST_TYPE_STREAM_UNI),
(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),
(UCX_PERF_CMD_FADD, UCX_PERF_TEST_TYPE_STREAM_UNI),
(UCX_PERF_CMD_SWAP, UCX_PERF_TEST_TYPE_STREAM_UNI),
(UCX_PERF_CMD_CSWAP, UCX_PERF_TEST_TYPE_STREAM_UNI)
);

ucs_error("Invalid test case");
using uct_dispatch_func_t = ucs_status_t
(*)(ucx_perf_context_t *perf);
static const uct_dispatch_func_t dispatchers[] = {
ITERATE_TEST_CASES(DISPATCH_FUNC_ENTRY)
};
ucs_status_t status;

for (const auto &dispatcher : dispatchers) {
status = dispatcher(perf);
if (status != UCS_ERR_INVALID_PARAM) {
return status;
}
}

ucs_error("Invalid test case: %d/%d/0x%x",
perf->params.command, perf->params.test_type,
perf->params.flags);
return UCS_ERR_INVALID_PARAM;
}

0 comments on commit 0efde8e

Please sign in to comment.