Skip to content

Commit 3c0d3ac

Browse files
committed
switch back to allowing external prte
in which case we use the old app launch method. Signed-off-by: Howard Pritchard <[email protected]>
1 parent f6efdbb commit 3c0d3ac

File tree

4 files changed

+132
-28
lines changed

4 files changed

+132
-28
lines changed

config/ompi_setup_prrte.m4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ OPAL_VAR_SCOPE_PUSH([prrte_setup_internal_happy prrte_setup_external_happy targe
118118
[$OMPI_USING_INTERNAL_PRRTE],
119119
[Whether or not we are using the internal PRRTE])
120120
121+
AM_CONDITIONAL(OMPI_USING_INTERNAL_PRRTE, [test $OMPI_USING_INTERNAL_PRRTE -eq 1])
122+
121123
AC_SUBST(OMPI_PRRTE_RST_CONTENT_DIR)
122124
AC_SUBST(OMPI_SCHIZO_OMPI_RST_CONTENT_DIR)
123125
AM_CONDITIONAL(OMPI_HAVE_PRRTE_RST, [test $OMPI_HAVE_PRRTE_RST -eq 1])

ompi/tools/mpirun/Makefile.am

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ mpirun_SOURCES = \
3131
# TODO: HPP replace hard-wired prrte prefix with something configurable
3232
#
3333
mpirun_LDADD = \
34-
$(top_builddir)/opal/libopen-pal_core.la \
34+
$(top_builddir)/opal/libopen-pal_core.la
35+
if OMPI_USING_INTERNAL_PRRTE
36+
mpirun_LDADD += \
3537
$(top_builddir)/3rd-party/prrte/src/libompi-prrte.la
38+
endif
3639

3740
mpirun_CPPFLAGS = \
3841
-DMCA_oshmem_FRAMEWORKS="\"$(MCA_oshmem_FRAMEWORKS)\"" \

ompi/tools/mpirun/help-mpirun.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,16 @@
1414
Open MPI's mpirun command was unable to launch the user's application.
1515
This may indicate an issue with the environment or incorrect configuration.
1616

17-
Error Message: %s
17+
Error Message: %s
18+
19+
[no-prterun-found]
20+
Open MPI's mpirun command was unable to find an underlying prterun
21+
command to execute. Consider setting the OMPI_PRTERUN environment
22+
variable to help mpirun find the correct underlying prterun.
23+
[prterun-exec-failed]
24+
Open MPI's mpirun command could not execute the underlying prterun
25+
command. The prterun command we tried to execute and the error
26+
message from exec() are below:
27+
28+
Command: %s
29+
Error Message: %s

ompi/tools/mpirun/main.c

Lines changed: 113 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
#include "opal/util/printf.h"
2929
#include "opal/util/show_help.h"
3030
#include "ompi/constants.h"
31+
#if OMPI_USING_INTERNAL_PRRTE
3132
#include "3rd-party/prrte/include/prte.h"
33+
#endif
3234

3335

3436
static void append_prefixes(char ***out, const char *in)
@@ -78,6 +80,10 @@ static void setup_mca_prefixes(void)
7880
}
7981

8082

