Skip to content

Commit ebee6d7

Browse files
author
Gerardo Garcia
committed
modified mpirun to longer fork/exec prterun but now to instead call the function directly in the process
Signed-off-by: Gerardo Garcia <[email protected]>
1 parent 72c952d commit ebee6d7

File tree

2 files changed

+10
-66
lines changed

2 files changed

+10
-66
lines changed

ompi/tools/mpirun/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ mpirun_SOURCES = \
2121
main.c
2222

2323
mpirun_LDADD = \
24-
$(top_builddir)/opal/libopen-pal_core.la
24+
$(top_builddir)/opal/libopen-pal_core.la \
25+
$(top_builddir)/3rd-party/src/libprrte.la
2526

2627
mpirun_CPPFLAGS = \
2728
-DMCA_oshmem_FRAMEWORKS="\"$(MCA_oshmem_FRAMEWORKS)\"" \

ompi/tools/mpirun/main.c

Lines changed: 8 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -28,46 +28,8 @@
2828
#include "opal/util/printf.h"
2929
#include "opal/util/show_help.h"
3030
#include "ompi/constants.h"
31+
#include "3rd-party/prrte/include/prte.h"
3132

32-
static char *find_prterun(void)
33-
{
34-
char *filename = NULL;
35-
#if !OMPI_USING_INTERNAL_PRRTE
36-
char *prrte_prefix = NULL;
37-
#endif
38-
39-
/* 1) Did the user tell us exactly where to find prterun? */
40-
filename = getenv("OMPI_PRTERUN");
41-
if (NULL != filename) {
42-
return filename;
43-
}
44-
45-
#if OMPI_USING_INTERNAL_PRRTE
46-
/* 2) If using internal PRRTE, use our bindir. Note that this
47-
* will obey OPAL_PREFIX and OPAL_DESTDIR */
48-
opal_asprintf(&filename, "%s%sprterun", opal_install_dirs.bindir, OPAL_PATH_SEP);
49-
return filename;
50-
#else
51-
52-
/* 3) Look in ${PRTE_PREFIX}/bin */
53-
prrte_prefix = getenv("PRTE_PREFIX");
54-
if (NULL != prrte_prefix) {
55-
opal_asprintf(&filename, "%s%sbin%sprterun", prrte_prefix, OPAL_PATH_SEP, OPAL_PATH_SEP);
56-
return filename;
57-
}
58-
59-
/* 4) See if configure told us where to look, if set */
60-
#if defined(OMPI_PRTERUN_PATH)
61-
return strdup(OMPI_PRTERUN_PATH);
62-
#else
63-
64-
/* 5) Use path search */
65-
filename = opal_find_absolute_path("prterun");
66-
67-
return filename;
68-
#endif
69-
#endif
70-
}
7133

7234
static void append_prefixes(char ***out, const char *in)
7335
{
@@ -119,10 +81,7 @@ static void setup_mca_prefixes(void)
11981
int main(int argc, char *argv[])
12082
{
12183
char *opal_prefix = getenv("OPAL_PREFIX");
122-
char *full_prterun_path = NULL;
123-
char **prterun_args = NULL;
12484
int ret;
125-
size_t i;
12685

12786
ret = opal_init_util(&argc, &argv);
12887
if (OMPI_SUCCESS != ret) {
@@ -154,12 +113,6 @@ int main(int argc, char *argv[])
154113
#endif
155114
}
156115

157-
full_prterun_path = find_prterun();
158-
if (NULL == full_prterun_path) {
159-
opal_show_help("help-mpirun.txt", "no-prterun-found", 1);
160-
exit(1);
161-
}
162-
163116
/*
164117
* set environment variable for our install location
165118
* used within the OMPI prrte schizo component
@@ -171,24 +124,14 @@ int main(int argc, char *argv[])
171124
// to Open MPI.
172125
setup_mca_prefixes();
173126

174-
/* calling mpirun (and now prterun) with a full path has a special
175-
* meaning in terms of -prefix behavior, so copy that behavior
176-
* into prterun */
177-
if (opal_path_is_absolute(argv[0])) {
178-
opal_argv_append_nosize(&prterun_args, full_prterun_path);
179-
} else {
180-
opal_argv_append_nosize(&prterun_args, "prterun");
127+
128+
ret = prte_launch(argc, argv);
129+
if (OMPI_SUCCESS != ret) {
130+
opal_show_help("help-mpirun.txt", "prte-launch-failed", 1, strerror(errno));
131+
exit(1);
181132
}
182133

183-
/* Copy all the mpirun arguments to prterun.
184-
* TODO: Need to handle --prefix rationally here. */
185-
for (i = 1; NULL != argv[i]; i++) {
186-
opal_argv_append_nosize(&prterun_args, argv[i]);
187-
}
188-
ret = execv(full_prterun_path, prterun_args);
189-
opal_show_help("help-mpirun.txt", "prterun-exec-failed",
190-
1, full_prterun_path, strerror(errno));
191-
exit(1);
134+
return 0;
192135
}
193136

194137
/*
@@ -214,4 +157,4 @@ int main(int argc, char *argv[])
214157
* Additional copyrights may follow
215158
*
216159
* $HEADER$
217-
*/
160+
*/

0 commit comments

Comments
 (0)