Skip to content

Commit 4c9975b

Browse files
author
Mamzi Bayatpour [email protected] ()
committed
Revert "Enhance ref counters"
This reverts commit 00ebe71.
1 parent 00ebe71 commit 4c9975b

File tree

3 files changed

+12
-27
lines changed

3 files changed

+12
-27
lines changed

ompi/mca/osc/ucx/osc_ucx.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ typedef struct ompi_osc_ucx_module {
135135
bool lock_all_is_nocheck;
136136
bool no_locks;
137137
bool acc_single_intrinsic;
138-
uint64_t *acc_lock_refcnt;
139-
uint64_t *pending_acc_finalize_refcnt;
138+
uint64_t acc_lock_refcnt;
140139
opal_common_ucx_ctx_t *ctx;
141140
opal_common_ucx_wpmem_t *mem;
142141
opal_common_ucx_wpmem_t *state_mem;

ompi/mca/osc/ucx/osc_ucx_comm.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,8 +1523,6 @@ void ompi_osc_ucx_req_completion(void *request) {
15231523
if (temp_dt != NULL && !ompi_datatype_is_predefined(temp_dt)) {
15241524
OBJ_RELEASE(temp_dt);
15251525
}
1526-
module->pending_acc_finalize_refcnt[target]--;
1527-
assert(module->pending_acc_finalize_refcnt[target] >= 0);
15281526
break;
15291527
}
15301528
case ACC_GET_RESULTS_DATA:

ompi/mca/osc/ucx/osc_ucx_component.c

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -840,8 +840,7 @@ static int component_select(struct ompi_win_t *win, void **base, size_t size, in
840840
OBJ_CONSTRUCT(&module->pending_posts, opal_list_t);
841841
module->start_grp_ranks = NULL;
842842
module->lock_all_is_nocheck = false;
843-
module->acc_lock_refcnt = calloc(comm_size, sizeof(uint64_t));
844-
module->pending_acc_finalize_refcnt = calloc(comm_size, sizeof(uint64_t));
843+
module->acc_lock_refcnt = 0;
845844

846845
if (!module->no_locks) {
847846
OBJ_CONSTRUCT(&module->outstanding_locks, opal_hash_table_t);
@@ -931,13 +930,8 @@ inline int ompi_osc_ucx_state_lock(
931930
OSC_UCX_GET_DEFAULT_EP(ep, module, target);
932931
int ret = OMPI_SUCCESS;
933932

934-
assert(module->pending_acc_finalize_refcnt[target] >= 0);
935-
while (module->pending_acc_finalize_refcnt[target] > 0) {
936-
opal_common_ucx_wpool_progress(mca_osc_ucx_component.wpool);
937-
}
938-
939933
if (force_lock || ompi_osc_need_acc_lock(module, target)) {
940-
if (module->acc_lock_refcnt[target] == 0) {
934+
if (module->acc_lock_refcnt == 0) {
941935
for (;;) {
942936
ret = opal_common_ucx_wpmem_cmpswp(module->state_mem,
943937
TARGET_LOCK_UNLOCKED, TARGET_LOCK_EXCLUSIVE,
@@ -954,11 +948,13 @@ inline int ompi_osc_ucx_state_lock(
954948
opal_common_ucx_wpool_progress(mca_osc_ucx_component.wpool);
955949
}
956950
}
957-
module->acc_lock_refcnt[target]++;
951+
958952
*lock_acquired = true;
953+
module->acc_lock_refcnt++;
959954
} else {
960955
*lock_acquired = false;
961956
}
957+
962958
return OMPI_SUCCESS;
963959
}
964960

@@ -981,16 +977,16 @@ inline int ompi_osc_ucx_state_unlock(
981977
return OMPI_ERROR;
982978
}
983979

984-
if (module->acc_lock_refcnt[target] == 1) {
980+
if (module->acc_lock_refcnt == 1) {
985981
ret = opal_common_ucx_wpmem_fetch(module->state_mem,
986982
UCP_ATOMIC_FETCH_OP_SWAP, TARGET_LOCK_UNLOCKED,
987983
target, &result_value, sizeof(result_value),
988984
remote_addr, ep);
989985
assert(result_value == TARGET_LOCK_EXCLUSIVE);
990986
}
991-
module->acc_lock_refcnt[target]--;
992-
assert(module->acc_lock_refcnt[target] >= 0);
993-
} else if (NULL != free_ptr) {
987+
module->acc_lock_refcnt--;
988+
assert(module->acc_lock_refcnt >= 0);
989+
} else if (NULL != free_ptr){
994990
/* flush before freeing the buffer */
995991
ret = opal_common_ucx_ctx_flush(module->ctx, OPAL_COMMON_UCX_SCOPE_EP, target);
996992
}
@@ -1020,8 +1016,6 @@ inline int ompi_osc_ucx_nonblocking_ops_finalize(ompi_osc_ucx_module_t *module,
10201016
ucx_req->phase = ACC_FINALIZE;
10211017
ucx_req->acc_type = ANY;
10221018
ucx_req->super.module = module;
1023-
ucx_req->lock_acquired = lock_acquired;
1024-
ucx_req->target = target;
10251019

10261020
/* Fence any still active operations */
10271021
ret = opal_common_ucx_wpmem_fence(module->mem);
@@ -1030,8 +1024,7 @@ inline int ompi_osc_ucx_nonblocking_ops_finalize(ompi_osc_ucx_module_t *module,
10301024
return OMPI_ERROR;
10311025
}
10321026

1033-
module->pending_acc_finalize_refcnt[target]++;
1034-
if (lock_acquired && module->acc_lock_refcnt[target] == 1) {
1027+
if (lock_acquired) {
10351028
OSC_UCX_INCREMENT_OUTSTANDING_NB_OPS(module);
10361029
ret = opal_common_ucx_wpmem_fetch_nb(module->state_mem,
10371030
UCP_ATOMIC_FETCH_OP_SWAP, TARGET_LOCK_UNLOCKED,
@@ -1043,7 +1036,7 @@ inline int ompi_osc_ucx_nonblocking_ops_finalize(ompi_osc_ucx_module_t *module,
10431036
return ret;
10441037
}
10451038
} else {
1046-
/* Lock is not acquired/ or ref count is not 1, but still, we need to know when the
1039+
/* Lock is not acquired, but still, we need to know when the
10471040
* acc is finalized so that we can free the temp buffers */
10481041
OSC_UCX_INCREMENT_OUTSTANDING_NB_OPS(module);
10491042
ret = opal_common_ucx_wpmem_flush_ep_nb(module->mem, target, ompi_osc_ucx_req_completion, ucx_req, ep);
@@ -1061,11 +1054,6 @@ inline int ompi_osc_ucx_nonblocking_ops_finalize(ompi_osc_ucx_module_t *module,
10611054
}
10621055
}
10631056

1064-
if (lock_acquired) {
1065-
module->acc_lock_refcnt[target]--;
1066-
assert(module->acc_lock_refcnt[target] >= 0);
1067-
}
1068-
10691057
return ret;
10701058
}
10711059

0 commit comments

Comments
 (0)