Skip to content

Commit b33b61a

Browse files
committed
pml/ucx: Propagate MPI serialized thread mode
The UCX PML needs to differentiate between mpi serialized and single thread mode according to MPI standard. Using UCX with multiple threads, even when providing mutual exclusion, is not completely equivalent to only using UCX with one same thread. Signed-off-by: Thomas Vegas <tvegas@nvidia.com>
1 parent 42c744e commit b33b61a

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

ompi/mca/pml/ucx/pml_ucx.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,20 @@ int mca_pml_ucx_close(void)
283283
return OMPI_SUCCESS;
284284
}
285285

286+
static ucs_thread_mode_t mca_pml_ucx_thread_mode(int ompi_mode)
287+
{
288+
switch (ompi_mode) {
289+
case MPI_THREAD_MULTIPLE:
290+
return UCS_THREAD_MODE_MULTI;
291+
case MPI_THREAD_SERIALIZED:
292+
return UCS_THREAD_MODE_SERIALIZED;
293+
case MPI_THREAD_FUNNELED:
294+
case MPI_THREAD_SINGLE:
295+
default:
296+
return UCS_THREAD_MODE_SINGLE;
297+
}
298+
}
299+
286300
int mca_pml_ucx_init(int enable_mpi_threads)
287301
{
288302
ucp_worker_params_t params;
@@ -292,12 +306,11 @@ int mca_pml_ucx_init(int enable_mpi_threads)
292306

293307
PML_UCX_VERBOSE(1, "mca_pml_ucx_init");
294308

295-
/* TODO check MPI thread mode */
296309
params.field_mask = UCP_WORKER_PARAM_FIELD_THREAD_MODE;
297310
if (enable_mpi_threads) {
298311
params.thread_mode = UCS_THREAD_MODE_MULTI;
299312
} else {
300-
params.thread_mode = UCS_THREAD_MODE_SINGLE;
313+
params.thread_mode = mca_pml_ucx_thread_mode(ompi_mpi_thread_provided);
301314
}
302315

303316
#if HAVE_DECL_UCP_WORKER_FLAG_IGNORE_REQUEST_LEAK

oshmem/mca/spml/ucx/spml_ucx_component.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ static int spml_ucx_init(void)
322322
wkr_params.field_mask = UCP_WORKER_PARAM_FIELD_THREAD_MODE;
323323
if (oshmem_mpi_thread_requested == SHMEM_THREAD_MULTIPLE) {
324324
wkr_params.thread_mode = UCS_THREAD_MODE_MULTI;
325+
} else if (oshmem_mpi_thread_requested == SHMEM_THREAD_SERIALIZED) {
326+
wkr_params.thread_mode = UCS_THREAD_MODE_SERIALIZED;
325327
} else {
326328
wkr_params.thread_mode = UCS_THREAD_MODE_SINGLE;
327329
}

0 commit comments

Comments
 (0)