• Xin Zhao's avatar
    Bug-fix: always waiting for remote completion in Win_unlock. · c76aa786
    Xin Zhao authored and Pavan Balaji's avatar Pavan Balaji committed
    The original implementation includes an optimization which
    allows Win_unlock for exclusive lock to return without
    waiting for remote completion. This relys on the
    assumption that window memory on target process will not
    be accessed by a third party until that target process
    finishes all RMA operations and grants the lock to other
    processes. However, this assumption is not correct if user
    uses assert MPI_MODE_NOCHECK. Consider the following code:
              P0                              P1           P2
        MPI_Win_lock(P1, NULL, exclusive);
        MPI_Win_unlock(P1, exclusive);
        MPI_Send (P2);                                MPI_Recv(P0);
                                                      MPI_Win_lock(P1, MODE_NOCHECK, exclusive);
                                                      MPI_Win_unlock(P1, exclusive);
    Both P0 and P2 issue exclusive lock to P1, and P2 uses assert
    MPI_MODE_NOCHECK because the lock should be granted to P2 after
    synchronization between P2 and P0. However, in the original
    implementation, GET operation on P2 might not get the updated
    value since Win_unlock on P0 return without waiting for remote
    In this patch we delete this optimization. In Win_free, since every
    Win_unlock guarantees the remote completion, target process no
    longer needs to do additional counting works to detect target-side
    completion, but only needs to do a global barrier.
    Signed-off-by: Pavan Balaji's avatarPavan Balaji <balaji@anl.gov>