Skip to content

Commit 931692f

Browse files
committed
Slight code cleanup and remove locks if threads are not enabled
Signed-off-by: Joseph Schuchart <[email protected]>
1 parent db2eae3 commit 931692f

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

ompi/mpiext/continue/c/continuation.c

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -627,42 +627,24 @@ ompi_continuation_t *ompi_continue_cont_create(
627627
/* signal that the continuation request has a new continuation */
628628
OBJ_RETAIN(cont_req);
629629

630-
opal_atomic_lock(&cont_req->cont_lock);
630+
if (using_threads) {
631+
opal_atomic_lock(&cont_req->cont_lock);
632+
}
631633
int prev_num_active = OPAL_THREAD_ADD_FETCH32(&cont_req->cont_num_active, 1);
632634

633635
/* if the continuation request was completed we mark it pending here */
634-
//if (REQUEST_COMPLETE(&cont_req->super)) {
635636
if (prev_num_active == 1) {
636-
//printf("PENDING cont_req %p cont %p\n", cont_req, cont);
637-
if (using_threads) {
638-
//opal_atomic_lock(&cont_req->cont_lock);
639-
//if (REQUEST_COMPLETE(&cont_req->super)) {
640-
cont_req->super.req_complete = REQUEST_PENDING;
641-
cont_req->super.req_complete_cb = NULL;
642-
//}
643-
/* NOTE: atomic operations not required here, we're protected by the lock */
644-
//intptr_t tmp = (intptr_t)REQUEST_COMPLETED;
645-
//opal_atomic_compare_exchange_strong_ptr((intptr_t*)&cont_req->super.req_complete, &tmp, (intptr_t)REQUEST_PENDING);
646-
//tmp = (intptr_t)REQUEST_CB_COMPLETED;
647-
//opal_atomic_compare_exchange_strong_ptr((intptr_t*)&cont_req->super.req_complete_cb, &tmp, (intptr_t)NULL);
648-
//opal_atomic_unlock(&cont_req->cont_lock);
649-
} else {
650-
cont_req->super.req_complete = REQUEST_PENDING;
651-
cont_req->super.req_complete_cb = NULL;
652-
}
637+
cont_req->super.req_complete = REQUEST_PENDING;
638+
cont_req->super.req_complete_cb = NULL;
653639
}
654-
opal_atomic_unlock(&cont_req->cont_lock);
655640

656641
/* if we don't have the requests we cannot handle oob errors,
657642
* so don't bother keeping the continuation around */
658643
if (!req_volatile) {
659-
if (using_threads) {
660-
opal_atomic_lock(&cont_req->cont_lock);
661-
}
662644
opal_list_append(&cont_req->cont_incomplete_list, &cont->super.super);
663-
if (using_threads) {
664-
opal_atomic_unlock(&cont_req->cont_lock);
665-
}
645+
}
646+
if (using_threads) {
647+
opal_atomic_unlock(&cont_req->cont_lock);
666648
}
667649

668650
return cont;

0 commit comments

Comments
 (0)