From 2acb166bd7dd1147d0c2a0cf88983906daa290ef Mon Sep 17 00:00:00 2001 From: "raphael.bach" <raphael.bach@etu.hesge.ch> Date: Sun, 26 Jun 2022 22:06:51 +0200 Subject: [PATCH] Add `fmpi_mpi_world_gather_in_place()` --- include/internal/fmpi_mpi.h | 7 +++++++ src/fmpi_mpi.c | 25 ++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/include/internal/fmpi_mpi.h b/include/internal/fmpi_mpi.h index 5519e3b..91fbf91 100644 --- a/include/internal/fmpi_mpi.h +++ b/include/internal/fmpi_mpi.h @@ -216,6 +216,13 @@ int fmpi_mpi_gather_in_place( const struct fmpi_mpi_ctx * ctx, void * buf, MPI_Datatype type, size_t send_cnt, size_t recv_cnt, int root, MPI_Comm comm ); +/*------------------------------------------------------------------------------ + fmpi_mpi_world_gather_in_place() +------------------------------------------------------------------------------*/ +int fmpi_mpi_world_gather_in_place( + const struct fmpi_mpi_ctx * ctx, void * buf, MPI_Datatype type, + size_t send_cnt, size_t recv_cnt +); /*============================================================================== GUARD ==============================================================================*/ diff --git a/src/fmpi_mpi.c b/src/fmpi_mpi.c index 8229836..959b054 100644 --- a/src/fmpi_mpi.c +++ b/src/fmpi_mpi.c @@ -239,7 +239,7 @@ int fmpi_mpi_gather_in_place( if(ctx->rank == root) { err = MPI_Gather( MPI_IN_PLACE, (int)send_cnt, type, - buf , (int)recv_cnt, type, + buf , (int)recv_cnt, type, root, comm ); } else { @@ -251,3 +251,26 @@ int fmpi_mpi_gather_in_place( } return fmpi_mpi_check_error(ctx, err, "MPI_Gather"); } +/*------------------------------------------------------------------------------ + fmpi_mpi_world_gather_in_place() +------------------------------------------------------------------------------*/ +int fmpi_mpi_world_gather_in_place( + const struct fmpi_mpi_ctx * const ctx, void * const buf, MPI_Datatype type, + const size_t send_cnt, const size_t recv_cnt +){ + assert(ctx != NULL); + assert(buf != NULL); + assert(send_cnt <= INT_MAX); + assert(recv_cnt <= INT_MAX); + assert(send_cnt <= recv_cnt); + + const int err = fmpi_mpi_gather_in_place( + ctx, buf, type, send_cnt, recv_cnt, ctx->root, ctx->world + ); + if(err != FMPI_SUCCESS) { + FMPI_RAISE_ERROR(ctx->err_handler, "FMPI", + "fmpi_mpi_gather_in_place() failed!" + ); + } + return err; +} -- GitLab