83+
#if OMPI_USING_INTERNAL_PRRTE
84+
85+
/* we can use prte_launch */
86+
8187
int main(int argc, char *argv[])
8288
{
8389
char *opal_prefix = getenv("OPAL_PREFIX");
@@ -105,9 +111,7 @@ int main(int argc, char *argv[])
105111
/* as a special case, if OPAL_PREFIX was set and either PRRTE or
106112
* PMIx are internal builds, set their prefix variables as well */
107113
if (NULL != opal_prefix) {
108-
#if OMPI_USING_INTERNAL_PRRTE
109114
setenv("PRTE_PREFIX", opal_prefix, 1);
110-
#endif
111115
#if OPAL_USING_INTERNAL_PMIX
112116
setenv("PMIX_PREFIX", opal_prefix, 1);
113117
#endif
@@ -134,27 +138,110 @@ int main(int argc, char *argv[])
134138
return 0;
135139
}
136140

137-
/*
138-
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
139-
* University Research and Technology
140-
* Corporation. All rights reserved.
141-
* Copyright (c) 2004-2005 The University of Tennessee and The University
142-
* of Tennessee Research Foundation. All rights
143-
* reserved.
144-
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
145-
* University of Stuttgart. All rights reserved.
146-
* Copyright (c) 2004-2005 The Regents of the University of California.
147-
* All rights reserved.
148-
* Copyright (c) 2017-2020 Intel, Inc. All rights reserved.
149-
* Copyright (c) 2020-2022 Cisco Systems, Inc. All rights reserved
150-
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
151-
* Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
152-
* Copyright (c) 2022 Triad National Security, LLC. All rights
153-
* reserved.
154-
155-
* $COPYRIGHT$
156-
*
157-
* Additional copyrights may follow
158-
*
159-
* $HEADER$
160-
*/
141+
#else
142+
143+
/* using external prrte so cannot assume there's a prte_launch */
144+
145+
static char *find_prterun(void)
146+
{
147+
char *filename = NULL;
148+
char *prrte_prefix = NULL;
149+
150+
/* 1) Did the user tell us exactly where to find prterun? */
151+
filename = getenv("OMPI_PRTERUN");
152+
if (NULL != filename) {
153+
return filename;
154+
}
155+
156+
/* 2) Look in ${PRTE_PREFIX}/bin */
157+
prrte_prefix = getenv("PRTE_PREFIX");
158+
if (NULL != prrte_prefix) {
159+
opal_asprintf(&filename, "%s%sbin%sprterun", prrte_prefix, OPAL_PATH_SEP, OPAL_PATH_SEP);
160+
return filename;
161+
}
162+
163+
/* 4) See if configure told us where to look, if set */
164+
#if defined(OMPI_PRTERUN_PATH)
165+
return strdup(OMPI_PRTERUN_PATH);
166+
#else
167+
168+
/* 5) Use path search */
169+
filename = opal_find_absolute_path("prterun");
170+
171+
return filename;
172+
#endif
173+
}
174+
175+
int main(int argc, char *argv[])
176+
{
177+
char *opal_prefix = getenv("OPAL_PREFIX");
178+
char *full_prterun_path = NULL;
179+
char **prterun_args = NULL;
180+
int ret;
181+
size_t i;
182+
183+
ret = opal_init_util(&argc, &argv);
184+
if (OMPI_SUCCESS != ret) {
185+
fprintf(stderr, "Failed initializing opal: %d\n", ret);
186+
exit(1);
187+
}
188+
189+
/* note that we just modify our environment rather than create a
190+
* child environment because it is easier and we're not going to
191+
* be around long enough for it to matter (since we exec prterun
192+
* asap */
193+
setenv("PRTE_MCA_schizo_proxy", "ompi", 1);
194+
setenv("OMPI_VERSION", OMPI_VERSION, 1);
195+
char *base_tool_name = opal_basename(argv[0]);
196+
setenv("OMPI_TOOL_NAME", base_tool_name, 1);
197+
free(base_tool_name);
198+
199+
/* TODO: look for --prefix and compare with OPAL_PREFIX and pick
200+
* one */
201+
202+
/* as a special case, if OPAL_PREFIX was set and either PRRTE or
203+
* PMIx are internal builds, set their prefix variables as well */
204+
if (NULL != opal_prefix) {
205+
#if OPAL_USING_INTERNAL_PMIX
206+
setenv("PMIX_PREFIX", opal_prefix, 1);
207+
#endif
208+
}
209+
210+
full_prterun_path = find_prterun();
211+
if (NULL == full_prterun_path) {
212+
opal_show_help("help-mpirun.txt", "no-prterun-found", 1);
213+
exit(1);
214+
}
215+
216+
/*
217+
* set environment variable for our install location
218+
* used within the OMPI prrte schizo component
219+
*/
220+
221+
setenv("OMPI_LIBDIR_LOC", opal_install_dirs.libdir, 1);
222+
223+
// Set environment variable to tell PRTE what MCA prefixes belong
224+
// to Open MPI.
225+
setup_mca_prefixes();
226+
227+
/* calling mpirun (and now prterun) with a full path has a special
228+
* meaning in terms of -prefix behavior, so copy that behavior
229+
* into prterun */
230+
if (opal_path_is_absolute(argv[0])) {
231+
opal_argv_append_nosize(&prterun_args, full_prterun_path);
232+
} else {
233+
opal_argv_append_nosize(&prterun_args, "prterun");
234+
}
235+
236+
/* Copy all the mpirun arguments to prterun.
237+
* TODO: Need to handle --prefix rationally here. */
238+
for (i = 1; NULL != argv[i]; i++) {
239+
opal_argv_append_nosize(&prterun_args, argv[i]);
240+
}
241+
ret = execv(full_prterun_path, prterun_args);
242+
opal_show_help("help-mpirun.txt", "prterun-exec-failed",
243+
1, full_prterun_path, strerror(errno));
244+
exit(1);
245+
}
246+
#endif /* OMPI_USING_INTERNAL_PRRTE */
247+

0 commit comments

Comments
 (0)