Skip to content

Commit 59bf1f0

Browse files
authored
Merge pull request #1836 from jjhursey/topic/coll-nbc-0-count-ireduce
mpi/c: Add each check for count==0 in nonblocking reduce interface
2 parents 9b4ed96 + 96779f6 commit 59bf1f0

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

ompi/mpi/c/iallreduce.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* reserved.
1515
* Copyright (c) 2015 Research Organization for Information Science
1616
* and Technology (RIST). All rights reserved.
17+
* Copyright (c) 2016 IBM Corporation. All rights reserved.
1718
* $COPYRIGHT$
1819
*
1920
* Additional copyrights may follow
@@ -94,6 +95,16 @@ int MPI_Iallreduce(const void *sendbuf, void *recvbuf, int count,
9495
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
9596
}
9697

98+
99+
/* MPI standard says that reductions have to have a count of at least 1,
100+
* but some benchmarks (e.g., IMB) calls this function with a count of 0.
101+
* So handle that case.
102+
*/
103+
if (0 == count) {
104+
*request = &ompi_request_empty;
105+
return MPI_SUCCESS;
106+
}
107+
97108
OPAL_CR_ENTER_LIBRARY();
98109

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

ompi/mpi/c/ireduce.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* reserved.
1616
* Copyright (c) 2015 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
18+
* Copyright (c) 2016 IBM Corporation. All rights reserved.
1819
* $COPYRIGHT$
1920
*
2021
* Additional copyrights may follow
@@ -120,6 +121,15 @@ int MPI_Ireduce(const void *sendbuf, void *recvbuf, int count,
120121
}
121122
}
122123

124+
/* MPI standard says that reductions have to have a count of at least 1,
125+
* but some benchmarks (e.g., IMB) calls this function with a count of 0.
126+
* So handle that case.
127+
*/
128+
if (0 == count) {
129+
*request = &ompi_request_empty;
130+
return MPI_SUCCESS;
131+
}
132+
123133
OPAL_CR_ENTER_LIBRARY();
124134

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

ompi/mpi/c/ireduce_scatter.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* reserved.
1616
* Copyright (c) 2015 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
18+
* Copyright (c) 2016 IBM Corporation. All rights reserved.
1819
* $COPYRIGHT$
1920
*
2021
* Additional copyrights may follow
@@ -45,7 +46,7 @@ static const char FUNC_NAME[] = "MPI_Ireduce_scatter";
4546
int MPI_Ireduce_scatter(const void *sendbuf, void *recvbuf, const int recvcounts[],
4647
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm, MPI_Request *request)
4748
{
48-
int i, err, size;
49+
int i, err, size, count;
4950

5051
MEMCHECKER(
5152
int rank;
@@ -110,6 +111,21 @@ int MPI_Ireduce_scatter(const void *sendbuf, void *recvbuf, const int recvcounts
110111
}
111112
}
112113

114+
/* MPI standard says that reductions have to have a count of at least 1,
115+
* but some benchmarks (e.g., IMB) calls this function with a count of 0.
116+
* So handle that case.
117+
*/
118+
size = ompi_comm_size(comm);
119+
for (count = i = 0; i < size; ++i) {
120+
if (0 == recvcounts[i]) {
121+
++count;
122+
}
123+
}
124+
if (size == count) {
125+
*request = &ompi_request_empty;
126+
return MPI_SUCCESS;
127+
}
128+
113129
OPAL_CR_ENTER_LIBRARY();
114130

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

0 commit comments

Comments
 (0)