Skip to content

Commit d0308ee

Browse files
committed
Request test/wait: prevent continuation requests from being set to inactive
Continuation requests are persistent requests that are always active. They are implicitly restarted when the first continuation is registered. Signed-off-by: Joseph Schuchart <[email protected]>
1 parent 32fa3cc commit d0308ee

File tree

2 files changed

+87
-4
lines changed

2 files changed

+87
-4
lines changed

ompi/request/req_test.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ int ompi_request_default_test(ompi_request_t ** rptr,
6161
if (MPI_STATUS_IGNORE != status) {
6262
OMPI_COPY_STATUS(status, request->req_status, false);
6363
}
64+
65+
#if OMPI_HAVE_MPI_EXT_CONTINUE
66+
if (OMPI_REQUEST_CONT == request->req_type) {
67+
/* continuation requests are alwys active, don't modify the state */
68+
return request->req_status.MPI_ERROR;
69+
}
70+
#endif // OMPI_HAVE_MPI_EXT_CONTINUE
71+
6472
if( request->req_persistent ) {
6573
request->req_state = OMPI_REQUEST_INACTIVE;
6674
return request->req_status.MPI_ERROR;
@@ -146,6 +154,13 @@ int ompi_request_default_test_any(
146154
OMPI_COPY_STATUS(status, request->req_status, false);
147155
}
148156

157+
#if OMPI_HAVE_MPI_EXT_CONTINUE
158+
if (OMPI_REQUEST_CONT == request->req_type) {
159+
/* continuation requests are alwys active, don't modify the state */
160+
return OMPI_SUCCESS;
161+
}
162+
#endif // OMPI_HAVE_MPI_EXT_CONTINUE
163+
149164
if( request->req_persistent ) {
150165
request->req_state = OMPI_REQUEST_INACTIVE;
151166
return OMPI_SUCCESS;
@@ -279,6 +294,14 @@ int ompi_request_default_test_all(
279294
ompi_grequest_invoke_query(request, &request->req_status);
280295
}
281296
OMPI_COPY_STATUS(&statuses[i], request->req_status, true);
297+
298+
#if OMPI_HAVE_MPI_EXT_CONTINUE
299+
if (OMPI_REQUEST_CONT == request->req_type) {
300+
/* continuation requests are alwys active, don't modify the state */
301+
continue;
302+
}
303+
#endif // OMPI_HAVE_MPI_EXT_CONTINUE
304+
282305
if( request->req_persistent ) {
283306
request->req_state = OMPI_REQUEST_INACTIVE;
284307
continue;
@@ -314,6 +337,14 @@ int ompi_request_default_test_all(
314337
if (OMPI_REQUEST_GEN == request->req_type) {
315338
ompi_grequest_invoke_query(request, &request->req_status);
316339
}
340+
341+
#if OMPI_HAVE_MPI_EXT_CONTINUE
342+
if (OMPI_REQUEST_CONT == request->req_type) {
343+
/* continuation requests are alwys active, don't modify the state */
344+
continue;
345+
}
346+
#endif // OMPI_HAVE_MPI_EXT_CONTINUE
347+
317348
if( request->req_persistent ) {
318349
request->req_state = OMPI_REQUEST_INACTIVE;
319350
continue;
@@ -436,6 +467,13 @@ int ompi_request_default_test_some(
436467
#endif /* OPAL_ENABLE_FT_MPI */
437468
}
438469

470+
#if OMPI_HAVE_MPI_EXT_CONTINUE
471+
if (OMPI_REQUEST_CONT == request->req_type) {
472+
/* continuation requests are alwys active, don't modify the state */
473+
continue;
474+
}
475+
#endif // OMPI_HAVE_MPI_EXT_CONTINUE
476+
439477
if( request->req_persistent ) {
440478
request->req_state = OMPI_REQUEST_INACTIVE;
441479
} else {

ompi/request/req_wait.c

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,29 @@ int ompi_request_default_wait(
7777
if( MPI_STATUS_IGNORE != status ) {
7878
OMPI_COPY_STATUS(status, req->req_status, false);
7979
}
80+
81+
#if OMPI_HAVE_MPI_EXT_CONTINUE
82+
if (OMPI_REQUEST_CONT == req->req_type) {
83+
/* continuation requests are alwys active, don't modify the state */
84+
return req->req_status.MPI_ERROR;
85+
}
86+
#endif // OMPI_HAVE_MPI_EXT_CONTINUE
87+
8088
if( req->req_persistent ) {
8189
if( req->req_state == OMPI_REQUEST_INACTIVE ) {
8290
if (MPI_STATUS_IGNORE != status) {
8391
OMPI_COPY_STATUS(status, ompi_status_empty, false);
8492
}
8593
return OMPI_SUCCESS;
8694
}
95+
96+
#if OMPI_HAVE_MPI_EXT_CONTINUE
97+
if (OMPI_REQUEST_CONT == req->req_type) {
98+
/* continuation requests are alwys active, don't modify the state */
99+
return req->req_status.MPI_ERROR;
100+
}
101+
#endif // OMPI_HAVE_MPI_EXT_CONTINUE
102+
87103
req->req_state = OMPI_REQUEST_INACTIVE;
88104
return req->req_status.MPI_ERROR;
89105
}
@@ -220,7 +236,7 @@ int ompi_request_default_wait_any(size_t count,
220236
if( *index == (int)completed ) {
221237
/* Only one request has triggered. There was no in-flight
222238
* completions. Drop the signalled flag so we won't block
223-
* in WAIT_SYNC_RELEASE
239+
* in WAIT_SYNC_RELEASE
224240
*/
225241
WAIT_SYNC_SIGNALLED(&sync);
226242
}
@@ -244,7 +260,14 @@ int ompi_request_default_wait_any(size_t count,
244260
}
245261
rc = request->req_status.MPI_ERROR;
246262
if( request->req_persistent ) {
263+
#if OMPI_HAVE_MPI_EXT_CONTINUE
264+
if (OMPI_REQUEST_CONT != request->req_type) {
265+
request->req_state = OMPI_REQUEST_INACTIVE;
266+
}
267+
#else // OMPI_HAVE_MPI_EXT_CONTINUE
247268
request->req_state = OMPI_REQUEST_INACTIVE;
269+
#endif // OMPI_HAVE_MPI_EXT_CONTINUE
270+
248271
} else if (MPI_SUCCESS == rc) {
249272
/* Only free the request if there is no error on it */
250273
/* If there's an error while freeing the request,
@@ -400,6 +423,14 @@ int ompi_request_default_wait_all( size_t count,
400423

401424
OMPI_COPY_STATUS(&statuses[i], request->req_status, true);
402425

426+
427+
#if OMPI_HAVE_MPI_EXT_CONTINUE
428+
if (OMPI_REQUEST_CONT == request->req_type) {
429+
/* continuation requests are alwys active, don't modify the state */
430+
continue;
431+
}
432+
#endif // OMPI_HAVE_MPI_EXT_CONTINUE
433+
403434
if( request->req_persistent ) {
404435
request->req_state = OMPI_REQUEST_INACTIVE;
405436
continue;
@@ -471,6 +502,13 @@ int ompi_request_default_wait_all( size_t count,
471502

472503
rc = request->req_status.MPI_ERROR;
473504

505+
#if OMPI_HAVE_MPI_EXT_CONTINUE
506+
if (OMPI_REQUEST_CONT == request->req_type) {
507+
/* continuation requests are alwys active, don't modify the state */
508+
continue;
509+
}
510+
#endif // OMPI_HAVE_MPI_EXT_CONTINUE
511+
474512
if( request->req_persistent ) {
475513
request->req_state = OMPI_REQUEST_INACTIVE;
476514
} else if (MPI_SUCCESS == rc) {
@@ -602,14 +640,14 @@ int ompi_request_default_wait_some(size_t count,
602640
* a) request was found completed in the first loop
603641
* => ( indices[i] == 0 )
604642
* b) request was completed between first loop and this check
605-
* => ( indices[i] == 1 ) and we can NOT atomically mark the
643+
* => ( indices[i] == 1 ) and we can NOT atomically mark the
606644
* request as pending.
607645
* c) request wasn't finished yet
608-
* => ( indices[i] == 1 ) and we CAN atomically mark the
646+
* => ( indices[i] == 1 ) and we CAN atomically mark the
609647
* request as pending.
610648
* NOTE that in any case (i >= num_requests_done) as latter grows
611649
* either slowly (in case of partial completion)
612-
* OR in parallel with `i` (in case of full set completion)
650+
* OR in parallel with `i` (in case of full set completion)
613651
*/
614652
if( !indices[num_active_reqs] ) {
615653
indices[num_requests_done++] = i;
@@ -679,6 +717,13 @@ int ompi_request_default_wait_some(size_t count,
679717
rc = MPI_ERR_IN_STATUS;
680718
}
681719

720+
#if OMPI_HAVE_MPI_EXT_CONTINUE
721+
if (OMPI_REQUEST_CONT == request->req_type) {
722+
/* continuation requests are alwys active, don't modify the state */
723+
continue;
724+
}
725+
#endif // OMPI_HAVE_MPI_EXT_CONTINUE
726+
682727
if( request->req_persistent ) {
683728
request->req_state = OMPI_REQUEST_INACTIVE;
684729
} else {

0 commit comments

Comments
 (0)