Skip to content

Commit

Permalink
Consistent handling of zero counts in the MPI API.
Browse files Browse the repository at this point in the history
Signed-off-by: George Bosilca <[email protected]>
  • Loading branch information
bosilca authored and jsquyres committed Aug 24, 2020
1 parent d712645 commit 8582e10
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ompi/mpi/c/ibcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ int MPI_Ibcast(void *buffer, int count, MPI_Datatype datatype,
}
}

/* If there's only one node, or if the count is 0, we're done */

if ((OMPI_COMM_IS_INTRA(comm) && ompi_comm_size(comm) <= 1) ||
0 == count) {
return MPI_SUCCESS;
}

OPAL_CR_ENTER_LIBRARY();

/* Invoke the coll component to perform the back-end operation */
Expand Down
5 changes: 5 additions & 0 deletions ompi/mpi/c/ireduce_scatter_block.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ int MPI_Ireduce_scatter_block(const void *sendbuf, void *recvbuf, int recvcount,
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
}

if (0 == recvcount) {
*request = &ompi_request_empty;
return MPI_SUCCESS;
}

OPAL_CR_ENTER_LIBRARY();

/* Invoke the coll component to perform the back-end operation */
Expand Down
3 changes: 3 additions & 0 deletions ompi/mpi/c/reduce_scatter_block.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ int MPI_Reduce_scatter_block(const void *sendbuf, void *recvbuf, int recvcount,
OMPI_CHECK_DATATYPE_FOR_SEND(err, datatype, recvcount);
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
}
if (0 == recvcount) {
return MPI_SUCCESS;
}

OPAL_CR_ENTER_LIBRARY();

Expand Down

0 comments on commit 8582e10

Please sign in to comment.