1
1

Make MPI_REDUCE and MPI_REDUCE_SCATTER return MPI_SUCCESS immediately

if the count/sum of counts is 0.  This is technically in violation of
the MPI-1 standard, but...  :-(

This commit was SVN r6914.
Этот коммит содержится в:
Jeff Squyres 2005-08-17 15:34:33 +00:00
родитель 6a7bd04dec
Коммит e8c103ac1f
2 изменённых файлов: 24 добавлений и 2 удалений

Просмотреть файл

@ -71,6 +71,14 @@ int MPI_Reduce(void *sendbuf, void *recvbuf, int count,
} }
} }
/* MPI-1, p114, says that each process must supply at least
one element. But at least the Pallas benchmarks call
MPI_REDUCE with a count of 0. So be sure to handle it. */
if (0 == count) {
return MPI_SUCCESS;
}
/* Invoke the coll component to perform the back-end operation */ /* Invoke the coll component to perform the back-end operation */
err = comm->c_coll.coll_reduce(sendbuf, recvbuf, count, err = comm->c_coll.coll_reduce(sendbuf, recvbuf, count,

Просмотреть файл

@ -38,7 +38,7 @@ static const char FUNC_NAME[] = "MPI_Reduce_scatter";
int MPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts, int MPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
{ {
int i, err, size; int i, err, size, count;
if (MPI_PARAM_CHECK) { if (MPI_PARAM_CHECK) {
err = MPI_SUCCESS; err = MPI_SUCCESS;
@ -67,13 +67,27 @@ int MPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
get the size of the remote group here for both intra- and get the size of the remote group here for both intra- and
intercommunicators */ intercommunicators */
size = ompi_comm_remote_size(comm); size = ompi_comm_size(comm);
for (i = 0; i < size; ++i) { for (i = 0; i < size; ++i) {
OMPI_CHECK_DATATYPE_FOR_SEND(err, datatype, recvcounts[i]); OMPI_CHECK_DATATYPE_FOR_SEND(err, datatype, recvcounts[i]);
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
} }
} }
/* MPI-1, p114, says that each process must supply at least one
element. But at least the Pallas benchmarks call MPI_REDUCE
with a count of 0. So be sure to handle it. Grrr... */
size = ompi_comm_size(comm);
for (count = i = 0; i < size; ++i) {
if (0 == recvcounts[i]) {
++count;
}
}
if (size == count) {
return MPI_SUCCESS;
}
/* Invoke the coll component to perform the back-end operation */ /* Invoke the coll component to perform the back-end operation */
err = comm->c_coll.coll_reduce_scatter(sendbuf, recvbuf, recvcounts, err = comm->c_coll.coll_reduce_scatter(sendbuf, recvbuf, recvcounts,