Skip to content

Commit c7e390f

Browse files
authored
Merge pull request #9765 from awlauria/8904_v5.0.x
v5.0.x: Improvements to MPI_Test and friends
2 parents b6dbae2 + 6093e38 commit c7e390f

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 ) {
@@ -86,9 +86,10 @@ int ompi_request_default_test(ompi_request_t ** rptr,
8686
* If we run the opal_progress then check the status of the request before
8787
* leaving. We will call the opal_progress only once per call.
8888
*/
89-
opal_progress();
90-
do_it_once++;
91-
goto recheck_request_status;
89+
++do_it_once;
90+
if (0 != opal_progress()) {
91+
goto recheck_request_status;
92+
}
9293
}
9394
#endif
9495
*completed = false;
@@ -183,15 +184,15 @@ int ompi_request_default_test_all(
183184
ompi_request_t **rptr;
184185
size_t num_completed = 0;
185186
ompi_request_t *request;
187+
int do_it_once = 0;
186188

187189
opal_atomic_mb();
188-
rptr = requests;
189-
for (i = 0; i < count; i++, rptr++) {
190-
request = *rptr;
190+
for (i = 0; i < count; i++) {
191+
request = requests[i];
191192

192-
if( request->req_state == OMPI_REQUEST_INACTIVE ||
193-
REQUEST_COMPLETE(request) ) {
193+
if( request->req_state == OMPI_REQUEST_INACTIVE || REQUEST_COMPLETE(request) ) {
194194
num_completed++;
195+
continue;
195196
}
196197
#if OPAL_ENABLE_FT_MPI
197198
/* Check for dead requests due to process failure */
@@ -206,13 +207,22 @@ int ompi_request_default_test_all(
206207
return MPI_ERR_PROC_FAILED_PENDING;
207208
}
208209
#endif /* OPAL_ENABLE_FT_MPI */
210+
#if OPAL_ENABLE_PROGRESS_THREADS == 0
211+
if (0 == do_it_once) {
212+
++do_it_once;
213+
if (0 != opal_progress()) {
214+
/* continue walking the list, retest the current request */
215+
--i;
216+
continue;
217+
}
218+
}
219+
#endif /* OPAL_ENABLE_PROGRESS_THREADS */
220+
/* short-circuit */
221+
break;
209222
}
210223

211224
if (num_completed != count) {
212225
*completed = false;
213-
#if OPAL_ENABLE_PROGRESS_THREADS == 0
214-
opal_progress();
215-
#endif
216226
return OMPI_SUCCESS;
217227
}
218228

@@ -318,6 +328,7 @@ int ompi_request_default_test_some(
318328
}
319329
if( REQUEST_COMPLETE(request) ) {
320330
indices[num_requests_done++] = i;
331+
continue;
321332
}
322333
#if OPAL_ENABLE_FT_MPI
323334
/* 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)