Skip to content

Commit 9eaedb4

Browse files
committed
Fix finding "prte" for singleton comm_spawn
Copy the search code from mpirun to use when starting "prte" in support of comm_spawn. This respects things like OPAL_PREFIX. Signed-off-by: Ralph Castain <[email protected]>
1 parent aa2e117 commit 9eaedb4

File tree

1 file changed

+55
-2
lines changed

1 file changed

+55
-2
lines changed

ompi/dpm/dpm.c

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* Copyright (c) 2014-2020 Research Organization for Information Science
2121
* and Technology (RIST). All rights reserved.
2222
* Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
23-
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
23+
* Copyright (c) 2021-2024 Nanook Consulting All rights reserved.
2424
* Copyright (c) 2018-2022 Triad National Security, LLC. All rights
2525
* reserved.
2626
* Copyright (c) 2022 IBM Corporation. All rights reserved.
@@ -53,6 +53,7 @@
5353
#include "opal/util/show_help.h"
5454
#include "opal/util/printf.h"
5555
#include "opal/mca/hwloc/base/base.h"
56+
#include "opal/mca/installdirs/base/base.h"
5657
#include "opal/mca/pmix/base/base.h"
5758

5859
#include "ompi/communicator/communicator.h"
@@ -1974,6 +1975,46 @@ static void set_handler_default(int sig)
19741975
sigaction(sig, &act, (struct sigaction *)0);
19751976
}
19761977

1978+
static char *find_prte(void)
1979+
{
1980+
char *filename = NULL;
1981+
#if !OMPI_USING_INTERNAL_PRRTE
1982+
char *prrte_prefix = NULL;
1983+
#endif
1984+
1985+
/* 1) Did the user tell us exactly where to find prte? */
1986+
filename = getenv("OMPI_PRTERUN");
1987+
if (NULL != filename) {
1988+
return filename;
1989+
}
1990+
1991+
#if OMPI_USING_INTERNAL_PRRTE
1992+
/* 2) If using internal PRRTE, use our bindir. Note that this
1993+
* will obey OPAL_PREFIX and OPAL_DESTDIR */
1994+
opal_asprintf(&filename, "%s%sprte", opal_install_dirs.bindir, OPAL_PATH_SEP);
1995+
return filename;
1996+
#else
1997+
1998+
/* 3) Look in ${PRTE_PREFIX}/bin */
1999+
prrte_prefix = getenv("PRTE_PREFIX");
2000+
if (NULL != prrte_prefix) {
2001+
opal_asprintf(&filename, "%s%sbin%sprte", prrte_prefix, OPAL_PATH_SEP, OPAL_PATH_SEP);
2002+
return filename;
2003+
}
2004+
2005+
/* 4) See if configure told us where to look, if set */
2006+
#if defined(OMPI_PRTERUN_PATH)
2007+
return strdup(OMPI_PRTERUN_PATH);
2008+
#else
2009+
2010+
/* 5) Use path search */
2011+
filename = opal_find_absolute_path("prte");
2012+
2013+
return filename;
2014+
#endif
2015+
#endif
2016+
}
2017+
19772018
static int start_dvm(char **hostfiles, char **dash_host)
19782019
{
19792020
pmix_status_t pret;
@@ -1987,11 +2028,23 @@ static int start_dvm(char **hostfiles, char **dash_host)
19872028
pmix_info_t info;
19882029
int buffer_length, num_chars_read, chunk;
19892030
char *uri;
2031+
char *opal_prefix = getenv("OPAL_PREFIX");
2032+
2033+
/* as a special case, if OPAL_PREFIX was set and either PRRTE or
2034+
* PMIx are internal builds, set their prefix variables as well */
2035+
if (NULL != opal_prefix) {
2036+
#if OMPI_USING_INTERNAL_PRRTE
2037+
setenv("PRTE_PREFIX", opal_prefix, 1);
2038+
#endif
2039+
#if OPAL_USING_INTERNAL_PMIX
2040+
setenv("PMIX_PREFIX", opal_prefix, 1);
2041+
#endif
2042+
}
19902043

19912044
/* find the prte binary using the install_dirs support - this also
19922045
* checks to ensure that we can see this executable and it *is* executable by us
19932046
*/
1994-
cmd = opal_find_absolute_path("prte");
2047+
cmd = find_prte();
19952048
if (NULL == cmd) {
19962049
/* guess we couldn't do it - best to abort */
19972050
OMPI_ERROR_LOG(OMPI_ERROR);

0 commit comments

Comments
 (0)