Skip to content

Commit 7454a5e

Browse files
committed
mpirun: set OMPI_MCA_PREFIXES env var
The OMPI_MCA_PREFIXES env variable is used to pass the list of MCA variable prefixes to prterun, so that the PRRTE schizo/ompi component can know which variables passed via `--mca foo bar` belong to Open MPI and which belong to something else. Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
1 parent 14bc2ed commit 7454a5e

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

ompi/tools/mpirun/Makefile.am

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Copyright (c) 2020 IBM Corporation. All rights reserved.
44
# Copyright (c) 2021-2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
55
# Copyright (c) 2021 Nanook Consulting. All rights reserved.
6+
# Copyright (c) 2022 Cisco Systems, Inc. All rights reserved
67
# $COPYRIGHT$
78
#
89
# Additional copyrights may follow
@@ -22,6 +23,11 @@ mpirun_SOURCES = \
2223
mpirun_LDADD = \
2324
$(top_builddir)/opal/libopen-pal_core.la
2425

26+
mpirun_CPPFLAGS = \
27+
-DMCA_oshmem_FRAMEWORKS="\"$(MCA_oshmem_FRAMEWORKS)\"" \
28+
-DMCA_ompi_FRAMEWORKS="\"$(MCA_ompi_FRAMEWORKS)\"" \
29+
-DMCA_opal_FRAMEWORKS="\"$(MCA_opal_FRAMEWORKS)\""
30+
2531
install-exec-hook:
2632
(cd $(DESTDIR)$(bindir); rm -f mpiexec$(EXEEXT); $(LN_S) mpirun$(EXEEXT) mpiexec$(EXEEXT))
2733
(cd $(DESTDIR)$(bindir); rm -f oshrun$(EXEEXT); $(LN_S) mpirun$(EXEEXT) oshrun$(EXEEXT))

ompi/tools/mpirun/main.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,48 @@ static char *find_prterun(void)
6969
#endif
7070
}
7171

72+
static void append_prefixes(char ***out, const char *in)
73+
{
74+
if (NULL == in) {
75+
return;
76+
}
77+
78+
char **tokenized;
79+
tokenized = opal_argv_split(in, ' ');
80+
81+
int count = opal_argv_count(*out);
82+
for (int i = 0; tokenized[i] != NULL; ++i) {
83+
// Skip adding the names "common" and "pmix" to the list
84+
if (strcmp(tokenized[i], "common") == 0 ||
85+
strcmp(tokenized[i], "pmix") == 0) {
86+
continue;
87+
}
88+
opal_argv_append(&count, out, tokenized[i]);
89+
}
90+
91+
opal_argv_free(tokenized);
92+
}
93+
94+
static void setup_mca_prefixes(void)
95+
{
96+
int count = 0;
97+
char **tmp = NULL;
98+
99+
opal_argv_append(&count, &tmp, "mca");
100+
opal_argv_append(&count, &tmp, "opal");
101+
opal_argv_append(&count, &tmp, "ompi");
102+
103+
append_prefixes(&tmp, MCA_oshmem_FRAMEWORKS);
104+
append_prefixes(&tmp, MCA_ompi_FRAMEWORKS);
105+
append_prefixes(&tmp, MCA_opal_FRAMEWORKS);
106+
107+
char *env_str = opal_argv_join(tmp, ',');
108+
opal_setenv("OMPI_MCA_PREFIXES", env_str, true,
109+
&environ);
110+
111+
opal_argv_free(tmp);
112+
}
113+
72114

73115
int main(int argc, char *argv[])
74116
{
@@ -121,6 +163,9 @@ int main(int argc, char *argv[])
121163

122164
setenv("OMPI_LIBDIR_LOC", opal_install_dirs.libdir, 1);
123165

166+
// Set environment variable to tell PRTE what MCA prefixes belong
167+
// to Open MPI.
168+
setup_mca_prefixes();
124169

125170
/* calling mpirun (and now prterun) with a full path has a special
126171
* meaning in terms of -prefix behavior, so copy that behavior

0 commit comments

Comments
 (0)