Skip to content

Commit 8582e10

Browse files
bosilcajsquyres
authored andcommitted
Consistent handling of zero counts in the MPI API.
Signed-off-by: George Bosilca <bosilca@icl.utk.edu>
1 parent d712645 commit 8582e10

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

ompi/mpi/c/ibcast.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ int MPI_Ibcast(void *buffer, int count, MPI_Datatype datatype,
9696
}
9797
}
9898

99+
/* If there's only one node, or if the count is 0, we're done */
100+
101+
if ((OMPI_COMM_IS_INTRA(comm) && ompi_comm_size(comm) <= 1) ||
102+
0 == count) {
103+
return MPI_SUCCESS;
104+
}
105+
99106
OPAL_CR_ENTER_LIBRARY();
100107

101108
/* Invoke the coll component to perform the back-end operation */

ompi/mpi/c/ireduce_scatter_block.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ int MPI_Ireduce_scatter_block(const void *sendbuf, void *recvbuf, int recvcount,
9797
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
9898
}
9999

100+
if (0 == recvcount) {
101+
*request = &ompi_request_empty;
102+
return MPI_SUCCESS;
103+
}
104+
100105
OPAL_CR_ENTER_LIBRARY();
101106

102107
/* Invoke the coll component to perform the back-end operation */

ompi/mpi/c/reduce_scatter_block.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ int MPI_Reduce_scatter_block(const void *sendbuf, void *recvbuf, int recvcount,
9494
OMPI_CHECK_DATATYPE_FOR_SEND(err, datatype, recvcount);
9595
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
9696
}
97+
if (0 == recvcount) {
98+
return MPI_SUCCESS;
99+
}
97100

98101
OPAL_CR_ENTER_LIBRARY();
99102

0 commit comments

Comments
 (0)