Skip to content

Commit 2497d7a

Browse files
authored
Merge pull request #8904 from devreal/mpi-test-recheck
Improvements to MPI_Test and friends
2 parents 17e3b48 + 7bc5848 commit 2497d7a

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

ompi/request/req_test.c

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int ompi_request_default_test(ompi_request_t ** rptr,
3535
#if OPAL_ENABLE_PROGRESS_THREADS == 0
3636
int do_it_once = 0;
3737

38-
recheck_request_status:
38+
recheck_request_status:
3939
#endif
4040
opal_atomic_mb();
4141
if( request->req_state == OMPI_REQUEST_INACTIVE ) {
@@ -94,9 +94,10 @@ int ompi_request_default_test(ompi_request_t ** rptr,
9494
* If we run the opal_progress then check the status of the request before
9595
* leaving. We will call the opal_progress only once per call.
9696
*/
97-
opal_progress();
98-
do_it_once++;
99-
goto recheck_request_status;
97+
++do_it_once;
98+
if (0 != opal_progress()) {
99+
goto recheck_request_status;
100+
}
100101
}
101102
#endif
102103
*completed = false;
@@ -201,15 +202,15 @@ int ompi_request_default_test_all(
201202
ompi_request_t **rptr;
202203
size_t num_completed = 0;
203204
ompi_request_t *request;
205+
int do_it_once = 0;
204206

205207
opal_atomic_mb();
206-
rptr = requests;
207-
for (i = 0; i < count; i++, rptr++) {
208-
request = *rptr;
208+
for (i = 0; i < count; i++) {
209+
request = requests[i];
209210

210-
if( request->req_state == OMPI_REQUEST_INACTIVE ||
211-
REQUEST_COMPLETE(request) ) {
211+
if( request->req_state == OMPI_REQUEST_INACTIVE || REQUEST_COMPLETE(request) ) {
212212
num_completed++;
213+
continue;
213214
}
214215
#if OPAL_ENABLE_FT_MPI
215216
/* Check for dead requests due to process failure */
@@ -224,13 +225,22 @@ int ompi_request_default_test_all(
224225
return MPI_ERR_PROC_FAILED_PENDING;
225226
}
226227
#endif /* OPAL_ENABLE_FT_MPI */
228+
#if OPAL_ENABLE_PROGRESS_THREADS == 0
229+
if (0 == do_it_once) {
230+
++do_it_once;
231+
if (0 != opal_progress()) {
232+
/* continue walking the list, retest the current request */
233+
--i;
234+
continue;
235+
}
236+
}
237+
#endif /* OPAL_ENABLE_PROGRESS_THREADS */
238+
/* short-circuit */
239+
break;
227240
}
228241

229242
if (num_completed != count) {
230243
*completed = false;
231-
#if OPAL_ENABLE_PROGRESS_THREADS == 0
232-
opal_progress();
233-
#endif
234244
return OMPI_SUCCESS;
235245
}
236246

@@ -336,6 +346,7 @@ int ompi_request_default_test_some(
336346
}
337347
if( REQUEST_COMPLETE(request) ) {
338348
indices[num_requests_done++] = i;
349+
continue;
339350
}
340351
#if OPAL_ENABLE_FT_MPI
341352
/* Check for dead requests due to process failure */

opal/runtime/opal_progress.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ static int opal_progress_events(void)
213213
* care, as the cost of that happening is far outweighed by the cost
214214
* of the if checks (they were resulting in bad pipe stalling behavior)
215215
*/
216-
void opal_progress(void)
216+
int opal_progress(void)
217217
{
218218
static uint32_t num_calls = 0;
219219
size_t i;
@@ -250,6 +250,8 @@ void opal_progress(void)
250250
*/
251251
opal_thread_yield();
252252
}
253+
254+
return events;
253255
}
254256

255257
int opal_progress_set_event_flag(int flag)

opal/runtime/opal_progress.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ OPAL_DECLSPEC int opal_progress_init(void);
5757
* opal_progress_event_users_delete()) or the time since the last call
5858
* into the event library is greater than the progress tick rate (by
5959
* default, 10ms).
60+
*
61+
* Returns 0 if no progress has been observed, non-zero otherwise.
6062
*/
61-
OPAL_DECLSPEC void opal_progress(void);
63+
OPAL_DECLSPEC int opal_progress(void);
6264

6365
/**
6466
* Control how the event library is called

0 commit comments

Comments
 (0)