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

STACK: reduce stack usage in tests #10131

Merged
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
78 changes: 57 additions & 21 deletions src/tools/perf/lib/ucp_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1033,35 +1033,71 @@ class ucp_perf_test_runner {
#define TEST_CASE_ALL_AM(_perf, _case) \
TEST_CASE(_perf, UCS_PP_TUPLE_0 _case, UCS_PP_TUPLE_1 _case, 0, 0)

ucs_status_t ucp_perf_test_dispatch(ucx_perf_context_t *perf)
static ucs_status_t ucp_perf_dispatch_osd(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_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),
(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)
);
(UCX_PERF_CMD_PUT, UCX_PERF_TEST_TYPE_PINGPONG),
(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),
(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)
);
return UCS_ERR_INVALID_PARAM;
}

static ucs_status_t ucp_perf_dispatch_tag(ucx_perf_context_t *perf)
{
UCS_PP_FOREACH(TEST_CASE_ALL_TAG, perf,
(UCX_PERF_CMD_TAG, UCX_PERF_TEST_TYPE_PINGPONG),
(UCX_PERF_CMD_TAG, UCX_PERF_TEST_TYPE_STREAM_UNI),
(UCX_PERF_CMD_TAG_SYNC, UCX_PERF_TEST_TYPE_PINGPONG),
(UCX_PERF_CMD_TAG_SYNC, UCX_PERF_TEST_TYPE_STREAM_UNI)
);
(UCX_PERF_CMD_TAG, UCX_PERF_TEST_TYPE_PINGPONG),
(UCX_PERF_CMD_TAG, UCX_PERF_TEST_TYPE_STREAM_UNI),
(UCX_PERF_CMD_TAG_SYNC, UCX_PERF_TEST_TYPE_PINGPONG),
(UCX_PERF_CMD_TAG_SYNC, UCX_PERF_TEST_TYPE_STREAM_UNI)
);
return UCS_ERR_INVALID_PARAM;
}

static ucs_status_t ucp_perf_dispatch_stream(ucx_perf_context_t *perf)
{
UCS_PP_FOREACH(TEST_CASE_ALL_STREAM, perf,
(UCX_PERF_CMD_STREAM, UCX_PERF_TEST_TYPE_STREAM_UNI),
(UCX_PERF_CMD_STREAM, UCX_PERF_TEST_TYPE_PINGPONG)
);
(UCX_PERF_CMD_STREAM, UCX_PERF_TEST_TYPE_STREAM_UNI),
(UCX_PERF_CMD_STREAM, UCX_PERF_TEST_TYPE_PINGPONG)
);
return UCS_ERR_INVALID_PARAM;
}

static ucs_status_t ucp_perf_dispatch_am(ucx_perf_context_t *perf)
{
UCS_PP_FOREACH(TEST_CASE_ALL_AM, perf,
(UCX_PERF_CMD_AM, UCX_PERF_TEST_TYPE_PINGPONG),
(UCX_PERF_CMD_AM, UCX_PERF_TEST_TYPE_STREAM_UNI)
);
(UCX_PERF_CMD_AM, UCX_PERF_TEST_TYPE_PINGPONG),
(UCX_PERF_CMD_AM, UCX_PERF_TEST_TYPE_STREAM_UNI)
);
return UCS_ERR_INVALID_PARAM;
}

typedef ucs_status_t (*ucp_dispatch_func_t)(ucx_perf_context_t *perf);

static ucp_dispatch_func_t dispatchers[] = {
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO better use std::vector here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

please check again @Artemy-Mellanox

ucp_perf_dispatch_osd,
ucp_perf_dispatch_tag,
ucp_perf_dispatch_stream,
ucp_perf_dispatch_am
};

