From ca448021b42fde4a06bfab9aebebe00925c62d38 Mon Sep 17 00:00:00 2001 From: genaud Date: Tue, 30 Jun 2009 21:23:33 +0000 Subject: [PATCH 1/1] MPI_Allreduce() git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6407 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/smpi/smpi_mpi.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/smpi/smpi_mpi.c b/src/smpi/smpi_mpi.c index 730e3c8de6..f454c2765c 100644 --- a/src/smpi/smpi_mpi.c +++ b/src/smpi/smpi_mpi.c @@ -341,6 +341,32 @@ int SMPI_MPI_Reduce(void *sendbuf, void *recvbuf, int count, return retval; } +/** + * MPI_Allreduce + * + * Same as MPI_REDUCE except that the result appears in the receive buffer of all the group members. + **/ +int SMPI_MPI_Allreduce( void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, + MPI_Op op, MPI_Comm comm ) +{ + int retval = MPI_SUCCESS; + int root=0; // arbitrary choice + + smpi_bench_end(); + + retval = SMPI_MPI_Reduce( sendbuf, recvbuf, count, datatype, op, root, comm); + if (MPI_SUCCESS != retval) + return(retval); + retval = SMPI_MPI_Bcast( recvbuf, count, datatype, root, comm); + + smpi_bench_begin(); + return( retval ); +} + + + + + // used by comm_split to sort ranks based on key values int smpi_compare_rankkeys(const void *a, const void *b); int smpi_compare_rankkeys(const void *a, const void *b) -- 2.20.1