2828#include "opal/util/printf.h"
2929#include "opal/util/show_help.h"
3030#include "ompi/constants.h"
31-
32- static char * find_prterun (void )
33- {
34- char * filename = NULL ;
35- #if !OMPI_USING_INTERNAL_PRRTE
36- char * prrte_prefix = NULL ;
31+ #if OMPI_HAVE_PRTE_LAUNCH
32+ #include "prte.h"
3733#endif
3834
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- }
71-
7235static void append_prefixes (char * * * out , const char * in )
7336{
7437 if (NULL == in ) {
@@ -115,14 +78,43 @@ static void setup_mca_prefixes(void)
11578 opal_argv_free (tmp );
11679}
11780
81+ __opal_attribute_unused__
82+ static char * find_prterun (void )
83+ {
84+ char * filename = NULL ;
85+ char * prrte_prefix = NULL ;
86+
87+ /* 1) Did the user tell us exactly where to find prterun? */
88+ filename = getenv ("OMPI_PRTERUN" );
89+ if (NULL != filename ) {
90+ return filename ;
91+ }
92+
93+ /* 2) Look in ${PRTE_PREFIX}/bin */
94+ prrte_prefix = getenv ("PRTE_PREFIX" );
95+ if (NULL != prrte_prefix ) {
96+ opal_asprintf (& filename , "%s%sbin%sprterun" , prrte_prefix , OPAL_PATH_SEP , OPAL_PATH_SEP );
97+ return filename ;
98+ }
99+
100+ /* 4) See if configure told us where to look, if set */
101+ #if defined(OMPI_PRTERUN_PATH )
102+ return strdup (OMPI_PRTERUN_PATH );
103+ #else
104+
105+ /* 5) Use path search */
106+ filename = opal_find_absolute_path ("prterun" );
107+
108+ return filename ;
109+ #endif
110+ }
118111
119112int main (int argc , char * argv [])
120113{
121114 char * opal_prefix = getenv ("OPAL_PREFIX" );
122- char * full_prterun_path = NULL ;
123- char * * prterun_args = NULL ;
115+ char __opal_attribute_unused__ * full_prterun_path = NULL ;
116+ char __opal_attribute_unused__ * * prterun_args = NULL ;
124117 int ret ;
125- size_t i ;
126118
127119 ret = opal_init_util (& argc , & argv );
128120 if (OMPI_SUCCESS != ret ) {
@@ -154,23 +146,33 @@ int main(int argc, char *argv[])
154146#endif
155147 }
156148
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-
163149 /*
164150 * set environment variable for our install location
165151 * used within the OMPI prrte schizo component
166152 */
167-
168153 setenv ("OMPI_LIBDIR_LOC" , opal_install_dirs .libdir , 1 );
169154
170155 // Set environment variable to tell PRTE what MCA prefixes belong
171156 // to Open MPI.
172157 setup_mca_prefixes ();
173158
159+ #if OMPI_HAVE_PRTE_LAUNCH
160+
161+ ret = prte_launch (argc , argv );
162+ if (OMPI_SUCCESS != ret ) {
163+ opal_show_help ("help-mpirun.txt" , "prte-launch-failed" , 1 , strerror (errno ));
164+ exit (1 );
165+ }
166+
167+ return 0 ;
168+ #else
169+
170+ full_prterun_path = find_prterun ();
171+ if (NULL == full_prterun_path ) {
172+ opal_show_help ("help-mpirun.txt" , "no-prterun-found" , 1 );
173+ exit (1 );
174+ }
175+
174176 /* calling mpirun (and now prterun) with a full path has a special
175177 * meaning in terms of -prefix behavior, so copy that behavior
176178 * into prterun */
@@ -182,16 +184,16 @@ int main(int argc, char *argv[])
182184
183185 /* Copy all the mpirun arguments to prterun.
184186 * TODO: Need to handle --prefix rationally here. */
185- for (i = 1 ; NULL != argv [i ]; i ++ ) {
187+ for (size_t i = 1 ; NULL != argv [i ]; i ++ ) {
186188 opal_argv_append_nosize (& prterun_args , argv [i ]);
187189 }
188190 ret = execv (full_prterun_path , prterun_args );
189191 opal_show_help ("help-mpirun.txt" , "prterun-exec-failed" ,
190192 1 , full_prterun_path , strerror (errno ));
191- exit (1 );
192- }
193-
194- /*
193+ exit (1 );
194+ #endif /* OMPI_HAVE_PRTE_LAUNCH*/
195+ }
196+ /*
195197 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
196198 * University Research and Technology
197199 * Corporation. All rights reserved.
@@ -206,9 +208,9 @@ int main(int argc, char *argv[])
206208 * Copyright (c) 2020-2022 Cisco Systems, Inc. All rights reserved
207209 * Copyright (c) 2021 Nanook Consulting. All rights reserved.
208210 * Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
209- * Copyright (c) 2022 Triad National Security, LLC. All rights
211+ * Copyright (c) 2022-2025 Triad National Security, LLC. All rights
210212 * reserved.
211-
213+
212214 * $COPYRIGHT$
213215 *
214216 * Additional copyrights may follow
0 commit comments