Skip to content

Commit 91e1200

Browse files
committed
ompi/request: correctly handle zero count in ompi_request_default_wait_{all,any,some}
1 parent fb51d65 commit 91e1200

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ompi/request/req_wait.c

+16
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
1717
* reserved.
1818
* Copyright (c) 2016 Mellanox Technologies. All rights reserved.
19+
* Copyright (c) 2016 Research Organization for Information Science
20+
* and Technology (RIST). All rights reserved.
1921
* $COPYRIGHT$
2022
*
2123
* Additional copyrights may follow
@@ -89,6 +91,11 @@ int ompi_request_default_wait_any(size_t count,
8991
ompi_request_t *request=NULL;
9092
ompi_wait_sync_t sync;
9193

94+
if (OPAL_UNLIKELY(0 == count)) {
95+
*index = MPI_UNDEFINED;
96+
return OMPI_SUCCESS;
97+
}
98+
9299
WAIT_SYNC_INIT(&sync, 1);
93100

94101
num_requests_null_inactive = 0;
@@ -197,6 +204,10 @@ int ompi_request_default_wait_all( size_t count,
197204
int mpi_error = OMPI_SUCCESS;
198205
ompi_wait_sync_t sync;
199206

207+
if (OPAL_UNLIKELY(0 == count)) {
208+
return OMPI_SUCCESS;
209+
}
210+
200211
WAIT_SYNC_INIT(&sync, count);
201212
rptr = requests;
202213
for (i = 0; i < count; i++) {
@@ -374,6 +385,11 @@ int ompi_request_default_wait_some(size_t count,
374385
ompi_wait_sync_t sync;
375386
size_t sync_sets = 0, sync_unsets = 0;
376387

388+
if (OPAL_UNLIKELY(0 == count)) {
389+
*outcount = MPI_UNDEFINED;
390+
return OMPI_SUCCESS;
391+
}
392+
377393
WAIT_SYNC_INIT(&sync, 1);
378394

379395
*outcount = 0;

0 commit comments

Comments
 (0)