Skip to content

Commit f13f291

Browse files
committed
UCX: Propagate MPI serialized for all worker creations
Move MPI to UCX thread mode function to common source. Also use serialized mode for all oshmem initializations. Signed-off-by: Thomas Vegas <[email protected]> (cherry picked from commit 44cc663)
1 parent cb33ea4 commit f13f291

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

ompi/mca/pml/ucx/pml_ucx.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ int mca_pml_ucx_init(int enable_mpi_threads)
293293
if (enable_mpi_threads) {
294294
params.thread_mode = UCS_THREAD_MODE_MULTI;
295295
} else {
296-
params.thread_mode = UCS_THREAD_MODE_SINGLE;
296+
params.thread_mode =
297+
opal_common_ucx_thread_mode(ompi_mpi_thread_provided);
297298
}
298299

299300
#if HAVE_DECL_UCP_WORKER_FLAG_IGNORE_REQUEST_LEAK

opal/mca/common/ucx/common_ucx.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
#include "opal/util/argv.h"
2626
#include "opal/util/printf.h"
2727

28+
#include "mpi.h"
29+
2830
#include <ucm/api/ucm.h>
31+
2932
#include <fnmatch.h>
3033
#include <stdio.h>
3134

@@ -49,6 +52,23 @@ static void opal_common_ucx_mem_release_cb(void *buf, size_t length,
4952
ucm_vm_munmap(buf, length);
5053
}
5154

55+
ucs_thread_mode_t opal_common_ucx_thread_mode(int ompi_mode)
56+
{
57+
switch (ompi_mode) {
58+
case MPI_THREAD_MULTIPLE:
59+
return UCS_THREAD_MODE_MULTI;
60+
case MPI_THREAD_SERIALIZED:
61+
return UCS_THREAD_MODE_SERIALIZED;
62+
case MPI_THREAD_FUNNELED:
63+
case MPI_THREAD_SINGLE:
64+
return UCS_THREAD_MODE_SINGLE;
65+
default:
66+
MCA_COMMON_UCX_WARN("Unknown MPI thread mode %d, using multithread",
67+
ompi_mode);
68+
return UCS_THREAD_MODE_MULTI;
69+
}
70+
}
71+
5272
OPAL_DECLSPEC void opal_common_ucx_mca_var_register(const mca_base_component_t *component)
5373
{
5474
char *default_tls = "rc_verbs,ud_verbs,rc_mlx5,dc_mlx5,ud_mlx5,cuda_ipc,rocm_ipc";

opal/mca/common/ucx/common_ucx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ OPAL_DECLSPEC int opal_common_ucx_del_procs(opal_common_ucx_del_proc_t *procs, s
124124
OPAL_DECLSPEC int opal_common_ucx_del_procs_nofence(opal_common_ucx_del_proc_t *procs, size_t count,
125125
size_t my_rank, size_t max_disconnect, ucp_worker_h worker);
126126
OPAL_DECLSPEC void opal_common_ucx_mca_var_register(const mca_base_component_t *component);
127+
OPAL_DECLSPEC ucs_thread_mode_t opal_common_ucx_thread_mode(int ompi_mode);
127128

128129
static inline
129130
ucs_status_t opal_common_ucx_request_status(ucs_status_ptr_t request)

oshmem/mca/spml/ucx/spml_ucx.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,8 +1016,11 @@ static int mca_spml_ucx_ctx_create_common(long options, mca_spml_ucx_ctx_t **ucx
10161016
ucx_ctx->strong_sync = mca_spml_ucx_ctx_default.strong_sync;
10171017

10181018
params.field_mask = UCP_WORKER_PARAM_FIELD_THREAD_MODE;
1019-
if (oshmem_mpi_thread_provided == SHMEM_THREAD_SINGLE || options & SHMEM_CTX_PRIVATE || options & SHMEM_CTX_SERIALIZED) {
1019+
if (oshmem_mpi_thread_provided == SHMEM_THREAD_SINGLE ||
1020+
oshmem_mpi_thread_provided == SHMEM_THREAD_FUNNELED || options & SHMEM_CTX_PRIVATE) {
10201021
params.thread_mode = UCS_THREAD_MODE_SINGLE;
1022+
} else if (oshmem_mpi_thread_provided == SHMEM_THREAD_SERIALIZED || options & SHMEM_CTX_SERIALIZED) {
1023+
params.thread_mode = UCS_THREAD_MODE_SERIALIZED;
10211024
} else {
10221025
params.thread_mode = UCS_THREAD_MODE_MULTI;
10231026
}

0 commit comments

Comments
 (0)