Skip to content

Commit

Permalink
Merge pull request #9312 from awlauria/v4.1.x_threads
Browse files Browse the repository at this point in the history
v4.1.x Thread fixes.
  • Loading branch information
jsquyres authored Sep 7, 2021
2 parents 349fe15 + aa4529b commit 66d34c3
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions ompi/request/request.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,21 +417,24 @@ static inline int ompi_request_free(ompi_request_t** request)

static inline void ompi_request_wait_completion(ompi_request_t *req)
{
if (opal_using_threads () && !REQUEST_COMPLETE(req)) {
void *_tmp_ptr = REQUEST_PENDING;
ompi_wait_sync_t sync;
if (opal_using_threads ()) {
if(!REQUEST_COMPLETE(req)) {
void *_tmp_ptr = REQUEST_PENDING;
ompi_wait_sync_t sync;

WAIT_SYNC_INIT(&sync, 1);
WAIT_SYNC_INIT(&sync, 1);

if (OPAL_ATOMIC_COMPARE_EXCHANGE_STRONG_PTR(&req->req_complete, &_tmp_ptr, &sync)) {
SYNC_WAIT(&sync);
} else {
/* completed before we had a chance to swap in the sync object */
WAIT_SYNC_SIGNALLED(&sync);
}
if (OPAL_ATOMIC_COMPARE_EXCHANGE_STRONG_PTR(&req->req_complete, &_tmp_ptr, &sync)) {
SYNC_WAIT(&sync);
} else {
/* completed before we had a chance to swap in the sync object */
WAIT_SYNC_SIGNALLED(&sync);
}

assert(REQUEST_COMPLETE(req));
WAIT_SYNC_RELEASE(&sync);
assert(REQUEST_COMPLETE(req));
WAIT_SYNC_RELEASE(&sync);
}
opal_atomic_rmb();
} else {
while(!REQUEST_COMPLETE(req)) {
opal_progress();
Expand Down

0 comments on commit 66d34c3

Please sign in to comment.