Skip to content

Commit 32c79e0

Browse files
authored
Merge pull request #8971 from SeyedMir/topic/v4.1.x/osc_ucx_win_free
v4.1.x: osc/ucx: Detach dynamic window memory when freeing a window
2 parents f5cc551 + e91a2b0 commit 32c79e0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

ompi/mca/osc/ucx/osc_ucx_component.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,7 @@ int ompi_osc_ucx_win_detach(struct ompi_win_t *win, const void *base) {
854854
int ompi_osc_ucx_free(struct ompi_win_t *win) {
855855
ompi_osc_ucx_module_t *module = (ompi_osc_ucx_module_t*) win->w_osc_module;
856856
int i, ret;
857+
uint64_t idx;
857858

858859
assert(module->global_ops_num == 0);
859860
assert(module->lock_count == 0);
@@ -874,6 +875,14 @@ int ompi_osc_ucx_free(struct ompi_win_t *win) {
874875
ret = module->comm->c_coll->coll_barrier(module->comm,
875876
module->comm->c_coll->coll_barrier_module);
876877

878+
/* MPI_Win_free should detach any memory attached to dynamic windows */
879+
for (idx = 0; idx < module->state.dynamic_win_count; idx++) {
880+
assert(module->local_dynamic_win_info[idx].refcnt == 1);
881+
ucp_mem_unmap(mca_osc_ucx_component.ucp_context,
882+
module->local_dynamic_win_info[idx].memh);
883+
}
884+
module->state.dynamic_win_count = 0;
885+
877886
for (i = 0; i < ompi_comm_size(module->comm); i++) {
878887
if ((module->win_info_array[i]).rkey_init == true) {
879888
ucp_rkey_destroy((module->win_info_array[i]).rkey);

0 commit comments

Comments
 (0)