From cc29ba29d7146a132a868b85a200bdbb9a2020f3 Mon Sep 17 00:00:00 2001 From: Nick Sarkauskas Date: Thu, 29 Feb 2024 10:35:41 -0800 Subject: [PATCH] Skip sliding window gtest if exported memh is unsupported --- test/gtest/coll/test_allreduce.cc | 8 +++- .../coll/test_allreduce_sliding_window.cc | 41 +++++++++++-------- .../coll/test_allreduce_sliding_window.h | 2 +- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/test/gtest/coll/test_allreduce.cc b/test/gtest/coll/test_allreduce.cc index 71b7df4f38..98c00dae3b 100644 --- a/test/gtest/coll/test_allreduce.cc +++ b/test/gtest/coll/test_allreduce.cc @@ -448,6 +448,7 @@ TYPED_TEST(test_allreduce_alg, sliding_window) test_ucp_info_t *ucp_infos = NULL; UccCollCtxVec ctxs; std::vector 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? @@ -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); diff --git a/test/gtest/coll/test_allreduce_sliding_window.cc b/test/gtest/coll/test_allreduce_sliding_window.cc index 79c8d9e105..389884e695 100644 --- a/test/gtest/coll/test_allreduce_sliding_window.cc +++ b/test/gtest/coll/test_allreduce_sliding_window.cc @@ -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, ¶ms, &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; @@ -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 @@ -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; @@ -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; } @@ -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, @@ -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 diff --git a/test/gtest/coll/test_allreduce_sliding_window.h b/test/gtest/coll/test_allreduce_sliding_window.h index b9b1339ad2..788ca70513 100644 --- a/test/gtest/coll/test_allreduce_sliding_window.h +++ b/test/gtest/coll/test_allreduce_sliding_window.h @@ -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