From 48fdcc6fca91be54771fc385d9d86e2c97e34eb5 Mon Sep 17 00:00:00 2001 From: "zhongsiping2@huawei.com" Date: Tue, 19 Sep 2023 19:41:51 +0800 Subject: [PATCH] [Huawei]update hmpi version to 1.3.1 --- ompi/mca/coll/ucg/coll_ucg.h | 26 ++++++------- ompi/mca/coll/ucg/coll_ucg_allgatherv.c | 2 +- ompi/mca/coll/ucg/coll_ucg_component.c | 4 +- ompi/mca/coll/ucg/coll_ucg_gatherv.c | 4 +- ompi/mca/coll/ucg/coll_ucg_module.c | 22 +++++------ ompi/mca/coll/ucg/coll_ucg_request.c | 50 ++++++++++++++++--------- ompi/mca/coll/ucg/coll_ucg_request.h | 8 ++-- ompi/mca/pml/ucx/pml_ucx_datatype.c | 25 ++++++++----- 8 files changed, 81 insertions(+), 60 deletions(-) diff --git a/ompi/mca/coll/ucg/coll_ucg.h b/ompi/mca/coll/ucg/coll_ucg.h index 57c154048a..3bcb266721 100644 --- a/ompi/mca/coll/ucg/coll_ucg.h +++ b/ompi/mca/coll/ucg/coll_ucg.h @@ -41,15 +41,15 @@ typedef struct { bool initialized; /** MCA parameter */ - int priority; /* Priority of this component */ - int verbose; /* Verbose level of this component */ - int max_rcache_size; /* Max size of request cache */ - char *disable_coll; /* JUST FOR TEST, may remove later */ - char *topology; /* Topology file path */ + int priority; /* Priority of this component */ + int verbose; /* Verbose level of this component */ + int max_rcache_size; /* Max size of request cache */ + char *disable_coll; /* JUST FOR TEST, may remove later */ + char *topology; /* Topology file path */ ucg_context_h ucg_context; - char **blacklist; /** disabled collective operations */ + char **blacklist; /** disabled collective operations */ } mca_coll_ucg_component_t; OMPI_MODULE_DECLSPEC extern mca_coll_ucg_component_t mca_coll_ucg_component; @@ -167,7 +167,7 @@ int mca_coll_ucg_ibcast(void *buffer, int count, MPI_Datatype datatype, int root mca_coll_base_module_t *module); int mca_coll_ucg_ibcast_cache(void *buffer, int count, MPI_Datatype datatype, int root, - ompi_communicator_t *comm, ompi_request_t **request, + ompi_communicator_t *comm, ompi_request_t **request, mca_coll_base_module_t *module); int mca_coll_ucg_bcast_init(void *buffer, int count, MPI_Datatype datatype, int root, @@ -186,10 +186,10 @@ int mca_coll_ucg_alltoallv_cache(const void *sbuf, const int *scounts, const int ompi_communicator_t *comm, mca_coll_base_module_t *module); int mca_coll_ucg_ialltoallv(const void *sbuf, const int *scounts, const int *sdispls, - ompi_datatype_t *sdtype, void *rbuf, const int *rcounts, - const int *rdispls, ompi_datatype_t *rdtype, - ompi_communicator_t *comm, ompi_request_t **request, - mca_coll_base_module_t *module); + ompi_datatype_t *sdtype, void *rbuf, const int *rcounts, + const int *rdispls, ompi_datatype_t *rdtype, + ompi_communicator_t *comm, ompi_request_t **request, + mca_coll_base_module_t *module); int mca_coll_ucg_ialltoallv_cache(const void *sbuf, const int *scounts, const int *sdispls, ompi_datatype_t *sdtype, void *rbuf, const int *rcounts, @@ -203,7 +203,7 @@ int mca_coll_ucg_alltoallv_init(const void *sbuf, const int *scounts, const int ompi_communicator_t *comm, ompi_info_t *info, ompi_request_t **request, mca_coll_base_module_t *module); -/* barrier */ +/*barrier */ int mca_coll_ucg_barrier(ompi_communicator_t *comm, mca_coll_base_module_t *module); int mca_coll_ucg_barrier_cache(ompi_communicator_t *comm, mca_coll_base_module_t *module); @@ -217,7 +217,7 @@ int mca_coll_ucg_ibarrier_cache(ompi_communicator_t *comm, ompi_request_t **requ int mca_coll_ucg_barrier_init(ompi_communicator_t *comm, ompi_info_t *info, ompi_request_t **request, mca_coll_base_module_t *module); -/* scatterv */ +/*scatterv */ int mca_coll_ucg_scatterv(const void *sbuf, const int *scounts, const int *disps, ompi_datatype_t *sdtype, void *rbuf, int rcount, ompi_datatype_t *rdtype, int root, diff --git a/ompi/mca/coll/ucg/coll_ucg_allgatherv.c b/ompi/mca/coll/ucg/coll_ucg_allgatherv.c index eed0d4b212..0bb25cba9a 100644 --- a/ompi/mca/coll/ucg/coll_ucg_allgatherv.c +++ b/ompi/mca/coll/ucg/coll_ucg_allgatherv.c @@ -1,7 +1,7 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2022-2022 Huawei Technologies Co., Ltd. - * All rights reserved. + * All rights reserved. * COPYRIGHT$ * * Additional copyrights may follow diff --git a/ompi/mca/coll/ucg/coll_ucg_component.c b/ompi/mca/coll/ucg/coll_ucg_component.c index e75e265147..ece53e4921 100644 --- a/ompi/mca/coll/ucg/coll_ucg_component.c +++ b/ompi/mca/coll/ucg/coll_ucg_component.c @@ -1,6 +1,6 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2022-2022 Huawei Technologies Co., Ltd. + * Copyright (c) 2022-2023 Huawei Technologies Co., Ltd. * All rights reserved. * COPYRIGHT$ * @@ -74,7 +74,7 @@ mca_coll_ucg_component_t mca_coll_ucg_component = { /* MCA parameter */ .priority = 90, /* priority */ .verbose = 2, /* verbose level */ - .max_rcache_size = 0, + .max_rcache_size = 1024, .disable_coll = NULL, .topology = NULL, diff --git a/ompi/mca/coll/ucg/coll_ucg_gatherv.c b/ompi/mca/coll/ucg/coll_ucg_gatherv.c index 6016e68b03..c1c347d989 100644 --- a/ompi/mca/coll/ucg/coll_ucg_gatherv.c +++ b/ompi/mca/coll/ucg/coll_ucg_gatherv.c @@ -228,8 +228,8 @@ int mca_coll_ucg_igatherv_cache(const void *sbuf, int sendcount, fallback: UCG_DEBUG("fallback igatherv"); return ucg_module->previous_igatherv(sbuf, sendcount, sdtype, rbuf, - recvcounts, disps, rdtype, root, comm, request, - ucg_module->previous_gatherv_module); + recvcounts, disps, rdtype, root, comm, request, + ucg_module->previous_gatherv_module); } int mca_coll_ucg_gatherv_init(const void *sbuf, int sendcount, diff --git a/ompi/mca/coll/ucg/coll_ucg_module.c b/ompi/mca/coll/ucg/coll_ucg_module.c index 9fdda8b08f..a97fbd702d 100644 --- a/ompi/mca/coll/ucg/coll_ucg_module.c +++ b/ompi/mca/coll/ucg/coll_ucg_module.c @@ -1,6 +1,6 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2022-2022 Huawei Technologies Co., Ltd. + * Copyright (c) 2022-2023 Huawei Technologies Co., Ltd. * All rights reserved. * COPYRIGHT$ * @@ -17,17 +17,17 @@ #include "ompi/mca/pml/pml.h" #include "ompi/mca/pml/ucx/pml_ucx.h" -/* Ensure coll ucg can be dlopened if global var "ompi_pml_ucx" is not existed*/ +/* Ensure coll ucg can be dlopened if global var "ompi_pml_ucx" is not existed */ mca_pml_ucx_module_t ompi_pml_ucx __attribute__((weak)); #define MCA_COLL_UCG_SET_HANDLER(_api) \ if (mca_coll_ucg_is_api_enable(#_api)) { \ - module->super.coll_ ## _api = mca_coll_ucg_ ## _api;\ + module->super.coll_ ## _api = mca_coll_ucg_ ## _api; \ } #define MCA_COLL_UCG_SET_CACHE_HANDLER(_api) \ if (mca_coll_ucg_is_api_enable(#_api)) { \ - module->super.coll_ ## _api = mca_coll_ucg_ ## _api ## _cache; \ + module->super.coll_ ## _api = mca_coll_ucg_ ## _api ## _cache; \ } #define MCA_COLL_UCG_SAVE_FALLBACK(_api) \ @@ -90,8 +90,8 @@ static ucg_status_t mca_coll_ucg_oob_blocking_allgather(const void *sendbuf, //bcast recvbuf to all rank for (i = 1; i < size; i++) { rc = MCA_PML_CALL(send((char *)recvbuf, size * count, MPI_CHAR, i, - MCA_COLL_BASE_TAG_ALLGATHER, - MCA_PML_BASE_SEND_STANDARD, comm)); + MCA_COLL_BASE_TAG_ALLGATHER, + MCA_PML_BASE_SEND_STANDARD, comm)); if (rc != OMPI_SUCCESS) { goto out; } @@ -99,15 +99,15 @@ static ucg_status_t mca_coll_ucg_oob_blocking_allgather(const void *sendbuf, } else { //send data to rank 0 rc = MCA_PML_CALL(send((char *)sendbuf, count, MPI_CHAR, 0, MCA_COLL_BASE_TAG_ALLGATHER, - MCA_PML_BASE_SEND_STANDARD, comm)); + MCA_PML_BASE_SEND_STANDARD, comm)); if (rc != OMPI_SUCCESS) { goto out; } //recv gather data from rank 0 rc = MCA_PML_CALL(recv((char *)recvbuf, size * count, MPI_CHAR, 0, - MCA_COLL_BASE_TAG_ALLGATHER, comm, - MPI_STATUS_IGNORE)); + MCA_COLL_BASE_TAG_ALLGATHER, comm, + MPI_STATUS_IGNORE)); if (rc != OMPI_SUCCESS) { goto out; } @@ -576,7 +576,7 @@ static void mca_coll_ucg_module_construct(mca_coll_ucg_module_t *module) MCA_COLL_UCG_SET_CACHE_HANDLER(barrier); MCA_COLL_UCG_SET_CACHE_HANDLER(bcast); MCA_COLL_UCG_SET_CACHE_HANDLER(alltoallv); - // MCA_COLL_UCG_SET_CACHE_HANDLER(scatterv); + MCA_COLL_UCG_SET_CACHE_HANDLER(scatterv); MCA_COLL_UCG_SET_CACHE_HANDLER(gatherv); MCA_COLL_UCG_SET_CACHE_HANDLER(allgatherv); @@ -592,7 +592,7 @@ static void mca_coll_ucg_module_construct(mca_coll_ucg_module_t *module) MCA_COLL_UCG_SET_HANDLER(barrier); MCA_COLL_UCG_SET_HANDLER(bcast); MCA_COLL_UCG_SET_HANDLER(alltoallv); - // MCA_COLL_UCG_SET_HANDLER(scatterv); + MCA_COLL_UCG_SET_HANDLER(scatterv); MCA_COLL_UCG_SET_HANDLER(gatherv); MCA_COLL_UCG_SET_HANDLER(allgatherv); diff --git a/ompi/mca/coll/ucg/coll_ucg_request.c b/ompi/mca/coll/ucg/coll_ucg_request.c index a39922adbc..d8825458ee 100644 --- a/ompi/mca/coll/ucg/coll_ucg_request.c +++ b/ompi/mca/coll/ucg/coll_ucg_request.c @@ -1,6 +1,6 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2022-2022 Huawei Technologies Co., Ltd. + * Copyright (c) 2022-2023 Huawei Technologies Co., Ltd. * All rights reserved. * COPYRIGHT$ * @@ -256,7 +256,7 @@ static void mca_coll_ucg_rcache_coll_req_args_init(mca_coll_ucg_args_t *dst, *dst = *src; int *scounts, *sdispls, *rcounts, *rdispls, *disps; uint32_t i, size = (uint32_t)ompi_comm_size(src->comm); - mca_coll_ucg_subargs_t *args = mca_coll_ucg_subargs_pool_get(); + mca_coll_ucg_subargs_t *args = NULL; switch (src->coll_type) { case MCA_COLL_UCG_TYPE_ALLTOALLV: @@ -267,6 +267,7 @@ static void mca_coll_ucg_rcache_coll_req_args_init(mca_coll_ucg_args_t *dst, src->alltoallv.rdispls == NULL) { return; } + args = mca_coll_ucg_subargs_pool_get(); scounts = args->buf; sdispls = scounts + size; rcounts = sdispls + size; @@ -285,9 +286,11 @@ static void mca_coll_ucg_rcache_coll_req_args_init(mca_coll_ucg_args_t *dst, case MCA_COLL_UCG_TYPE_SCATTERV: case MCA_COLL_UCG_TYPE_ISCATTERV: if (src->scatterv.scounts == NULL || - src->scatterv.disps == NULL) { + src->scatterv.disps == NULL || + ompi_comm_rank(src->comm) != src->scatterv.root) { return; } + args = mca_coll_ucg_subargs_pool_get(); scounts = args->buf; disps = scounts + size; for (i = 0; i < size; ++i) { @@ -299,10 +302,12 @@ static void mca_coll_ucg_rcache_coll_req_args_init(mca_coll_ucg_args_t *dst, break; case MCA_COLL_UCG_TYPE_GATHERV: case MCA_COLL_UCG_TYPE_IGATHERV: - if (src->gatherv.rcounts == NULL || - src->gatherv.disps == NULL) { + if (src->gatherv.rcounts == NULL || + src->gatherv.disps == NULL || + ompi_comm_rank(src->comm) != src->gatherv.root) { return; } + args = mca_coll_ucg_subargs_pool_get(); rcounts = args->buf; disps = rcounts + size; for (i = 0; i < size; ++i) { @@ -314,10 +319,11 @@ static void mca_coll_ucg_rcache_coll_req_args_init(mca_coll_ucg_args_t *dst, break; case MCA_COLL_UCG_TYPE_ALLGATHERV: case MCA_COLL_UCG_TYPE_IALLGATHERV: - if (src->allgatherv.rcounts == NULL || - src->allgatherv.disps == NULL) { + if (src->allgatherv.rcounts == NULL || + src->allgatherv.disps == NULL) { return; } + args = mca_coll_ucg_subargs_pool_get(); rcounts = args->buf; disps = rcounts + size; for (i = 0; i < size; ++i) { @@ -343,11 +349,15 @@ static void mca_coll_ucg_rcache_coll_req_args_uninit(mca_coll_ucg_args_t *args) break; case MCA_COLL_UCG_TYPE_SCATTERV: case MCA_COLL_UCG_TYPE_ISCATTERV: - buf = (void *)args->scatterv.scounts; + if (ompi_comm_rank(args->comm) == args->scatterv.root) { + buf = (void *)args->scatterv.scounts; + } break; case MCA_COLL_UCG_TYPE_GATHERV: case MCA_COLL_UCG_TYPE_IGATHERV: - buf = (void *)args->gatherv.rcounts; + if (ompi_comm_rank(args->comm) == args->gatherv.root) { + buf = (void *)args->gatherv.rcounts; + } break; case MCA_COLL_UCG_TYPE_ALLGATHERV: case MCA_COLL_UCG_TYPE_IALLGATHERV: @@ -367,7 +377,7 @@ void mca_coll_ucg_rcache_mark_cacheable(mca_coll_ucg_req_t *coll_req, mca_coll_ucg_args_t *key) { OBJ_CONSTRUCT(&coll_req->list, opal_list_item_t); - mca_coll_ucg_rcache_coll_req_args_init(&coll_req->args, key); // deep copy + mca_coll_ucg_rcache_coll_req_args_init(&coll_req->args, key); // deep copy ucg_coll_ucg_rcache_ref(coll_req); coll_req->cacheable = true; return; @@ -459,13 +469,16 @@ static bool mca_coll_ucg_rcache_is_same(const mca_coll_ucg_args_t *key1, case MCA_COLL_UCG_TYPE_ISCATTERV: { const mca_coll_scatterv_args_t *args1 = &key1->scatterv; const mca_coll_scatterv_args_t *args2 = &key2->scatterv; - is_same = args1->sbuf == args2->sbuf && - args1->sdtype == args2->sdtype && - args1->rbuf == args2->rbuf && + is_same = args1->rbuf == args2->rbuf && args1->rcount == args2->rcount && args1->rdtype == args2->rdtype && args1->root == args2->root; + if (ompi_comm_rank(key1->comm) != args1->root) { // Non-root processes don't compare send parms + break; + } is_same = is_same && + args1->sbuf == args2->sbuf && + args1->sdtype == args2->sdtype && mca_coll_ucg_rcache_compare(comm_size, args1->scounts, args2->scounts) && mca_coll_ucg_rcache_compare(comm_size, args1->disps, args2->disps); break; @@ -477,10 +490,13 @@ static bool mca_coll_ucg_rcache_is_same(const mca_coll_ucg_args_t *key1, is_same = args1->sbuf == args2->sbuf && args1->scount == args2->scount && args1->sdtype == args2->sdtype && - args1->rbuf == args2->rbuf && - args1->rdtype == args2->rdtype && args1->root == args2->root; + if (ompi_comm_rank(key1->comm) != args1->root) { // Non-root processes don't compare recv parms + break; + } is_same = is_same && + args1->rbuf == args2->rbuf && + args1->rdtype == args2->rdtype && mca_coll_ucg_rcache_compare(comm_size, args1->rcounts, args2->rcounts) && mca_coll_ucg_rcache_compare(comm_size, args1->disps, args2->disps); break; @@ -577,7 +593,7 @@ int mca_coll_ucg_request_common_init(mca_coll_ucg_req_t *coll_req, ucg_request_info_t *info = &coll_req->info; info->field_mask = 0; if (nb || persistent) { - // For those case, the request is not done in the current call stack. + //For those case, the request is not done in the current call stack. info->field_mask |= UCG_REQUEST_INFO_FIELD_CB; info->complete_cb.cb = mca_coll_ucg_request_complete; info->complete_cb.arg = coll_req; @@ -622,7 +638,7 @@ int mca_coll_ucg_request_execute(mca_coll_ucg_req_t *coll_req) int count = 0; while (UCG_INPROGRESS == (status = ucg_request_test(ucg_req))) { - // TODO: test wether opal_progress() can be removed + //TODO: test wether opal_progress() can be removed if (++count % 1000 == 0) { opal_progress(); } diff --git a/ompi/mca/coll/ucg/coll_ucg_request.h b/ompi/mca/coll/ucg/coll_ucg_request.h index 157329d1c0..f9b1aa9458 100644 --- a/ompi/mca/coll/ucg/coll_ucg_request.h +++ b/ompi/mca/coll/ucg/coll_ucg_request.h @@ -58,12 +58,12 @@ } while(0) /* - * Non-blockingexecution pattern: + * Non-blocking execution pattern: * 1. Initialize coll request * 2. Non-blocking execute * 3. Mark coll request cacheable * 4. Assign ompi request - * If any failure, goto fallback. + * If any failure, go to fallback. */ #define MCA_COLL_UCG_REQUEST_PATTERN_NB(_ompi_req, _cache_key, _coll_request_init, ...) \ do {\ @@ -126,12 +126,12 @@ typedef struct { typedef struct { opal_free_list_item_t super; int buf[]; -} mca_coll_ucg_subargs_t; +}mca_coll_ucg_subargs_t; OBJ_CLASS_DECLARATION(mca_coll_ucg_subargs_t); typedef struct { opal_free_list_t flist; -} mca_coll_ucg_subargs_pool_t; +}mca_coll_ucg_subargs_pool_t; typedef struct mca_coll_bcast_args { void *buffer; diff --git a/ompi/mca/pml/ucx/pml_ucx_datatype.c b/ompi/mca/pml/ucx/pml_ucx_datatype.c index 5b1b8ccbed..eabdb6a8a9 100644 --- a/ompi/mca/pml/ucx/pml_ucx_datatype.c +++ b/ompi/mca/pml/ucx/pml_ucx_datatype.c @@ -212,14 +212,21 @@ ucp_datatype_t mca_pml_ucx_init_datatype(ompi_datatype_t *datatype) ompi_datatype_type_size(datatype, &size); PML_UCX_ASSERT(size > 0); ucp_datatype = ucp_dt_make_contig(size); - goto out; - } - - status = ucp_dt_create_generic(&pml_ucx_generic_datatype_ops, - datatype, &ucp_datatype); - if (status != UCS_OK) { - PML_UCX_ERROR("Failed to create UCX datatype for %s", datatype->name); - ompi_mpi_abort(&ompi_mpi_comm_world.comm, 1); + PML_UCX_VERBOSE(7, "created contig UCX datatype 0x%"PRIx64, ucp_datatype) + } else { + status = ucp_dt_create_generic(&pml_ucx_generic_datatype_ops, + datatype, &ucp_datatype); + if (status != UCS_OK) { + int err = MPI_ERR_INTERN; + PML_UCX_ERROR("Failed to create UCX datatype for %s", datatype->name); + /* this error should return to the caller and invoke an error + * handler from the MPI API call. + * For now, it is fatal. */ + ompi_mpi_errors_are_fatal_comm_handler(NULL, &err, + "Failed to allocate " + "datatype structure"); + } + PML_UCX_VERBOSE(7, "created generic UCX datatype 0x%"PRIx64, ucp_datatype); } /* Add custom attribute, to clean up UCX resources when OMPI datatype is @@ -238,8 +245,6 @@ ucp_datatype_t mca_pml_ucx_init_datatype(ompi_datatype_t *datatype) ompi_mpi_abort(&ompi_mpi_comm_world.comm, 1); } } -out: - PML_UCX_VERBOSE(7, "created generic UCX datatype 0x%"PRIx64, ucp_datatype) #ifdef HAVE_UCP_REQUEST_PARAM_T UCS_STATIC_ASSERT(sizeof(datatype->pml_data) >= sizeof(pml_ucx_datatype_t*)); -- Gitee