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

Commit 377955a

Browse files
committed
ompi/request: correctly handle zero count in ompi_request_default_wait_{all,any,some}
(cherry picked from commit open-mpi/ompi@91e1200)
1 parent edb35d5 commit 377955a

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;
@@ -192,6 +199,10 @@ int ompi_request_default_wait_all( size_t count,
192199
int mpi_error = OMPI_SUCCESS;
193200
ompi_wait_sync_t sync;
194201

202+
if (OPAL_UNLIKELY(0 == count)) {
203+
return OMPI_SUCCESS;
204+
}
205+
195206
WAIT_SYNC_INIT(&sync, count);
196207
rptr = requests;
197208
for (i = 0; i < count; i++) {
@@ -361,6 +372,11 @@ int ompi_request_default_wait_some(size_t count,
361372
ompi_wait_sync_t sync;
362373
size_t sync_sets = 0, sync_unsets = 0;
363374

375+
if (OPAL_UNLIKELY(0 == count)) {
376+
*outcount = MPI_UNDEFINED;
377+
return OMPI_SUCCESS;
378+
}
379+
364380
WAIT_SYNC_INIT(&sync, 1);
365381

366382
*outcount = 0;

0 commit comments

Comments
 (0)