yosefe marked this conversation as resolved.
Show resolved Hide resolved
ucs_status_t ucp_perf_test_dispatch(ucx_perf_context_t *perf)
{
const size_t num_dispatchers = ucs_static_array_size(dispatchers);
ucs_status_t status;
ucp_dispatch_func_t *dispatcher;

ucs_carray_for_each(dispatcher, dispatchers, num_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,
Expand Down
8 changes: 4 additions & 4 deletions test/gtest/common/googletest/gtest.h
Original file line number Diff line number Diff line change
Expand Up @@ -1520,10 +1520,10 @@ inline bool operator!=(faketype, faketype) { return false; }

// The helper function for {ASSERT|EXPECT}_EQ.
template <typename T1, typename T2>
AssertionResult CmpHelperEQ(const char* lhs_expression,
const char* rhs_expression,
const T1& lhs,
const T2& rhs) {
GTEST_NO_INLINE_ AssertionResult CmpHelperEQ(const char* lhs_expression,
const char* rhs_expression,
const T1& lhs,
const T2& rhs) {
if (lhs == rhs) {
return AssertionSuccess();
}
Expand Down
114 changes: 27 additions & 87 deletions test/gtest/ucs/test_bitops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ extern "C" {
}

class test_bitops : public ucs::test {
protected:
static void
check_bitwise_equality(const uint8_t *buffer1, const uint8_t *buffer2,
const std::vector<int> &indices, int max_equal_index)
{
for (int i : indices) {
if (i <= max_equal_index) {
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, i));
} else {
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, i));
}
}
}
};

UCS_TEST_F(test_bitops, ffs32) {
Expand Down Expand Up @@ -91,111 +104,38 @@ UCS_TEST_F(test_bitops, ptr_ctz) {
}

UCS_TEST_F(test_bitops, is_equal) {
uint8_t buffer1[20] = {0};
uint8_t buffer2[20] = {0};

ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 0));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 1));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 8));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 64));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 65));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 128));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 130));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 159));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 160));
uint8_t buffer1[20] = {0};
uint8_t buffer2[20] = {0};
const std::vector<int> indices = {0, 1, 8, 64, 65, 128, 130, 159, 160};

buffer1[19] = 0x1; /* 00000001 */
test_bitops::check_bitwise_equality(buffer1, buffer2, indices, 160);

ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 0));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 1));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 8));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 64));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 65));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 128));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 130));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 159));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 160));
buffer1[19] = 0x1; /* 00000001 */
test_bitops::check_bitwise_equality(buffer1, buffer2, indices, 159);

buffer1[19] = 0x10; /* 00010000 */

ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 0));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 1));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 8));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 64));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 65));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 128));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 130));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 159));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 160));
test_bitops::check_bitwise_equality(buffer1, buffer2, indices, 130);

buffer1[16] = 0xff; /* 11111111 */

ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 0));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 1));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 8));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 64));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 65));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 128));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 130));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 159));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 160));
test_bitops::check_bitwise_equality(buffer1, buffer2, indices, 128);

buffer1[9] = 0xff; /* 11111111 */

ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 0));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 1));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 8));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 64));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 65));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 128));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 130));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 159));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 160));
test_bitops::check_bitwise_equality(buffer1, buffer2, indices, 65);

buffer1[7] = 0xff; /* 11111111 */

ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 0));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 1));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 8));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 64));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 65));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 128));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 130));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 159));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 160));
test_bitops::check_bitwise_equality(buffer1, buffer2, indices, 8);

buffer1[1] = 0xff; /* 11111111 */

ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 0));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 1));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 8));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 64));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 65));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 128));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 130));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 159));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 160));
test_bitops::check_bitwise_equality(buffer1, buffer2, indices, 8);

buffer1[0] = 0x1; /* 00000001 */

ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 0));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 1));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 8));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 64));
test_bitops::check_bitwise_equality(buffer1, buffer2, indices, 1);

buffer2[0] = 0x1; /* 00000001 */

ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 0));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 1));
ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 8));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 64));
test_bitops::check_bitwise_equality(buffer1, buffer2, indices, 8);

buffer2[0] = 0xff; /* 11111111 */

ASSERT_TRUE(ucs_bitwise_is_equal(buffer1, buffer2, 0));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 1));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 8));
ASSERT_FALSE(ucs_bitwise_is_equal(buffer1, buffer2, 64));
test_bitops::check_bitwise_equality(buffer1, buffer2, indices, 0);
}

template<typename Type> void test_mask()
Expand Down
5 changes: 3 additions & 2 deletions test/gtest/uct/ib/test_ud.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#include <uct/uct_test.h>

#include <vector>

extern "C" {
#include <ucs/time/time.h>
#include <ucs/datastruct/queue.h>
Expand Down Expand Up @@ -757,10 +759,9 @@ UCS_TEST_P(test_ud, connect_iface_sim2v2) {
* - flush() will also progress pending CREQs
*/
UCS_TEST_P(test_ud, connect_iface_2k) {

unsigned i;
unsigned cids[2000];
unsigned count = 2000 / ucs::test_time_multiplier();
std::vector<unsigned> cids(count, 0);

/* create 2k connections */
for (i = 0; i < count; i++) {
Expand Down
Loading