Commit def275e9 authored by Xin Zhao's avatar Xin Zhao
Browse files

Bug-fix: correct SHM barrier in MPI_Win_fence.



Here we move the SHM barrier in MPI_Win_fence after the completion
of coming-in RMA operations, so that following coming-in RMA
operations on SHM in the next FENCE epoch will see the updated value.
Signed-off-by: Pavan Balaji's avatarPavan Balaji <balaji@anl.gov>
parent 5bf646a3
......@@ -1170,28 +1170,6 @@ int MPIDI_Win_fence(int assert, MPID_Win *win_ptr)
MPIR_T_PVAR_TIMER_END(RMA, rma_winfence_clearlock);
}
if (!(assert & MPI_MODE_NOSUCCEED) &&
(assert & MPI_MODE_NOPRECEDE || win_ptr->fence_issued == 0)) {
/* In the FENCE that opens an epoch but does not close an epoch,
if SHM is allocated, perform a barrier among processes on the
same node, to prevent one process modifying another process's
memory before that process starts an epoch. */
if (win_ptr->shm_allocated == TRUE) {
MPID_Comm *node_comm_ptr = win_ptr->comm_ptr->node_comm;
/* Ensure ordering of load/store operations. */
OPA_read_write_barrier();
mpi_errno = MPIR_Barrier_impl(node_comm_ptr, &errflag);
if (mpi_errno) {goto fn_fail;}
/* Ensure ordering of load/store operations. */
OPA_read_write_barrier();
}
}
/* Note that the NOPRECEDE and NOSUCCEED must be specified by all processes
in the window's group if any specify it */
if (assert & MPI_MODE_NOPRECEDE)
......@@ -1201,7 +1179,7 @@ int MPIDI_Win_fence(int assert, MPID_Win *win_ptr)
mpi_errno, MPI_ERR_RMA_SYNC, "**rmasync");
win_ptr->fence_issued = (assert & MPI_MODE_NOSUCCEED) ? 0 : 1;
goto fn_exit;
goto shm_barrier;
}
if (win_ptr->fence_issued == 0)
......@@ -1407,6 +1385,28 @@ int MPIDI_Win_fence(int assert, MPID_Win *win_ptr)
win_ptr->epoch_state = MPIDI_EPOCH_NONE;
}
shm_barrier:
if (!(assert & MPI_MODE_NOSUCCEED)) {
/* In a FENCE without MPI_MODE_NOSUCCEED (which means this FENCE
might start a new Active epoch), if SHM is allocated, perform
a barrier among processes on the same node, to prevent one
process modifying another process's memory before that process
starts an epoch. */
if (win_ptr->shm_allocated == TRUE) {
MPID_Comm *node_comm_ptr = win_ptr->comm_ptr->node_comm;
/* Ensure ordering of load/store operations. */
OPA_read_write_barrier();
mpi_errno = MPIR_Barrier_impl(node_comm_ptr, &errflag);
if (mpi_errno) {goto fn_fail;}
/* Ensure ordering of load/store operations. */
OPA_read_write_barrier();
}
}
fn_exit:
MPIU_CHKLMEM_FREEALL();
MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPIDI_WIN_FENCE);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment