@@ -38,7 +38,7 @@ static const char FUNC_NAME[] = "MPI_Reduce_scatter";
38
38
int MPI_Reduce_scatter (void * sendbuf , void * recvbuf , int * recvcounts ,
39
39
MPI_Datatype datatype , MPI_Op op , MPI_Comm comm )
40
40
{
41
- int i , err , size ;
41
+ int i , err , size , count ;
42
42
43
43
if (MPI_PARAM_CHECK ) {
44
44
err = MPI_SUCCESS ;
@@ -67,13 +67,27 @@ int MPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
67
67
get the size of the remote group here for both intra- and
68
68
intercommunicators */
69
69
70
- size = ompi_comm_remote_size (comm );
70
+ size = ompi_comm_size (comm );
71
71
for (i = 0 ; i < size ; ++ i ) {
72
72
OMPI_CHECK_DATATYPE_FOR_SEND (err , datatype , recvcounts [i ]);
73
73
OMPI_ERRHANDLER_CHECK (err , comm , err , FUNC_NAME );
74
74
}
75
75
}
76
76
77
+ /* MPI-1, p114, says that each process must supply at least one
78
+ element. But at least the Pallas benchmarks call MPI_REDUCE
79
+ with a count of 0. So be sure to handle it. Grrr... */
80
+
81
+ size = ompi_comm_size (comm );
82
+ for (count = i = 0 ; i < size ; ++ i ) {
83
+ if (0 == recvcounts [i ]) {
84
+ ++ count ;
85
+ }
86
+ }
87
+ if (size == count ) {
88
+ return MPI_SUCCESS ;
89
+ }
90
+
77
91
/* Invoke the coll component to perform the back-end operation */
78
92
79
93
err = comm -> c_coll .coll_reduce_scatter (sendbuf , recvbuf , recvcounts ,
0 commit comments