28
28
#include "opal/util/printf.h"
29
29
#include "opal/util/show_help.h"
30
30
#include "ompi/constants.h"
31
+ #if OMPI_USING_INTERNAL_PRRTE
31
32
#include "3rd-party/prrte/include/prte.h"
33
+ #endif
32
34
33
35
34
36
static void append_prefixes (char * * * out , const char * in )
@@ -78,6 +80,10 @@ static void setup_mca_prefixes(void)
78
80
}
79
81
80
82
83
+ #if OMPI_USING_INTERNAL_PRRTE
84
+
85
+ /* we can use prte_launch */
86
+
81
87
int main (int argc , char * argv [])
82
88
{
83
89
char * opal_prefix = getenv ("OPAL_PREFIX" );
@@ -105,9 +111,7 @@ int main(int argc, char *argv[])
105
111
/* as a special case, if OPAL_PREFIX was set and either PRRTE or
106
112
* PMIx are internal builds, set their prefix variables as well */
107
113
if (NULL != opal_prefix ) {
108
- #if OMPI_USING_INTERNAL_PRRTE
109
114
setenv ("PRTE_PREFIX" , opal_prefix , 1 );
110
- #endif
111
115
#if OPAL_USING_INTERNAL_PMIX
112
116
setenv ("PMIX_PREFIX" , opal_prefix , 1 );
113
117
#endif
@@ -134,27 +138,110 @@ int main(int argc, char *argv[])
134
138
return 0 ;
135
139
}
136
140
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