Skip to content

Commit

Permalink
Skip sliding window gtest if exported memh is unsupported
Browse files Browse the repository at this point in the history
  • Loading branch information
nsarka committed Feb 29, 2024
1 parent 748c552 commit cc29ba2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
8 changes: 7 additions & 1 deletion test/gtest/coll/test_allreduce.cc
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ TYPED_TEST(test_allreduce_alg, sliding_window)
test_ucp_info_t *ucp_infos = NULL;
UccCollCtxVec ctxs;
std::vector<ucc_memory_type_t> mt = {UCC_MEMORY_TYPE_HOST};
ucs_status_t ucs_status = UCS_OK;

if (UCC_OK == ucc_mc_available(
UCC_MEMORY_TYPE_CUDA)) { //add cuda_managed for cl hier?
Expand All @@ -462,7 +463,12 @@ TYPED_TEST(test_allreduce_alg, sliding_window)
this->data_init(n_procs, TypeParam::dt, count, ctxs, true);

// set args->global_work_buffer on each ctx
setup_gwbi(n_procs, ctxs, &ucp_infos, inplace == TEST_INPLACE);
ucs_status = setup_gwbi(n_procs, ctxs, &ucp_infos, inplace == TEST_INPLACE);
if (ucs_status == UCS_ERR_UNSUPPORTED) {
free_gwbi(n_procs, ctxs, ucp_infos, inplace == TEST_INPLACE);
this->data_fini(ctxs);
GTEST_SKIP();
}

for (auto i = 0; i < repeat; i++) {
this->reset(ctxs);
Expand Down
41 changes: 25 additions & 16 deletions test/gtest/coll/test_allreduce_sliding_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,25 @@ ucs_status_t buffer_export_ucc(ucp_context_h ucp_context, void *buf, size_t len,
params.length = len;

ucs_status = ucp_mem_map(ucp_context, &params, &ebuf->memh);
EXPECT_EQ(UCS_OK, ucs_status) << "ucp_mem_map() returned error: "
<< ucs_status_string(ucs_status);
if (ucs_status != UCS_OK) {
printf("ucp_mem_map() returned error: %s\n", ucs_status_string(ucs_status));
return ucs_status;
}

pack_params.field_mask = UCP_MEMH_PACK_PARAM_FIELD_FLAGS;
pack_params.flags = UCP_MEMH_PACK_FLAG_EXPORT;

ucs_status = ucp_memh_pack(ebuf->memh, &pack_params, &ebuf->packed_memh,
&ebuf->packed_memh_len);
EXPECT_EQ(UCS_OK, ucs_status) << "ucp_memh_pack() returned error: "
<< ucs_status_string(ucs_status);
if (ucs_status != UCS_OK) {
printf("ucp_memh_pack() returned error: %s\n", ucs_status_string(ucs_status));
return ucs_status;
}

return ucs_status;
}

void setup_gwbi(int n_procs, UccCollCtxVec &ctxs,
ucs_status_t setup_gwbi(int n_procs, UccCollCtxVec &ctxs,
test_ucp_info_t **ucp_infos_p /* out */, bool inplace)
{
int i;
Expand Down Expand Up @@ -107,6 +111,8 @@ void setup_gwbi(int n_procs, UccCollCtxVec &ctxs,
ADD_FAILURE() << "test_init_ucp failed";
}
memcpy(&ucp_infos[i], &ucp_info, sizeof(test_ucp_info_t));
ucp_infos[i].src_ebuf = {0};
ucp_infos[i].dst_ebuf = {0};
}

// set up packed src/dst memh
Expand All @@ -124,8 +130,7 @@ void setup_gwbi(int n_procs, UccCollCtxVec &ctxs,
ucs_status = buffer_export_ucc(
ucp_info->ucp_ctx, ctxs[i]->args->dst.info.buffer,
dst_len, dst_ebuf);
ASSERT_EQ(UCS_OK, ucs_status) << "buffer_export_ucc() returned error: "
<< ucs_status_string(ucs_status);
if (ucs_status != UCS_OK) return ucs_status;

gwbi->packed_dst_memh = dst_ebuf->packed_memh;

Expand All @@ -136,9 +141,7 @@ void setup_gwbi(int n_procs, UccCollCtxVec &ctxs,
ucs_status = buffer_export_ucc(
ucp_info->ucp_ctx, ctxs[i]->args->src.info.buffer,
src_len, src_ebuf);
ASSERT_EQ(UCS_OK, ucs_status)
<< "buffer_export_ucc() returned error: "
<< ucs_status_string(ucs_status);
if (ucs_status != UCS_OK) return ucs_status;

gwbi->packed_src_memh = src_ebuf->packed_memh;
}
Expand All @@ -150,6 +153,8 @@ void setup_gwbi(int n_procs, UccCollCtxVec &ctxs,
UCC_COLL_ARGS_FIELD_FLAGS | UCC_COLL_ARGS_FIELD_GLOBAL_WORK_BUFFER;
ctx->args->flags |= UCC_COLL_ARGS_FLAG_MEM_MAPPED_BUFFERS;
}

return ucs_status;
}

void free_gwbi(int n_procs, UccCollCtxVec &ctxs, test_ucp_info_t *ucp_infos,
Expand All @@ -165,15 +170,19 @@ void free_gwbi(int n_procs, UccCollCtxVec &ctxs, test_ucp_info_t *ucp_infos,

if (!inplace) {
struct export_buf *src_ebuf = &ucp_info->src_ebuf;
ucs_status = ucp_mem_unmap(ucp_info->ucp_ctx, src_ebuf->memh);
ASSERT_EQ(UCS_OK, ucs_status) << "ucp_mem_unmap() returned error: "
<< ucs_status_string(ucs_status);
if (src_ebuf->memh != 0) {
ucs_status = ucp_mem_unmap(ucp_info->ucp_ctx, src_ebuf->memh);
ASSERT_EQ(UCS_OK, ucs_status) << "ucp_mem_unmap() returned error: "
<< ucs_status_string(ucs_status);
}
}

struct export_buf *dst_ebuf = &ucp_info->dst_ebuf;
ucs_status = ucp_mem_unmap(ucp_info->ucp_ctx, dst_ebuf->memh);
ASSERT_EQ(UCS_OK, ucs_status) << "ucp_mem_unmap() returned error: "
<< ucs_status_string(ucs_status);
if (dst_ebuf->memh != 0) {
ucs_status = ucp_mem_unmap(ucp_info->ucp_ctx, dst_ebuf->memh);
ASSERT_EQ(UCS_OK, ucs_status) << "ucp_mem_unmap() returned error: "
<< ucs_status_string(ucs_status);
}
}

// free ucp contexts
Expand Down
2 changes: 1 addition & 1 deletion test/gtest/coll/test_allreduce_sliding_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ typedef struct test_ucp_info_t {

void free_gwbi(int n_procs, UccCollCtxVec &ctxs, test_ucp_info_t *ucp_infos,
bool inplace);
void setup_gwbi(int n_procs, UccCollCtxVec &ctxs,
ucs_status_t setup_gwbi(int n_procs, UccCollCtxVec &ctxs,
test_ucp_info_t **ucp_infos_p /* out */, bool inplace);

#endif

0 comments on commit cc29ba2

Please sign in to comment.