diff --git a/ompi/mpi/c/allgather.c b/ompi/mpi/c/allgather.c index 2391fa76c8..7c824b657f 100644 --- a/ompi/mpi/c/allgather.c +++ b/ompi/mpi/c/allgather.c @@ -10,6 +10,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2010 University of Houston. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -89,12 +90,24 @@ int MPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype, /* Do we need to do anything? Everyone had to give the same send signature, which means that everyone must have given a - sendcount > 0 if there's anything to send. If we're doing - IN_PLACE, however, check recvcount, not sendcount. */ - - if ((MPI_IN_PLACE != sendbuf && 0 == sendcount) || - (0 == recvcount)) { - return MPI_SUCCESS; + sendcount > 0 if there's anything to send for the intra-communicator + case. If we're doing IN_PLACE, however, check recvcount, + not sendcount. */ + if ( OMPI_COMM_IS_INTRA(comm) ) { + if ((MPI_IN_PLACE != sendbuf && 0 == sendcount) || + (0 == recvcount)) { + return MPI_SUCCESS; + } + } + else if ( OMPI_COMM_IS_INTER(comm) ){ + /* for inter comunicators, the communication pattern + need not be symmetric. Specifically, one group is + allows to have sendcount=0, while the other has + a valid sendcount. Thus, the only way not to do + anything is if both sendcount and recvcount are zero. */ + if ( 0 == sendcount && 0 == recvcount ) { + return MPI_SUCCESS; + } } OPAL_CR_ENTER_LIBRARY(); diff --git a/ompi/mpi/c/allgatherv.c b/ompi/mpi/c/allgatherv.c index f3f8aa6955..f5605a7653 100644 --- a/ompi/mpi/c/allgatherv.c +++ b/ompi/mpi/c/allgatherv.c @@ -9,6 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2010 University of Houston. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -108,14 +109,22 @@ int MPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, signature, which means that everyone must have given a sum(recvounts) > 0 if there's anything to do. */ - for (i = 0; i < ompi_comm_size(comm); ++i) { - if (0 != recvcounts[i]) { - break; - } - } - if (i >= ompi_comm_size(comm)) { - return MPI_SUCCESS; + if ( OMPI_COMM_IS_INTRA( comm) ) { + for (i = 0; i < ompi_comm_size(comm); ++i) { + if (0 != recvcounts[i]) { + break; + } + } + if (i >= ompi_comm_size(comm)) { + return MPI_SUCCESS; + } } + /* There is no rule that can be applied for inter-communicators, since + recvcount(s)=0 only indicates that the processes in the other group + do not send anything, sendcount=0 only indicates that I do not send + anything. However, other processes in my group might very well send + something */ + OPAL_CR_ENTER_LIBRARY();