Skip to content

Commit

Permalink
Fix finding "prte" for singleton comm_spawn
Browse files Browse the repository at this point in the history
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 <rhc@pmix.org>
  • Loading branch information
rhc54 committed Feb 23, 2024
1 parent cb00772 commit 397f9f1
Showing 1 changed file with 55 additions and 2 deletions.
57 changes: 55 additions & 2 deletions ompi/dpm/dpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* Copyright (c) 2014-2020 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* Copyright (c) 2021-2024 Nanook Consulting All rights reserved.
* Copyright (c) 2018-2022 Triad National Security, LLC. All rights
* reserved.
* Copyright (c) 2022 IBM Corporation. All rights reserved.
Expand Down Expand Up @@ -53,6 +53,7 @@
#include "opal/util/show_help.h"
#include "opal/util/printf.h"
#include "opal/mca/hwloc/base/base.h"
#include "opal/mca/installdirs/base/base.h"
#include "opal/mca/pmix/base/base.h"

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

static char *find_prte(void)
{
char *filename = NULL;
#if !OMPI_USING_INTERNAL_PRRTE
char *prrte_prefix = NULL;
#endif

/* 1) Did the user tell us exactly where to find prte? */
filename = getenv("OMPI_PRTERUN");
if (NULL != filename) {
return filename;
}

#if OMPI_USING_INTERNAL_PRRTE
/* 2) If using internal PRRTE, use our bindir. Note that this
* will obey OPAL_PREFIX and OPAL_DESTDIR */
opal_asprintf(&filename, "%s%sprte", opal_install_dirs.bindir, OPAL_PATH_SEP);
return filename;
#else

/* 3) Look in ${PRTE_PREFIX}/bin */
prrte_prefix = getenv("PRTE_PREFIX");
if (NULL != prrte_prefix) {
opal_asprintf(&filename, "%s%sbin%sprte", prrte_prefix, OPAL_PATH_SEP, OPAL_PATH_SEP);
return filename;
}

/* 4) See if configure told us where to look, if set */
#if defined(OMPI_PRTERUN_PATH)
return strdup(OMPI_PRTERUN_PATH);
#else

/* 5) Use path search */
filename = opal_find_absolute_path("prte");

return filename;
#endif
#endif
}

static int start_dvm(char **hostfiles, char **dash_host)
{
pmix_status_t pret;
Expand All @@ -1987,11 +2028,23 @@ static int start_dvm(char **hostfiles, char **dash_host)
pmix_info_t info;
int buffer_length, num_chars_read, chunk;
char *uri;
char *opal_prefix = getenv("OPAL_PREFIX");

/* as a special case, if OPAL_PREFIX was set and either PRRTE or
* PMIx are internal builds, set their prefix variables as well */
if (NULL != opal_prefix) {
#if OMPI_USING_INTERNAL_PRRTE
setenv("PRTE_PREFIX", opal_prefix, 1);
#endif
#if OPAL_USING_INTERNAL_PMIX
setenv("PMIX_PREFIX", opal_prefix, 1);
#endif
}

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

0 comments on commit 397f9f1

Please sign in to comment.