From 373b666b90d0c3b6a60ff631d7af83c3d1ef8f98 Mon Sep 17 00:00:00 2001 From: Gengbin Zheng Date: Thu, 27 Jan 2022 11:47:29 -0600 Subject: [PATCH 1/7] ch4/coll: Add CVAR to select composition for Barrier --- src/mpid/ch4/src/ch4_coll.h | 67 +++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/src/mpid/ch4/src/ch4_coll.h b/src/mpid/ch4/src/ch4_coll.h index 3c96bc84672..6f1f5d25d71 100644 --- a/src/mpid/ch4/src/ch4_coll.h +++ b/src/mpid/ch4/src/ch4_coll.h @@ -10,7 +10,28 @@ #include "ch4_proc.h" #include "ch4_coll_impl.h" -MPL_STATIC_INLINE_PREFIX int MPID_Barrier(MPIR_Comm * comm, MPIR_Errflag_t * errflag) +/* +=== BEGIN_MPI_T_CVAR_INFO_BLOCK === + +cvars: + - name : MPIR_CVAR_BARRIER_COMPOSITION + category : COLLECTIVE + type : int + default : 0 + class : none + verbosity : MPI_T_VERBOSITY_USER_BASIC + scope : MPI_T_SCOPE_ALL_EQ + description : >- + Select composition (inter_node + intra_node) for Barrier + 0 Auto selection + 1 NM + SHM + 2 NM only + +=== END_MPI_T_CVAR_INFO_BLOCK === +*/ + +MPL_STATIC_INLINE_PREFIX int MPIDI_Barrier_allcomm_composition_json(MPIR_Comm * comm, + MPIR_Errflag_t * errflag) { int mpi_errno = MPI_SUCCESS; const MPIDI_Csel_container_s *cnt = NULL; @@ -20,8 +41,6 @@ MPL_STATIC_INLINE_PREFIX int MPID_Barrier(MPIR_Comm * comm, MPIR_Errflag_t * err .comm_ptr = comm, }; - MPIR_FUNC_ENTER; - cnt = MPIR_Csel_search(MPIDI_COMM(comm, csel_comm), coll_sig); if (cnt == NULL) { @@ -43,6 +62,48 @@ MPL_STATIC_INLINE_PREFIX int MPID_Barrier(MPIR_Comm * comm, MPIR_Errflag_t * err MPIR_ERR_CHECK(mpi_errno); + fn_exit: + return mpi_errno; + fn_fail: + goto fn_exit; +} + +MPL_STATIC_INLINE_PREFIX int MPID_Barrier(MPIR_Comm * comm, MPIR_Errflag_t * errflag) +{ + int mpi_errno = MPI_SUCCESS; + + MPIR_FUNC_ENTER; + + + switch (MPIR_CVAR_BARRIER_COMPOSITION) { + case 1: + MPII_COLLECTIVE_FALLBACK_CHECK(comm->rank, + (comm->comm_kind == MPIR_COMM_KIND__INTRACOMM) && + (comm->hierarchy_kind == + MPIR_COMM_HIERARCHY_KIND__PARENT), mpi_errno, + "Barrier composition alpha cannot be applied.\n"); + mpi_errno = MPIDI_Barrier_intra_composition_alpha(comm, errflag); + break; + case 2: + MPII_COLLECTIVE_FALLBACK_CHECK(comm->rank, + comm->comm_kind == MPIR_COMM_KIND__INTRACOMM, mpi_errno, + "Barrier composition beta cannot be applied.\n"); + mpi_errno = MPIDI_Barrier_intra_composition_beta(comm, errflag); + break; + default: + mpi_errno = MPIDI_Barrier_allcomm_composition_json(comm, errflag); + break; + } + + MPIR_ERR_CHECK(mpi_errno); + goto fn_exit; + + fallback: + if (comm->comm_kind == MPIR_COMM_KIND__INTERCOMM) + mpi_errno = MPIR_Barrier_impl(comm, errflag); + else + mpi_errno = MPIDI_Barrier_intra_composition_beta(comm, errflag); + fn_exit: MPIR_FUNC_EXIT; return mpi_errno; From 562dbfc7d89f1a5b84d9a4fdc0fcbc469b7beea9 Mon Sep 17 00:00:00 2001 From: Gengbin Zheng Date: Thu, 27 Jan 2022 13:42:54 -0600 Subject: [PATCH 2/7] ch4/coll: Add CVAR to select composition for Bcast --- src/mpid/ch4/src/ch4_coll.h | 77 +++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 4 deletions(-) diff --git a/src/mpid/ch4/src/ch4_coll.h b/src/mpid/ch4/src/ch4_coll.h index 6f1f5d25d71..409ae05e90c 100644 --- a/src/mpid/ch4/src/ch4_coll.h +++ b/src/mpid/ch4/src/ch4_coll.h @@ -27,6 +27,20 @@ 1 NM + SHM 2 NM only + - name : MPIR_CVAR_BCAST_COMPOSITION + category : COLLECTIVE + type : int + default : 0 + class : none + verbosity : MPI_T_VERBOSITY_USER_BASIC + scope : MPI_T_SCOPE_ALL_EQ + description : >- + Select composition (inter_node + intra_node) for Bcast + 0 Auto selection + 1 NM + SHM with explicit send-recv between rank 0 and root + 2 NM + SHM without the explicit send-recv + 3 NM only + === END_MPI_T_CVAR_INFO_BLOCK === */ @@ -111,8 +125,10 @@ MPL_STATIC_INLINE_PREFIX int MPID_Barrier(MPIR_Comm * comm, MPIR_Errflag_t * err goto fn_exit; } -MPL_STATIC_INLINE_PREFIX int MPID_Bcast(void *buffer, MPI_Aint count, MPI_Datatype datatype, - int root, MPIR_Comm * comm, MPIR_Errflag_t * errflag) +MPL_STATIC_INLINE_PREFIX int MPIDI_Bcast_allcomm_composition_json(void *buffer, MPI_Aint count, + MPI_Datatype datatype, int root, + MPIR_Comm * comm, + MPIR_Errflag_t * errflag) { int mpi_errno = MPI_SUCCESS; MPIR_Csel_coll_sig_s coll_sig = { @@ -126,8 +142,6 @@ MPL_STATIC_INLINE_PREFIX int MPID_Bcast(void *buffer, MPI_Aint count, MPI_Dataty const MPIDI_Csel_container_s *cnt = NULL; - MPIR_FUNC_ENTER; - cnt = MPIR_Csel_search(MPIDI_COMM(comm, csel_comm), coll_sig); if (cnt == NULL) { @@ -155,6 +169,61 @@ MPL_STATIC_INLINE_PREFIX int MPID_Bcast(void *buffer, MPI_Aint count, MPI_Dataty MPIR_ERR_CHECK(mpi_errno); + fn_exit: + return mpi_errno; + fn_fail: + goto fn_exit; +} + +MPL_STATIC_INLINE_PREFIX int MPID_Bcast(void *buffer, MPI_Aint count, MPI_Datatype datatype, + int root, MPIR_Comm * comm, MPIR_Errflag_t * errflag) +{ + int mpi_errno = MPI_SUCCESS; + + MPIR_FUNC_ENTER; + + switch (MPIR_CVAR_BCAST_COMPOSITION) { + case 1: + MPII_COLLECTIVE_FALLBACK_CHECK(comm->rank, + (comm->comm_kind == MPIR_COMM_KIND__INTRACOMM) && + (comm->hierarchy_kind == + MPIR_COMM_HIERARCHY_KIND__PARENT), mpi_errno, + "Bcast composition alpha cannot be applied.\n"); + mpi_errno = + MPIDI_Bcast_intra_composition_alpha(buffer, count, datatype, root, comm, errflag); + break; + case 2: + MPII_COLLECTIVE_FALLBACK_CHECK(comm->rank, + (comm->comm_kind == MPIR_COMM_KIND__INTRACOMM) && + (comm->hierarchy_kind == + MPIR_COMM_HIERARCHY_KIND__PARENT), mpi_errno, + "Bcast composition beta cannot be applied.\n"); + mpi_errno = + MPIDI_Bcast_intra_composition_beta(buffer, count, datatype, root, comm, errflag); + break; + case 3: + MPII_COLLECTIVE_FALLBACK_CHECK(comm->rank, + comm->comm_kind == MPIR_COMM_KIND__INTRACOMM, mpi_errno, + "Bcast composition gamma cannot be applied.\n"); + mpi_errno = + MPIDI_Bcast_intra_composition_gamma(buffer, count, datatype, root, comm, errflag); + break; + default: + mpi_errno = + MPIDI_Bcast_allcomm_composition_json(buffer, count, datatype, root, comm, errflag); + break; + } + + MPIR_ERR_CHECK(mpi_errno); + goto fn_exit; + + fallback: + if (comm->comm_kind == MPIR_COMM_KIND__INTERCOMM) + mpi_errno = MPIR_Bcast_impl(buffer, count, datatype, root, comm, errflag); + else + mpi_errno = + MPIDI_Bcast_intra_composition_gamma(buffer, count, datatype, root, comm, errflag); + fn_exit: MPIR_FUNC_EXIT; return mpi_errno; From c63ba23ca2b41d07fd4fbb9029fc88177cf688f2 Mon Sep 17 00:00:00 2001 From: Gengbin Zheng Date: Thu, 27 Jan 2022 14:57:40 -0600 Subject: [PATCH 3/7] ch4/coll: Add CVAR to select composition for Allreduce --- src/mpid/ch4/src/ch4_coll.h | 91 +++++++++++++++++++++++++++++++++++-- 1 file changed, 86 insertions(+), 5 deletions(-) diff --git a/src/mpid/ch4/src/ch4_coll.h b/src/mpid/ch4/src/ch4_coll.h index 409ae05e90c..53d99c82f6f 100644 --- a/src/mpid/ch4/src/ch4_coll.h +++ b/src/mpid/ch4/src/ch4_coll.h @@ -41,6 +41,20 @@ 2 NM + SHM without the explicit send-recv 3 NM only + - name : MPIR_CVAR_ALLREDUCE_COMPOSITION + category : COLLECTIVE + type : int + default : 0 + class : none + verbosity : MPI_T_VERBOSITY_USER_BASIC + scope : MPI_T_SCOPE_ALL_EQ + description : >- + Select composition (inter_node + intra_node) for Allreduce + 0 Auto selection + 1 NM + SHM with reduce + bcast + 2 NM only composition + 3 SHM only composition + === END_MPI_T_CVAR_INFO_BLOCK === */ @@ -231,9 +245,11 @@ MPL_STATIC_INLINE_PREFIX int MPID_Bcast(void *buffer, MPI_Aint count, MPI_Dataty goto fn_exit; } -MPL_STATIC_INLINE_PREFIX int MPID_Allreduce(const void *sendbuf, void *recvbuf, MPI_Aint count, - MPI_Datatype datatype, MPI_Op op, MPIR_Comm * comm, - MPIR_Errflag_t * errflag) +MPL_STATIC_INLINE_PREFIX int MPIDI_Allreduce_allcomm_composition_json(const void *sendbuf, + void *recvbuf, MPI_Aint count, + MPI_Datatype datatype, + MPI_Op op, MPIR_Comm * comm, + MPIR_Errflag_t * errflag) { int mpi_errno = MPI_SUCCESS; const MPIDI_Csel_container_s *cnt = NULL; @@ -249,8 +265,6 @@ MPL_STATIC_INLINE_PREFIX int MPID_Allreduce(const void *sendbuf, void *recvbuf, .u.allreduce.op = op, }; - MPIR_FUNC_ENTER; - cnt = MPIR_Csel_search(MPIDI_COMM(comm, csel_comm), coll_sig); if (cnt == NULL) { @@ -281,6 +295,72 @@ MPL_STATIC_INLINE_PREFIX int MPID_Allreduce(const void *sendbuf, void *recvbuf, MPIR_ERR_CHECK(mpi_errno); + fn_exit: + return mpi_errno; + fn_fail: + goto fn_exit; +} + +MPL_STATIC_INLINE_PREFIX int MPID_Allreduce(const void *sendbuf, void *recvbuf, MPI_Aint count, + MPI_Datatype datatype, MPI_Op op, MPIR_Comm * comm, + MPIR_Errflag_t * errflag) +{ + int mpi_errno = MPI_SUCCESS; + int is_commutative = -1; + + MPIR_FUNC_ENTER; + + is_commutative = MPIR_Op_is_commutative(op); + + switch (MPIR_CVAR_ALLREDUCE_COMPOSITION) { + case 1: + MPII_COLLECTIVE_FALLBACK_CHECK(comm->rank, + (comm->comm_kind == MPIR_COMM_KIND__INTRACOMM) && + (comm->hierarchy_kind == + MPIR_COMM_HIERARCHY_KIND__PARENT) && + is_commutative, mpi_errno, + "Allreduce composition alpha cannot be applied.\n"); + mpi_errno = + MPIDI_Allreduce_intra_composition_alpha(sendbuf, recvbuf, count, datatype, op, comm, + errflag); + break; + case 2: + MPII_COLLECTIVE_FALLBACK_CHECK(comm->rank, + comm->comm_kind == MPIR_COMM_KIND__INTRACOMM, mpi_errno, + "Allreduce composition beta cannot be applied.\n"); + mpi_errno = + MPIDI_Allreduce_intra_composition_beta(sendbuf, recvbuf, count, datatype, op, comm, + errflag); + break; + case 3: + MPII_COLLECTIVE_FALLBACK_CHECK(comm->rank, + (comm->comm_kind == MPIR_COMM_KIND__INTRACOMM) && + (comm->node_comm != NULL) && + (MPIR_Comm_size(comm) == + MPIR_Comm_size(comm->node_comm)), mpi_errno, + "Allreduce composition gamma cannot be applied.\n"); + mpi_errno = + MPIDI_Allreduce_intra_composition_gamma(sendbuf, recvbuf, count, datatype, op, comm, + errflag); + break; + default: + mpi_errno = + MPIDI_Allreduce_allcomm_composition_json(sendbuf, recvbuf, count, datatype, op, + comm, errflag); + break; + } + + MPIR_ERR_CHECK(mpi_errno); + goto fn_exit; + + fallback: + if (comm->comm_kind == MPIR_COMM_KIND__INTERCOMM) + mpi_errno = MPIR_Allreduce_impl(sendbuf, recvbuf, count, datatype, op, comm, errflag); + else + mpi_errno = + MPIDI_Allreduce_intra_composition_beta(sendbuf, recvbuf, count, datatype, op, comm, + errflag); + fn_exit: MPIR_FUNC_EXIT; return mpi_errno; @@ -288,6 +368,7 @@ MPL_STATIC_INLINE_PREFIX int MPID_Allreduce(const void *sendbuf, void *recvbuf, goto fn_exit; } + MPL_STATIC_INLINE_PREFIX int MPID_Allgather(const void *sendbuf, MPI_Aint sendcount, MPI_Datatype sendtype, void *recvbuf, MPI_Aint recvcount, MPI_Datatype recvtype, From f3eef9283648feb1977938395fc89da69b38bdf8 Mon Sep 17 00:00:00 2001 From: Gengbin Zheng Date: Wed, 2 Feb 2022 12:53:20 -0600 Subject: [PATCH 4/7] ch4/coll: Add CVAR to select composition for Allgather --- src/mpid/ch4/src/ch4_coll.h | 80 +++++++++++++++++++++++---- src/mpid/ch4/src/ch4_coll_impl.h | 16 +++--- src/mpid/ch4/src/ch4_csel_container.h | 1 + src/mpid/ch4/src/ch4_init.c | 3 + 4 files changed, 81 insertions(+), 19 deletions(-) diff --git a/src/mpid/ch4/src/ch4_coll.h b/src/mpid/ch4/src/ch4_coll.h index 53d99c82f6f..2d708b2e933 100644 --- a/src/mpid/ch4/src/ch4_coll.h +++ b/src/mpid/ch4/src/ch4_coll.h @@ -55,6 +55,19 @@ 2 NM only composition 3 SHM only composition + - name : MPIR_CVAR_ALLGATHER_COMPOSITION + category : COLLECTIVE + type : int + default : 0 + class : none + verbosity : MPI_T_VERBOSITY_USER_BASIC + scope : MPI_T_SCOPE_ALL_EQ + description : >- + Select composition (inter_node + intra_node) for Allgather + 0 Auto selection + 1 Multi leaders based inter node + intra node composition + 2 NM only composition + === END_MPI_T_CVAR_INFO_BLOCK === */ @@ -369,10 +382,14 @@ MPL_STATIC_INLINE_PREFIX int MPID_Allreduce(const void *sendbuf, void *recvbuf, } -MPL_STATIC_INLINE_PREFIX int MPID_Allgather(const void *sendbuf, MPI_Aint sendcount, - MPI_Datatype sendtype, void *recvbuf, - MPI_Aint recvcount, MPI_Datatype recvtype, - MPIR_Comm * comm, MPIR_Errflag_t * errflag) +MPL_STATIC_INLINE_PREFIX int MPIDI_Allgather_allcomm_composition_json(const void *sendbuf, + MPI_Aint sendcount, + MPI_Datatype sendtype, + void *recvbuf, + MPI_Aint recvcount, + MPI_Datatype recvtype, + MPIR_Comm * comm, + MPIR_Errflag_t * errflag) { int mpi_errno = MPI_SUCCESS; const MPIDI_Csel_container_s *cnt = NULL; @@ -389,8 +406,6 @@ MPL_STATIC_INLINE_PREFIX int MPID_Allgather(const void *sendbuf, MPI_Aint sendco .u.allgather.recvtype = recvtype, }; - MPIR_FUNC_ENTER; - cnt = MPIR_Csel_search(MPIDI_COMM(comm, csel_comm), coll_sig); if (cnt == NULL) { @@ -402,11 +417,10 @@ MPL_STATIC_INLINE_PREFIX int MPID_Allgather(const void *sendbuf, MPI_Aint sendco } switch (cnt->id) { - case MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Allgather_intra_composition_alpha: + case MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Allgather_intra_composition_beta: mpi_errno = - MPIDI_Allgather_intra_composition_alpha(sendbuf, sendcount, sendtype, - recvbuf, recvcount, recvtype, - comm, errflag); + MPIDI_Allgather_intra_composition_beta(sendbuf, sendcount, sendtype, + recvbuf, recvcount, recvtype, comm, errflag); break; default: MPIR_Assert(0); @@ -415,7 +429,51 @@ MPL_STATIC_INLINE_PREFIX int MPID_Allgather(const void *sendbuf, MPI_Aint sendco MPIR_ERR_CHECK(mpi_errno); fn_exit: - MPIR_FUNC_EXIT; + return mpi_errno; + fn_fail: + goto fn_exit; +} + +MPL_STATIC_INLINE_PREFIX int MPID_Allgather(const void *sendbuf, MPI_Aint sendcount, + MPI_Datatype sendtype, void *recvbuf, + MPI_Aint recvcount, MPI_Datatype recvtype, + MPIR_Comm * comm, MPIR_Errflag_t * errflag) +{ + int mpi_errno = MPI_SUCCESS; + + MPIR_FUNC_ENTER; + + switch (MPIR_CVAR_ALLGATHER_COMPOSITION) { + case 2: + MPII_COLLECTIVE_FALLBACK_CHECK(comm->rank, + comm->comm_kind == MPIR_COMM_KIND__INTRACOMM, mpi_errno, + "Allgather composition beta cannot be applied.\n"); + mpi_errno = + MPIDI_Allgather_intra_composition_beta(sendbuf, sendcount, sendtype, recvbuf, + recvcount, recvtype, comm, errflag); + break; + default: + mpi_errno = MPIDI_Allgather_allcomm_composition_json(sendbuf, sendcount, sendtype, + recvbuf, recvcount, recvtype, comm, + errflag); + break; + } + + MPIR_ERR_CHECK(mpi_errno); + goto fn_exit; + + fallback: + if (comm->comm_kind == MPIR_COMM_KIND__INTERCOMM) + mpi_errno = + MPIR_Allgather_impl(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm, + errflag); + else + mpi_errno = + MPIDI_Allgather_intra_composition_beta(sendbuf, sendcount, sendtype, recvbuf, recvcount, + recvtype, comm, errflag); + + fn_exit: + MPIR_FUNC_ENTER; return mpi_errno; fn_fail: goto fn_exit; diff --git a/src/mpid/ch4/src/ch4_coll_impl.h b/src/mpid/ch4/src/ch4_coll_impl.h index a145d3bfbb2..cb734dea7c3 100644 --- a/src/mpid/ch4/src/ch4_coll_impl.h +++ b/src/mpid/ch4/src/ch4_coll_impl.h @@ -642,14 +642,14 @@ MPL_STATIC_INLINE_PREFIX int MPIDI_Alltoallw_intra_composition_alpha(const void goto fn_exit; } -MPL_STATIC_INLINE_PREFIX int MPIDI_Allgather_intra_composition_alpha(const void *sendbuf, - MPI_Aint sendcount, - MPI_Datatype sendtype, - void *recvbuf, - MPI_Aint recvcount, - MPI_Datatype recvtype, - MPIR_Comm * comm_ptr, - MPIR_Errflag_t * errflag) +MPL_STATIC_INLINE_PREFIX int MPIDI_Allgather_intra_composition_beta(const void *sendbuf, + MPI_Aint sendcount, + MPI_Datatype sendtype, + void *recvbuf, + MPI_Aint recvcount, + MPI_Datatype recvtype, + MPIR_Comm * comm_ptr, + MPIR_Errflag_t * errflag) { int mpi_errno = MPI_SUCCESS; diff --git a/src/mpid/ch4/src/ch4_csel_container.h b/src/mpid/ch4/src/ch4_csel_container.h index 0d6dd7938f2..de888bc4877 100644 --- a/src/mpid/ch4/src/ch4_csel_container.h +++ b/src/mpid/ch4/src/ch4_csel_container.h @@ -23,6 +23,7 @@ typedef struct { MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Alltoallv_intra_composition_alpha, MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Alltoallw_intra_composition_alpha, MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Allgather_intra_composition_alpha, + MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Allgather_intra_composition_beta, MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Allgatherv_intra_composition_alpha, MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Gather_intra_composition_alpha, MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Gatherv_intra_composition_alpha, diff --git a/src/mpid/ch4/src/ch4_init.c b/src/mpid/ch4/src/ch4_init.c index cfafe7565bf..c1bc5417c24 100644 --- a/src/mpid/ch4/src/ch4_init.c +++ b/src/mpid/ch4/src/ch4_init.c @@ -151,6 +151,9 @@ static void *create_container(struct json_object *obj) else if (!strcmp(ckey, "composition=MPIDI_Allgather_intra_composition_alpha")) cnt->id = MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Allgather_intra_composition_alpha; + else if (!strcmp(ckey, "composition=MPIDI_Allgather_intra_composition_beta")) + cnt->id = + MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Allgather_intra_composition_beta; else if (!strcmp(ckey, "composition=MPIDI_Allgatherv_intra_composition_alpha")) cnt->id = MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Allgatherv_intra_composition_alpha; From 31aa52df66c83f7dcc96498a823190758b69540a Mon Sep 17 00:00:00 2001 From: Gengbin Zheng Date: Wed, 2 Feb 2022 15:07:39 -0600 Subject: [PATCH 5/7] ch4/coll: Add CVAR to select composition for Alltoall --- src/mpid/ch4/src/ch4_coll.h | 78 +++++++++++++++++++++++---- src/mpid/ch4/src/ch4_coll_impl.h | 16 +++--- src/mpid/ch4/src/ch4_csel_container.h | 1 + src/mpid/ch4/src/ch4_init.c | 2 + 4 files changed, 79 insertions(+), 18 deletions(-) diff --git a/src/mpid/ch4/src/ch4_coll.h b/src/mpid/ch4/src/ch4_coll.h index 2d708b2e933..704e695549e 100644 --- a/src/mpid/ch4/src/ch4_coll.h +++ b/src/mpid/ch4/src/ch4_coll.h @@ -68,6 +68,19 @@ 1 Multi leaders based inter node + intra node composition 2 NM only composition + - name : MPIR_CVAR_ALLTOALL_COMPOSITION + category : COLLECTIVE + type : int + default : 0 + class : none + verbosity : MPI_T_VERBOSITY_USER_BASIC + scope : MPI_T_SCOPE_ALL_EQ + description : >- + Select composition (inter_node + intra_node) for Alltoall + 0 Auto selection + 1 Multi leaders based inter node + intra node composition + 2 NM only composition + === END_MPI_T_CVAR_INFO_BLOCK === */ @@ -743,10 +756,14 @@ MPL_STATIC_INLINE_PREFIX int MPID_Gatherv(const void *sendbuf, MPI_Aint sendcoun goto fn_exit; } -MPL_STATIC_INLINE_PREFIX int MPID_Alltoall(const void *sendbuf, MPI_Aint sendcount, - MPI_Datatype sendtype, void *recvbuf, MPI_Aint recvcount, - MPI_Datatype recvtype, MPIR_Comm * comm, - MPIR_Errflag_t * errflag) +MPL_STATIC_INLINE_PREFIX int MPIDI_Alltoall_allcomm_composition_json(const void *sendbuf, + MPI_Aint sendcount, + MPI_Datatype sendtype, + void *recvbuf, + MPI_Aint recvcount, + MPI_Datatype recvtype, + MPIR_Comm * comm, + MPIR_Errflag_t * errflag) { int mpi_errno = MPI_SUCCESS; const MPIDI_Csel_container_s *cnt = NULL; @@ -763,8 +780,6 @@ MPL_STATIC_INLINE_PREFIX int MPID_Alltoall(const void *sendbuf, MPI_Aint sendcou .u.alltoall.recvtype = recvtype, }; - MPIR_FUNC_ENTER; - cnt = MPIR_Csel_search(MPIDI_COMM(comm, csel_comm), coll_sig); if (cnt == NULL) { @@ -775,10 +790,10 @@ MPL_STATIC_INLINE_PREFIX int MPID_Alltoall(const void *sendbuf, MPI_Aint sendcou } switch (cnt->id) { - case MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Alltoall_intra_composition_alpha: + case MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Alltoall_intra_composition_beta: mpi_errno = - MPIDI_Alltoall_intra_composition_alpha(sendbuf, sendcount, sendtype, - recvbuf, recvcount, recvtype, comm, errflag); + MPIDI_Alltoall_intra_composition_beta(sendbuf, sendcount, sendtype, + recvbuf, recvcount, recvtype, comm, errflag); break; default: MPIR_Assert(0); @@ -787,7 +802,50 @@ MPL_STATIC_INLINE_PREFIX int MPID_Alltoall(const void *sendbuf, MPI_Aint sendcou MPIR_ERR_CHECK(mpi_errno); fn_exit: - MPIR_FUNC_EXIT; + return mpi_errno; + fn_fail: + goto fn_exit; +} + +MPL_STATIC_INLINE_PREFIX int MPID_Alltoall(const void *sendbuf, MPI_Aint sendcount, + MPI_Datatype sendtype, void *recvbuf, MPI_Aint recvcount, + MPI_Datatype recvtype, MPIR_Comm * comm, + MPIR_Errflag_t * errflag) +{ + int mpi_errno = MPI_SUCCESS; + + MPIR_FUNC_ENTER; + + switch (MPIR_CVAR_ALLTOALL_COMPOSITION) { + case 2: + MPII_COLLECTIVE_FALLBACK_CHECK(comm->rank, + comm->comm_kind == MPIR_COMM_KIND__INTRACOMM, mpi_errno, + "Alltoall composition beta cannot be applied.\n"); + mpi_errno = + MPIDI_Alltoall_intra_composition_beta(sendbuf, sendcount, sendtype, recvbuf, + recvcount, recvtype, comm, errflag); + break; + default: + mpi_errno = MPIDI_Alltoall_allcomm_composition_json(sendbuf, sendcount, sendtype, + recvbuf, recvcount, recvtype, comm, + errflag); + break; + } + + MPIR_ERR_CHECK(mpi_errno); + goto fn_exit; + + fallback: + if (comm->comm_kind == MPIR_COMM_KIND__INTERCOMM) + mpi_errno = + MPIR_Alltoall_impl(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm, + errflag); + else + mpi_errno = MPIDI_Alltoall_intra_composition_beta(sendbuf, sendcount, sendtype, recvbuf, + recvcount, recvtype, comm, errflag); + + fn_exit: + MPIR_FUNC_ENTER; return mpi_errno; fn_fail: goto fn_exit; diff --git a/src/mpid/ch4/src/ch4_coll_impl.h b/src/mpid/ch4/src/ch4_coll_impl.h index cb734dea7c3..58132b232d6 100644 --- a/src/mpid/ch4/src/ch4_coll_impl.h +++ b/src/mpid/ch4/src/ch4_coll_impl.h @@ -569,14 +569,14 @@ MPL_STATIC_INLINE_PREFIX int MPIDI_Reduce_intra_composition_gamma(const void *se goto fn_exit; } -MPL_STATIC_INLINE_PREFIX int MPIDI_Alltoall_intra_composition_alpha(const void *sendbuf, - MPI_Aint sendcount, - MPI_Datatype sendtype, - void *recvbuf, - MPI_Aint recvcount, - MPI_Datatype recvtype, - MPIR_Comm * comm_ptr, - MPIR_Errflag_t * errflag) +MPL_STATIC_INLINE_PREFIX int MPIDI_Alltoall_intra_composition_beta(const void *sendbuf, + MPI_Aint sendcount, + MPI_Datatype sendtype, + void *recvbuf, + MPI_Aint recvcount, + MPI_Datatype recvtype, + MPIR_Comm * comm_ptr, + MPIR_Errflag_t * errflag) { int mpi_errno = MPI_SUCCESS; diff --git a/src/mpid/ch4/src/ch4_csel_container.h b/src/mpid/ch4/src/ch4_csel_container.h index de888bc4877..cd5144d3964 100644 --- a/src/mpid/ch4/src/ch4_csel_container.h +++ b/src/mpid/ch4/src/ch4_csel_container.h @@ -20,6 +20,7 @@ typedef struct { MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Allreduce_intra_composition_beta, MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Allreduce_intra_composition_gamma, MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Alltoall_intra_composition_alpha, + MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Alltoall_intra_composition_beta, MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Alltoallv_intra_composition_alpha, MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Alltoallw_intra_composition_alpha, MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Allgather_intra_composition_alpha, diff --git a/src/mpid/ch4/src/ch4_init.c b/src/mpid/ch4/src/ch4_init.c index c1bc5417c24..f3403b11338 100644 --- a/src/mpid/ch4/src/ch4_init.c +++ b/src/mpid/ch4/src/ch4_init.c @@ -142,6 +142,8 @@ static void *create_container(struct json_object *obj) else if (!strcmp(ckey, "composition=MPIDI_Alltoall_intra_composition_alpha")) cnt->id = MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Alltoall_intra_composition_alpha; + else if (!strcmp(ckey, "composition=MPIDI_Alltoall_intra_composition_beta")) + cnt->id = MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Alltoall_intra_composition_beta; else if (!strcmp(ckey, "composition=MPIDI_Alltoallv_intra_composition_alpha")) cnt->id = MPIDI_CSEL_CONTAINER_TYPE__COMPOSITION__MPIDI_Alltoallv_intra_composition_alpha; From 8c26428ac3242e1e2d56279c577bbf3c278e5a3f Mon Sep 17 00:00:00 2001 From: Gengbin Zheng Date: Wed, 2 Feb 2022 18:20:00 -0600 Subject: [PATCH 6/7] ch4/coll: Add CVAR to select composition for Reduce --- src/mpid/ch4/src/ch4_coll.h | 85 ++++++++++++++++++++++++++++++++++--- 1 file changed, 80 insertions(+), 5 deletions(-) diff --git a/src/mpid/ch4/src/ch4_coll.h b/src/mpid/ch4/src/ch4_coll.h index 704e695549e..f456466f7f1 100644 --- a/src/mpid/ch4/src/ch4_coll.h +++ b/src/mpid/ch4/src/ch4_coll.h @@ -81,6 +81,20 @@ 1 Multi leaders based inter node + intra node composition 2 NM only composition + - name : MPIR_CVAR_REDUCE_COMPOSITION + category : COLLECTIVE + type : int + default : 0 + class : none + verbosity : MPI_T_VERBOSITY_USER_BASIC + scope : MPI_T_SCOPE_ALL_EQ + description : >- + Select composition (inter_node + intra_node) for Reduce + 0 Auto selection + 1 NM + SHM with explicit send-recv between rank 0 and root + 2 NM + SHM without the explicit send-recv + 3 NM only + === END_MPI_T_CVAR_INFO_BLOCK === */ @@ -962,9 +976,11 @@ MPL_STATIC_INLINE_PREFIX int MPID_Alltoallw(const void *sendbuf, const MPI_Aint goto fn_exit; } -MPL_STATIC_INLINE_PREFIX int MPID_Reduce(const void *sendbuf, void *recvbuf, - MPI_Aint count, MPI_Datatype datatype, MPI_Op op, - int root, MPIR_Comm * comm, MPIR_Errflag_t * errflag) +MPL_STATIC_INLINE_PREFIX int MPIDI_Reduce_allcomm_composition_json(const void *sendbuf, + void *recvbuf, MPI_Aint count, + MPI_Datatype datatype, MPI_Op op, + int root, MPIR_Comm * comm, + MPIR_Errflag_t * errflag) { int mpi_errno = MPI_SUCCESS; const MPIDI_Csel_container_s *cnt = NULL; @@ -981,8 +997,6 @@ MPL_STATIC_INLINE_PREFIX int MPID_Reduce(const void *sendbuf, void *recvbuf, .u.reduce.root = root, }; - MPIR_FUNC_ENTER; - cnt = MPIR_Csel_search(MPIDI_COMM(comm, csel_comm), coll_sig); if (cnt == NULL) { @@ -1013,6 +1027,67 @@ MPL_STATIC_INLINE_PREFIX int MPID_Reduce(const void *sendbuf, void *recvbuf, MPIR_ERR_CHECK(mpi_errno); + fn_exit: + return mpi_errno; + fn_fail: + goto fn_exit; +} + +MPL_STATIC_INLINE_PREFIX int MPID_Reduce(const void *sendbuf, void *recvbuf, + MPI_Aint count, MPI_Datatype datatype, MPI_Op op, + int root, MPIR_Comm * comm, MPIR_Errflag_t * errflag) +{ + int mpi_errno = MPI_SUCCESS; + + MPIR_FUNC_ENTER; + + switch (MPIR_CVAR_REDUCE_COMPOSITION) { + case 1: + MPII_COLLECTIVE_FALLBACK_CHECK(comm->rank, comm->comm_kind == MPIR_COMM_KIND__INTRACOMM + && comm->hierarchy_kind == + MPIR_COMM_HIERARCHY_KIND__PARENT && + MPIR_Op_is_commutative(op), mpi_errno, + "Reduce composition alpha cannot be applied.\n"); + mpi_errno = + MPIDI_Reduce_intra_composition_alpha(sendbuf, recvbuf, count, datatype, op, root, + comm, errflag); + break; + case 2: + MPII_COLLECTIVE_FALLBACK_CHECK(comm->rank, comm->comm_kind == MPIR_COMM_KIND__INTRACOMM + && comm->hierarchy_kind == + MPIR_COMM_HIERARCHY_KIND__PARENT && + MPIR_Op_is_commutative(op), mpi_errno, + "Reduce composition beta cannot be applied.\n"); + mpi_errno = + MPIDI_Reduce_intra_composition_beta(sendbuf, recvbuf, count, datatype, op, root, + comm, errflag); + break; + case 3: + MPII_COLLECTIVE_FALLBACK_CHECK(comm->rank, + comm->comm_kind == MPIR_COMM_KIND__INTRACOMM, mpi_errno, + "Reduce composition gamma cannot be applied.\n"); + mpi_errno = + MPIDI_Reduce_intra_composition_gamma(sendbuf, recvbuf, count, datatype, op, root, + comm, errflag); + break; + default: + mpi_errno = + MPIDI_Reduce_allcomm_composition_json(sendbuf, recvbuf, count, datatype, op, + root, comm, errflag); + break; + } + + MPIR_ERR_CHECK(mpi_errno); + goto fn_exit; + + fallback: + if (comm->comm_kind == MPIR_COMM_KIND__INTERCOMM) + mpi_errno = MPIR_Reduce_impl(sendbuf, recvbuf, count, datatype, op, root, comm, errflag); + else + mpi_errno = + MPIDI_Reduce_intra_composition_gamma(sendbuf, recvbuf, count, datatype, op, root, comm, + errflag); + fn_exit: MPIR_FUNC_EXIT; return mpi_errno; From f0476629fb09a5bd274d707a40da99d55801eaf9 Mon Sep 17 00:00:00 2001 From: Gengbin Zheng Date: Thu, 3 Feb 2022 14:24:33 -0600 Subject: [PATCH 7/7] json: change Allgather/Alltoall composition to beta due to name change --- maint/tuning/coll/ch4/generic.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maint/tuning/coll/ch4/generic.json b/maint/tuning/coll/ch4/generic.json index 3e8c11de150..aa94ba85d5b 100644 --- a/maint/tuning/coll/ch4/generic.json +++ b/maint/tuning/coll/ch4/generic.json @@ -150,7 +150,7 @@ { "comm_type=intra": { - "composition=MPIDI_Alltoall_intra_composition_alpha":{} + "composition=MPIDI_Alltoall_intra_composition_beta":{} } }, "collective=alltoallv": @@ -171,7 +171,7 @@ { "comm_type=intra": { - "composition=MPIDI_Allgather_intra_composition_alpha":{} + "composition=MPIDI_Allgather_intra_composition_beta":{} } }, "collective=allgatherv":