Skip to content

Commit bb28bca

Browse files
authored
Merge pull request #9574 from hoopoepg/topic/dependency-compat-with-4.x
SPML/UCX: provide backward dependency compatibility
2 parents 4db61cd + dcf122d commit bb28bca

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

oshmem/mca/spml/ucx/spml_ucx.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ mca_spml_ucx_t mca_spml_ucx = {
7878
.num_disconnect = 1,
7979
.heap_reg_nb = 0,
8080
.enabled = 0,
81-
.get_mkey_slow = NULL,
82-
.synchronized_quiet = false,
83-
.strong_sync = SPML_UCX_STRONG_ORDERING_NONE
81+
.get_mkey_slow = NULL
8482
};
8583

8684
mca_spml_ucx_ctx_t mca_spml_ucx_ctx_default = {
8785
.ucp_worker = NULL,
8886
.ucp_peers = NULL,
89-
.options = 0
87+
.options = 0,
88+
.synchronized_quiet = false,
89+
.strong_sync = SPML_UCX_STRONG_ORDERING_NONE
9090
};
9191

9292
#ifdef HAVE_UCP_REQUEST_PARAM_T
@@ -402,7 +402,7 @@ int mca_spml_ucx_init_put_op_mask(mca_spml_ucx_ctx_t *ctx, size_t nprocs)
402402
{
403403
int res;
404404

405-
if (mca_spml_ucx_is_strong_ordering()) {
405+
if (mca_spml_ucx_is_strong_ordering(ctx)) {
406406
ctx->put_proc_indexes = malloc(nprocs * sizeof(*ctx->put_proc_indexes));
407407
if (NULL == ctx->put_proc_indexes) {
408408
return OSHMEM_ERR_OUT_OF_RESOURCE;
@@ -424,7 +424,7 @@ int mca_spml_ucx_init_put_op_mask(mca_spml_ucx_ctx_t *ctx, size_t nprocs)
424424

425425
int mca_spml_ucx_clear_put_op_mask(mca_spml_ucx_ctx_t *ctx)
426426
{
427-
if (mca_spml_ucx_is_strong_ordering() && ctx->put_proc_indexes) {
427+
if (mca_spml_ucx_is_strong_ordering(ctx) && ctx->put_proc_indexes) {
428428
OBJ_DESTRUCT(&ctx->put_op_bitmap);
429429
free(ctx->put_proc_indexes);
430430
}
@@ -841,6 +841,8 @@ static int mca_spml_ucx_ctx_create_common(long options, mca_spml_ucx_ctx_t **ucx
841841
ucx_ctx->options = options;
842842
ucx_ctx->ucp_worker = calloc(1, sizeof(ucp_worker_h));
843843
ucx_ctx->ucp_workers = 1;
844+
ucx_ctx->synchronized_quiet = mca_spml_ucx_ctx_default.synchronized_quiet;
845+
ucx_ctx->strong_sync = mca_spml_ucx_ctx_default.strong_sync;
844846

845847
params.field_mask = UCP_WORKER_PARAM_FIELD_THREAD_MODE;
846848
if (oshmem_mpi_thread_provided == SHMEM_THREAD_SINGLE || options & SHMEM_CTX_PRIVATE || options & SHMEM_CTX_SERIALIZED) {
@@ -1190,7 +1192,7 @@ static int mca_spml_ucx_strong_sync(shmem_ctx_t ctx)
11901192
for (i = 0; i < ucx_ctx->put_proc_count; i++) {
11911193
idx = ucx_ctx->put_proc_indexes[i];
11921194

1193-
switch (mca_spml_ucx.strong_sync) {
1195+
switch (ucx_ctx->strong_sync) {
11941196
case SPML_UCX_STRONG_ORDERING_NONE:
11951197
case SPML_UCX_STRONG_ORDERING_GETNB:
11961198
ret = mca_spml_ucx_get_nb(ctx,
@@ -1242,7 +1244,7 @@ int mca_spml_ucx_fence(shmem_ctx_t ctx)
12421244

12431245
opal_atomic_wmb();
12441246

1245-
if (mca_spml_ucx.strong_sync != SPML_UCX_STRONG_ORDERING_NONE) {
1247+
if (ucx_ctx->strong_sync != SPML_UCX_STRONG_ORDERING_NONE) {
12461248
ret = mca_spml_ucx_strong_sync(ctx);
12471249
if (ret != OSHMEM_SUCCESS) {
12481250
oshmem_shmem_abort(-1);
@@ -1269,7 +1271,7 @@ int mca_spml_ucx_quiet(shmem_ctx_t ctx)
12691271
unsigned i;
12701272
mca_spml_ucx_ctx_t *ucx_ctx = (mca_spml_ucx_ctx_t *)ctx;
12711273

1272-
if (mca_spml_ucx.synchronized_quiet) {
1274+
if (ucx_ctx->synchronized_quiet) {
12731275
ret = mca_spml_ucx_strong_sync(ctx);
12741276
if (ret != OSHMEM_SUCCESS) {
12751277
oshmem_shmem_abort(-1);

oshmem/mca/spml/ucx/spml_ucx.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ struct mca_spml_ucx_ctx {
8686
unsigned int ucp_workers;
8787
int *put_proc_indexes;
8888
unsigned put_proc_count;
89+
bool synchronized_quiet;
90+
int strong_sync;
8991
};
9092
typedef struct mca_spml_ucx_ctx mca_spml_ucx_ctx_t;
9193

@@ -120,8 +122,6 @@ struct mca_spml_ucx {
120122
mca_spml_ucx_ctx_t *aux_ctx;
121123
pthread_spinlock_t async_lock;
122124
int aux_refcnt;
123-
bool synchronized_quiet;
124-
int strong_sync;
125125
unsigned long nb_progress_thresh_global;
126126
unsigned long nb_put_progress_thresh;
127127
unsigned long nb_get_progress_thresh;
@@ -302,15 +302,15 @@ static inline int ucx_status_to_oshmem_nb(ucs_status_t status)
302302
#endif
303303
}
304304

305-
static inline int mca_spml_ucx_is_strong_ordering(void)
305+
static inline int mca_spml_ucx_is_strong_ordering(mca_spml_ucx_ctx_t *ctx)
306306
{
307-
return (mca_spml_ucx.strong_sync != SPML_UCX_STRONG_ORDERING_NONE) ||
308-
mca_spml_ucx.synchronized_quiet;
307+
return (ctx->strong_sync != SPML_UCX_STRONG_ORDERING_NONE) ||
308+
ctx->synchronized_quiet;
309309
}
310310

311311
static inline void mca_spml_ucx_remote_op_posted(mca_spml_ucx_ctx_t *ctx, int dst)
312312
{
313-
if (OPAL_UNLIKELY(mca_spml_ucx_is_strong_ordering())) {
313+
if (OPAL_UNLIKELY(mca_spml_ucx_is_strong_ordering(ctx))) {
314314
if (!opal_bitmap_is_set_bit(&ctx->put_op_bitmap, dst)) {
315315
ctx->put_proc_indexes[ctx->put_proc_count++] = dst;
316316
opal_bitmap_set_bit(&ctx->put_op_bitmap, dst);

oshmem/mca/spml/ucx/spml_ucx_component.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,12 @@ static int mca_spml_ucx_component_register(void)
159159

160160
mca_spml_ucx_param_register_bool("synchronized_quiet", 0,
161161
"Use synchronized quiet on shmem_quiet or shmem_barrier_all operations",
162-
&mca_spml_ucx.synchronized_quiet);
162+
&mca_spml_ucx_ctx_default.synchronized_quiet);
163163

164164
mca_spml_ucx_param_register_int("strong_sync", 0,
165165
"Use strong synchronization on shmem_quiet, shmem_fence or shmem_barrier_all operations: "
166166
"0 - don't do strong synchronization, 1 - use non blocking get, 2 - use blocking get, 3 - use flush operation",
167-
&mca_spml_ucx.strong_sync);
167+
&mca_spml_ucx_ctx_default.strong_sync);
168168

169169
mca_spml_ucx_param_register_ulong("nb_progress_thresh_global", 0,
170170
"Number of nb_put or nb_get operations before ucx progress is triggered. Disabled by default (0). Setting this value will override nb_put/get_progress_thresh.",
@@ -388,14 +388,14 @@ mca_spml_ucx_component_init(int* priority,
388388
if (OSHMEM_SUCCESS != spml_ucx_init())
389389
return NULL ;
390390

391-
SPML_UCX_VERBOSE(50, "*** ucx initialized ****");
392-
393-
if ((mca_spml_ucx.strong_sync < SPML_UCX_STRONG_ORDERING_NONE) ||
394-
(mca_spml_ucx.strong_sync > SPML_UCX_STRONG_ORDERING_FLUSH)) {
391+
if ((mca_spml_ucx_ctx_default.strong_sync < SPML_UCX_STRONG_ORDERING_NONE) ||
392+
(mca_spml_ucx_ctx_default.strong_sync > SPML_UCX_STRONG_ORDERING_FLUSH)) {
395393
SPML_UCX_ERROR("incorrect value of strong_sync parameter: %d",
396-
mca_spml_ucx.strong_sync);
394+
mca_spml_ucx_ctx_default.strong_sync);
397395
}
398396

397+
SPML_UCX_VERBOSE(50, "*** ucx initialized ****");
398+
399399
return &mca_spml_ucx.super;
400400
}
401401

0 commit comments

Comments
 (0)