diff --git a/ompi/mca/osc/pt2pt/osc_pt2pt.c b/ompi/mca/osc/pt2pt/osc_pt2pt.c index 8ab07c7c74..409b8bff75 100644 --- a/ompi/mca/osc/pt2pt/osc_pt2pt.c +++ b/ompi/mca/osc/pt2pt/osc_pt2pt.c @@ -19,6 +19,7 @@ #include "osc_pt2pt.h" #include "osc_pt2pt_sendreq.h" +#include "opal/runtime/opal_progress.h" #include "opal/threads/mutex.h" #include "ompi/win/win.h" #include "ompi/communicator/communicator.h" @@ -32,6 +33,10 @@ ompi_osc_pt2pt_module_free(ompi_win_t *win) int tmp; ompi_osc_pt2pt_module_t *module = P2P_MODULE(win); + while (OMPI_WIN_EXPOSE_EPOCH & ompi_win_get_mode(win)) { + opal_progress(); + } + /* finish with a barrier */ if (ompi_group_size(win->w_group) > 1) { ret = module->p2p_comm->c_coll.coll_barrier(module->p2p_comm); diff --git a/ompi/mca/osc/pt2pt/osc_pt2pt_sync.c b/ompi/mca/osc/pt2pt/osc_pt2pt_sync.c index 3200f46091..4cd4e551ce 100644 --- a/ompi/mca/osc/pt2pt/osc_pt2pt_sync.c +++ b/ompi/mca/osc/pt2pt/osc_pt2pt_sync.c @@ -422,7 +422,8 @@ ompi_osc_pt2pt_module_lock(int lock_type, assert(lock_type != 0); /* set our mode on the window */ - ompi_win_set_mode(win, OMPI_WIN_ACCESS_EPOCH | OMPI_WIN_LOCK_ACCESS); + ompi_win_remove_mode(win, OMPI_WIN_FENCE); + ompi_win_append_mode(win, OMPI_WIN_ACCESS_EPOCH | OMPI_WIN_LOCK_ACCESS); opal_output_verbose(50, ompi_osc_base_output, "%d sending lock request to %d", @@ -493,7 +494,7 @@ ompi_osc_pt2pt_module_unlock(int target, out_count); /* set our mode on the window */ - ompi_win_set_mode(win, 0); + ompi_win_remove_mode(win, OMPI_WIN_ACCESS_EPOCH | OMPI_WIN_LOCK_ACCESS); return OMPI_SUCCESS; } @@ -513,6 +514,7 @@ ompi_osc_pt2pt_passive_lock(ompi_osc_pt2pt_module_t *module, if (lock_type == MPI_LOCK_EXCLUSIVE) { if (module->p2p_lock_status == 0) { module->p2p_lock_status = MPI_LOCK_EXCLUSIVE; + ompi_win_append_mode(module->p2p_win, OMPI_WIN_EXPOSE_EPOCH); send_ack = true; } else { opal_output_verbose(50, ompi_osc_base_output, @@ -527,6 +529,7 @@ ompi_osc_pt2pt_passive_lock(ompi_osc_pt2pt_module_t *module, if (module->p2p_lock_status != MPI_LOCK_EXCLUSIVE) { module->p2p_lock_status = MPI_LOCK_SHARED; module->p2p_shared_count++; + ompi_win_append_mode(module->p2p_win, OMPI_WIN_EXPOSE_EPOCH); send_ack = true; } else { opal_output_verbose(50, ompi_osc_base_output, @@ -573,10 +576,12 @@ ompi_osc_pt2pt_passive_unlock(ompi_osc_pt2pt_module_t *module, OPAL_THREAD_LOCK(&(module->p2p_lock)); if (module->p2p_lock_status == MPI_LOCK_EXCLUSIVE) { + ompi_win_remove_mode(module->p2p_win, OMPI_WIN_EXPOSE_EPOCH); module->p2p_lock_status = 0; } else { module->p2p_shared_count--; if (module->p2p_shared_count == 0) { + ompi_win_remove_mode(module->p2p_win, OMPI_WIN_EXPOSE_EPOCH); module->p2p_lock_status = 0; } } @@ -589,6 +594,7 @@ ompi_osc_pt2pt_passive_unlock(ompi_osc_pt2pt_module_t *module, if (NULL != new_pending) { opal_output_verbose(50, ompi_osc_base_output, "sending lock request to proc"); + ompi_win_append_mode(module->p2p_win, OMPI_WIN_EXPOSE_EPOCH); /* set lock state and generate a lock request */ module->p2p_lock_status = new_pending->lock_type; ompi_osc_pt2pt_control_send(module, diff --git a/ompi/mca/osc/rdma/osc_rdma.c b/ompi/mca/osc/rdma/osc_rdma.c index c43d5118de..eab73f7ea8 100644 --- a/ompi/mca/osc/rdma/osc_rdma.c +++ b/ompi/mca/osc/rdma/osc_rdma.c @@ -19,6 +19,7 @@ #include "osc_rdma.h" #include "osc_rdma_sendreq.h" +#include "opal/runtime/opal_progress.h" #include "opal/threads/mutex.h" #include "ompi/win/win.h" #include "ompi/communicator/communicator.h" @@ -33,6 +34,10 @@ ompi_osc_rdma_module_free(ompi_win_t *win) int tmp; ompi_osc_rdma_module_t *module = P2P_MODULE(win); + while (OMPI_WIN_EXPOSE_EPOCH & ompi_win_get_mode(win)) { + opal_progress(); + } + /* finish with a barrier */ if (ompi_group_size(win->w_group) > 1) { ret = module->p2p_comm->c_coll.coll_barrier(module->p2p_comm); diff --git a/ompi/mca/osc/rdma/osc_rdma_sync.c b/ompi/mca/osc/rdma/osc_rdma_sync.c index dc2a773d50..540adb39be 100644 --- a/ompi/mca/osc/rdma/osc_rdma_sync.c +++ b/ompi/mca/osc/rdma/osc_rdma_sync.c @@ -460,7 +460,8 @@ ompi_osc_rdma_module_lock(int lock_type, assert(lock_type != 0); /* set our mode on the window */ - ompi_win_set_mode(win, OMPI_WIN_ACCESS_EPOCH | OMPI_WIN_LOCK_ACCESS); + ompi_win_remove_mode(win, OMPI_WIN_FENCE); + ompi_win_append_mode(win, OMPI_WIN_ACCESS_EPOCH | OMPI_WIN_LOCK_ACCESS); opal_output_verbose(50, ompi_osc_base_output, "%d sending lock request to %d", @@ -531,7 +532,7 @@ ompi_osc_rdma_module_unlock(int target, out_count); /* set our mode on the window */ - ompi_win_set_mode(win, 0); + ompi_win_remove_mode(win, OMPI_WIN_ACCESS_EPOCH | OMPI_WIN_LOCK_ACCESS); return OMPI_SUCCESS; } @@ -551,6 +552,7 @@ ompi_osc_rdma_passive_lock(ompi_osc_rdma_module_t *module, if (lock_type == MPI_LOCK_EXCLUSIVE) { if (module->p2p_lock_status == 0) { module->p2p_lock_status = MPI_LOCK_EXCLUSIVE; + ompi_win_append_mode(module->p2p_win, OMPI_WIN_EXPOSE_EPOCH); send_ack = true; } else { opal_output_verbose(50, ompi_osc_base_output, @@ -565,6 +567,7 @@ ompi_osc_rdma_passive_lock(ompi_osc_rdma_module_t *module, if (module->p2p_lock_status != MPI_LOCK_EXCLUSIVE) { module->p2p_lock_status = MPI_LOCK_SHARED; module->p2p_shared_count++; + ompi_win_append_mode(module->p2p_win, OMPI_WIN_EXPOSE_EPOCH); send_ack = true; } else { opal_output_verbose(50, ompi_osc_base_output, @@ -611,10 +614,12 @@ ompi_osc_rdma_passive_unlock(ompi_osc_rdma_module_t *module, OPAL_THREAD_LOCK(&(module->p2p_lock)); if (module->p2p_lock_status == MPI_LOCK_EXCLUSIVE) { + ompi_win_remove_mode(module->p2p_win, OMPI_WIN_EXPOSE_EPOCH); module->p2p_lock_status = 0; } else { module->p2p_shared_count--; if (module->p2p_shared_count == 0) { + ompi_win_remove_mode(module->p2p_win, OMPI_WIN_EXPOSE_EPOCH); module->p2p_lock_status = 0; } } @@ -627,6 +632,7 @@ ompi_osc_rdma_passive_unlock(ompi_osc_rdma_module_t *module, if (NULL != new_pending) { opal_output_verbose(50, ompi_osc_base_output, "sending lock request to proc"); + ompi_win_append_mode(module->p2p_win, OMPI_WIN_EXPOSE_EPOCH); /* set lock state and generate a lock request */ module->p2p_lock_status = new_pending->lock_type; ompi_osc_rdma_control_send(module, diff --git a/ompi/mpi/c/win_free.c b/ompi/mpi/c/win_free.c index b92bf90dc7..0462296e21 100644 --- a/ompi/mpi/c/win_free.c +++ b/ompi/mpi/c/win_free.c @@ -41,8 +41,7 @@ int MPI_Win_free(MPI_Win *win) if (ompi_win_invalid(*win)) { return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_WIN, FUNC_NAME); - } else if ((OMPI_WIN_ACCESS_EPOCH|OMPI_WIN_EXPOSE_EPOCH) & - ompi_win_get_mode(*win)) { + } else if (OMPI_WIN_ACCESS_EPOCH & ompi_win_get_mode(*win)) { return OMPI_ERRHANDLER_INVOKE(*win, MPI_ERR_RMA_SYNC, FUNC_NAME);