diff --git a/ompi/mpi/c/iallreduce.c b/ompi/mpi/c/iallreduce.c index 0bceeb94b1..869325bc6d 100644 --- a/ompi/mpi/c/iallreduce.c +++ b/ompi/mpi/c/iallreduce.c @@ -14,6 +14,7 @@ * reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2016 IBM Corporation. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -94,6 +95,16 @@ int MPI_Iallreduce(const void *sendbuf, void *recvbuf, int count, OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); } + + /* MPI standard says that reductions have to have a count of at least 1, + * but some benchmarks (e.g., IMB) calls this function with a count of 0. + * So handle that case. + */ + if (0 == count) { + *request = &ompi_request_empty; + return MPI_SUCCESS; + } + OPAL_CR_ENTER_LIBRARY(); /* Invoke the coll component to perform the back-end operation */ diff --git a/ompi/mpi/c/ireduce.c b/ompi/mpi/c/ireduce.c index 1080655de4..fd6a89ad3b 100644 --- a/ompi/mpi/c/ireduce.c +++ b/ompi/mpi/c/ireduce.c @@ -15,6 +15,7 @@ * reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2016 IBM Corporation. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -120,6 +121,15 @@ int MPI_Ireduce(const void *sendbuf, void *recvbuf, int count, } } + /* MPI standard says that reductions have to have a count of at least 1, + * but some benchmarks (e.g., IMB) calls this function with a count of 0. + * So handle that case. + */ + if (0 == count) { + *request = &ompi_request_empty; + return MPI_SUCCESS; + } + OPAL_CR_ENTER_LIBRARY(); /* Invoke the coll component to perform the back-end operation */ diff --git a/ompi/mpi/c/ireduce_scatter.c b/ompi/mpi/c/ireduce_scatter.c index 61e7ab5751..a1194339f7 100644 --- a/ompi/mpi/c/ireduce_scatter.c +++ b/ompi/mpi/c/ireduce_scatter.c @@ -15,6 +15,7 @@ * reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. + * Copyright (c) 2016 IBM Corporation. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -45,7 +46,7 @@ static const char FUNC_NAME[] = "MPI_Ireduce_scatter"; int MPI_Ireduce_scatter(const void *sendbuf, void *recvbuf, const int recvcounts[], MPI_Datatype datatype, MPI_Op op, MPI_Comm comm, MPI_Request *request) { - int i, err, size; + int i, err, size, count; MEMCHECKER( int rank; @@ -110,6 +111,21 @@ int MPI_Ireduce_scatter(const void *sendbuf, void *recvbuf, const int recvcounts } } + /* MPI standard says that reductions have to have a count of at least 1, + * but some benchmarks (e.g., IMB) calls this function with a count of 0. + * So handle that case. + */ + size = ompi_comm_size(comm); + for (count = i = 0; i < size; ++i) { + if (0 == recvcounts[i]) { + ++count; + } + } + if (size == count) { + *request = &ompi_request_empty; + return MPI_SUCCESS; + } + OPAL_CR_ENTER_LIBRARY(); /* Invoke the coll component to perform the back-end operation */