Skip to content

Commit 664f694

Browse files
committed
UCP/TEST: Add cuda_ipc tests in ucp and uct gtests
1 parent 00cac8e commit 664f694

5 files changed

Lines changed: 77 additions & 19 deletions

File tree

test/gtest/ucp/test_ucp_proto_mock.cc

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,75 @@ UCS_TEST_P(test_ucp_proto_mock_gpu, cuda_managed_ppln_host_frag,
948948
UCP_INSTANTIATE_TEST_CASE_TLS(test_ucp_proto_mock_gpu, rcx_gpu,
949949
"rc_x,cuda,rocm")
950950

951+
class test_ucp_proto_mock_cuda_ipc : public test_ucp_proto_mock {
952+
public:
953+
test_ucp_proto_mock_cuda_ipc()
954+
{
955+
mock_transport("rc_mlx5");
956+
}
957+
958+
virtual void init() override
959+
{
960+
if (!mem_buffer::is_mem_type_supported(UCS_MEMORY_TYPE_CUDA)) {
961+
UCS_TEST_SKIP_R("CUDA memory is not supported");
962+
}
963+
964+
add_mock_iface("mock", [](uct_iface_attr_t &iface_attr) {
965+
iface_attr.bandwidth.shared = 40e9;
966+
iface_attr.latency.c = 400e-9;
967+
iface_attr.latency.m = 1e-9;
968+
});
969+
970+
test_ucp_proto_mock::init();
971+
}
972+
973+
ucp_worker_cfg_index_t find_rkey_cfg_index(ucs_memory_type_t mem_type)
974+
{
975+
ucp_worker_h worker = sender().worker();
976+
ucp_proto_select_key_t sel_key;
977+
ucp_rkey_config_t *rkey_config;
978+
979+
/* Find rkey config with required mem_type for local and remote
980+
* memory */
981+
for (auto i = 0; i < ucs_array_length(&worker->rkey_config); ++i) {
982+
rkey_config = &ucs_array_elem(&worker->rkey_config, i);
983+
984+
if (rkey_config->key.mem_type != mem_type) {
985+
continue;
986+
}
987+
988+
kh_foreach_key(rkey_config->proto_select.hash, sel_key.u64, {
989+
if (sel_key.param.mem_type == mem_type) {
990+
return i;
991+
}
992+
})
993+
}
994+
995+
return UCP_WORKER_CFG_INDEX_NULL;
996+
}
997+
};
998+
999+
UCS_TEST_P(test_ucp_proto_mock_cuda_ipc, put_cuda, "IB_NUM_PATHS?=1")
1000+
{
1001+
send_recv_rma_put(UCS_MBYTE, UCS_MEMORY_TYPE_CUDA);
1002+
1003+
ucp_proto_select_key_t key = any_key();
1004+
key.param.op_id_flags = UCP_OP_ID_PUT;
1005+
key.param.op_attr = 0;
1006+
key.param.mem_type = UCS_MEMORY_TYPE_CUDA;
1007+
1008+
auto rkey_cfg_index = find_rkey_cfg_index(UCS_MEMORY_TYPE_CUDA);
1009+
ASSERT_NE(rkey_cfg_index, UCP_WORKER_CFG_INDEX_NULL);
1010+
1011+
check_rkey_config(sender(), {
1012+
{0, 0, "short", "rc_mlx5/mock"},
1013+
{1, INF, "zero-copy", "cuda_ipc/cuda"},
1014+
}, key, rkey_cfg_index);
1015+
}
1016+
1017+
UCP_INSTANTIATE_TEST_CASE_TLS_GPU_AWARE(test_ucp_proto_mock_cuda_ipc,
1018+
shm_ib_ipc, "shm,ib,cuda_ipc,rocm_ipc")
1019+
9511020
class test_ucp_proto_mock_rcx_twins : public test_ucp_proto_mock {
9521021
public:
9531022
test_ucp_proto_mock_rcx_twins()

test/gtest/uct/test_uct_ep.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,4 +282,3 @@ UCS_TEST_SKIP_COND_P(test_uct_ep, destroy_entity_after_send,
282282
}
283283

284284
UCT_INSTANTIATE_TEST_CASE(test_uct_ep)
285-
UCT_INSTANTIATE_CUDA_IPC_TEST_CASE(test_uct_ep)

test/gtest/uct/test_uct_iface.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,3 @@ UCS_TEST_P(test_uct_iface, is_reachable)
9393
}
9494

9595
UCT_INSTANTIATE_TEST_CASE(test_uct_iface)
96-
UCT_INSTANTIATE_CUDA_IPC_TEST_CASE(test_uct_iface)

test/gtest/uct/uct_p2p_test.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ void uct_p2p_test::test_xfer_multi_mem_type(send_func_t send, size_t min_length,
177177

178178
/* Trim at the max allocation available. Divide by 2 for
179179
2 buffers + 0.5 for spare capacity */
180-
max_length = ucs_min(max_length, sender().md_attr().max_alloc / 2.5);
180+
if (sender().md_attr().max_alloc > 0) {
181+
max_length = ucs_min(max_length, sender().md_attr().max_alloc / 2.5);
182+
}
181183

182184
/* Trim at 4.1 GB */
183185
max_length = ucs_min(max_length, (size_t)(4.1 * (double)UCS_GBYTE));

test/gtest/uct/uct_test.h

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,8 @@ class test_uct_iface_attrs : public uct_test {
502502

503503
#define UCT_TEST_CUDA_MEM_TYPE_TLS \
504504
cuda_copy, \
505-
gdr_copy
505+
gdr_copy, \
506+
cuda_ipc
506507

507508
#define UCT_TEST_ROCM_MEM_TYPE_TLS \
508509
rocm_copy
@@ -511,18 +512,16 @@ class test_uct_iface_attrs : public uct_test {
511512
UCT_TEST_NO_SELF_TLS, \
512513
self
513514

514-
#define UCT_TEST_TLS \
515-
UCT_TEST_NO_GPU_MEM_TYPE_TLS, \
516-
UCT_TEST_ROCM_MEM_TYPE_TLS, \
517-
UCT_TEST_CUDA_MEM_TYPE_TLS
518515

519516
/**
520517
* Instantiate the parametrized test case for all transports.
521518
*
522519
* @param _test_case Test case class, derived from uct_test.
523520
*/
524521
#define UCT_INSTANTIATE_TEST_CASE(_test_case) \
525-
UCS_PP_FOREACH(_UCT_INSTANTIATE_TEST_CASE, _test_case, UCT_TEST_TLS)
522+
UCS_PP_FOREACH(_UCT_INSTANTIATE_TEST_CASE, _test_case, UCT_TEST_NO_GPU_MEM_TYPE_TLS) \
523+
UCS_PP_FOREACH(_UCT_INSTANTIATE_TEST_CASE, _test_case, UCT_TEST_ROCM_MEM_TYPE_TLS) \
524+
UCS_PP_FOREACH(_UCT_INSTANTIATE_TEST_CASE, _test_case, UCT_TEST_CUDA_MEM_TYPE_TLS)
526525
#define _UCT_INSTANTIATE_TEST_CASE(_test_case, _tl_name) \
527526
INSTANTIATE_TEST_SUITE_P(_tl_name, _test_case, \
528527
testing::ValuesIn(_test_case::enum_resources(UCS_PP_QUOTE(_tl_name))));
@@ -618,16 +617,6 @@ class test_uct_iface_attrs : public uct_test {
618617
_UCT_INSTANTIATE_TEST_CASE(_test_case, gga_mlx5)
619618

620619

621-
/**
622-
* Instantiate the parametrized test case for CUDA_IPC.
623-
* TODO: add cuda_ipc to UCT_INSTANTIATE_TEST_CASE.
624-
*
625-
* @param _test_case Test case class, derived from uct_test.
626-
*/
627-
#define UCT_INSTANTIATE_CUDA_IPC_TEST_CASE(_test_case) \
628-
_UCT_INSTANTIATE_TEST_CASE(_test_case, cuda_ipc)
629-
630-
631620
/**
632621
* Instantiate the parametrized test case for the SRD transports
633622
*

0 commit comments

Comments
 (0)