Skip to content

Commit

Permalink
ompi/request: Add a read memory barrier to sync the receive buffer so…
Browse files Browse the repository at this point in the history
…on after wait completes.

We found an issue where with using multiple threads, it is possible for the data
to not be in the buffer before MPI_Wait() returns. Testing the buffer later after
MPI_Wait() returned would show the data arrives eventually without the rmb().

We have seen this issue on Power9 intermittently using PAMI, but in theory could
happen with any transport.

Signed-off-by: Austen Lauria <awlauria@us.ibm.com>
(cherry picked from commit 12192f1)
  • Loading branch information
AboorvaDevarajan authored and awlauria committed Aug 25, 2021
1 parent a39a051 commit aa4529b
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 aa4529b

Please sign in to comment.