Skip to content

Commit 1de67af

Browse files
committed
Cleanup sync object handling in ompi_request_complete
It's sufficient to swap the req_complete with REQUEST_COMPLETED and look at the original value to decide whether a sync object was there. No need to first CAS and then swap. Signed-off-by: Joseph Schuchart <schuchart@icl.utk.edu>
1 parent c6180c0 commit 1de67af

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

ompi/request/request.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -537,18 +537,16 @@ static inline int ompi_request_complete(ompi_request_t* request, bool with_signa
537537
}
538538

539539
if (0 == rc) {
540-
if( OPAL_LIKELY(with_signal) ) {
541-
void *_tmp_ptr = REQUEST_PENDING;
542-
543-
if(!OPAL_ATOMIC_COMPARE_EXCHANGE_STRONG_PTR(&request->req_complete, &_tmp_ptr, REQUEST_COMPLETED)) {
544-
ompi_wait_sync_t *tmp_sync = (ompi_wait_sync_t *) OPAL_ATOMIC_SWAP_PTR(&request->req_complete,
545-
REQUEST_COMPLETED);
546-
/* In the case where another thread concurrently changed the request to REQUEST_PENDING */
547-
if( REQUEST_PENDING != tmp_sync )
548-
wait_sync_update(tmp_sync, 1, request->req_status.MPI_ERROR);
540+
if (OPAL_LIKELY(with_signal)) {
541+
542+
ompi_wait_sync_t *tmp_sync = (ompi_wait_sync_t *) OPAL_ATOMIC_SWAP_PTR(&request->req_complete,
543+
REQUEST_COMPLETED);
544+
if( REQUEST_PENDING != tmp_sync ) {
545+
wait_sync_update(tmp_sync, 1, request->req_status.MPI_ERROR);
549546
}
550-
} else
547+
} else {
551548
request->req_complete = REQUEST_COMPLETED;
549+
}
552550
}
553551

554552
return OMPI_SUCCESS;

0 commit comments

Comments
 (0)