Skip to content

Commit 3117499

Browse files
committed
Make sure completed continuations requests are marked pending
Continuation requests may be marked as complete before another continuation is registered. In that case, we should mark the continuation request as pending again, unless a sync object has been registered already. Signed-off-by: Joseph Schuchart <schuchart@icl.utk.edu>
1 parent 6668a3b commit 3117499

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

ompi/mpiext/continue/c/continuation.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@ ompi_continuation_t *ompi_continue_cont_create(
605605
MPI_Status *cont_status,
606606
bool req_volatile)
607607
{
608+
const bool using_threads = opal_using_threads();
608609
ompi_continuation_t *cont;
609610
cont = (ompi_continuation_t *)opal_free_list_get(&ompi_continuation_freelist);
610611
cont->cont_req = cont_req;
@@ -618,10 +619,19 @@ ompi_continuation_t *ompi_continue_cont_create(
618619

619620
OPAL_THREAD_ADD_FETCH32(&cont_req->cont_num_active, 1);
620621

622+
/* if the continuation request was completed we mark it pending here */
623+
if (REQUEST_COMPLETE(&cont_req->super)) {
624+
if (using_threads) {
625+
intptr_t tmp = (intptr_t)REQUEST_COMPLETED;
626+
opal_atomic_compare_exchange_strong_ptr((intptr_t*)&cont_req->super.req_complete, &tmp, (intptr_t)REQUEST_PENDING);
627+
} else {
628+
cont_req->super.req_complete = REQUEST_PENDING;
629+
}
630+
}
631+
621632
/* if we don't have the requests we cannot handle oob errors,
622633
* so don't bother keeping the continuation around */
623634
if (!req_volatile) {
624-
const bool using_threads = opal_using_threads();
625635
if (using_threads) {
626636
opal_atomic_lock(&cont_req->cont_lock);
627637
}
@@ -998,7 +1008,10 @@ static int ompi_continue_request_start(size_t count, ompi_request_t** cont_req_p
9981008
&cont_req->cont_complete_defer_list);
9991009
}
10001010
cont_req->super.req_state = OMPI_REQUEST_ACTIVE;
1001-
cont_req->super.req_complete = REQUEST_PENDING;
1011+
/* TODO: is it correct to mark the cont_req pending once we
1012+
* register a new operation request?
1013+
*/
1014+
//cont_req->super.req_complete = REQUEST_PENDING;
10021015
if (using_threads) {
10031016
opal_atomic_unlock(&cont_req->cont_lock);
10041017
}

0 commit comments

Comments
 (0)