Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit 7728484

Browse files
authored
Merge pull request #1254 from jjhursey/topic/v2.x-coll-nbc-0-count-ireduce
mpi/c: Add each check for count==0 in nonblocking reduce interface
2 parents 1bf2289 + 1d8870d commit 7728484

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

ompi/mpi/c/iallreduce.c

Lines changed: 10 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
@@ -93,6 +94,15 @@ int MPI_Iallreduce(const void *sendbuf, void *recvbuf, int count,
9394
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
9495
}
9596

97+
/* MPI standard says that reductions have to have a count of at least 1,
98+
* but some benchmarks (e.g., IMB) calls this function with a count of 0.
99+
* So handle that case.
100+
*/
101+
if (0 == count) {
102+
*request = &ompi_request_empty;
103+
return MPI_SUCCESS;
104+
}
105+
96106
/* Invoke the coll component to perform the back-end operation */
97107

98108
OBJ_RETAIN(op);

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
/* Invoke the coll component to perform the back-end operation */
124134
OBJ_RETAIN(op);
125135
err = comm->c_coll.coll_ireduce(sendbuf, recvbuf, count,

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
/* Invoke the coll component to perform the back-end operation */
114130

115131
OBJ_RETAIN(op);

0 commit comments

Comments
 (0)