1919 * Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
2020 * Copyright (c) 2019 Triad National Security, LLC. All rights
2121 * reserved.
22+ * Copyright (c) 2020 Intel, Inc. All rights reserved.
2223 * $COPYRIGHT$
2324 *
2425 * Additional copyrights may follow
4647#include "opal/util/argv.h"
4748#include "opal/util/opal_getcwd.h"
4849#include "opal/util/output.h"
50+ #include "opal/util/printf.h"
4951#include "opal/util/info.h"
5052
5153#include "ompi/info/info.h"
5254#include "ompi/runtime/mpiruntime.h"
5355#include "ompi/runtime/params.h"
56+ #include "ompi/runtime/ompi_rte.h"
5457
5558/*
5659 * Global variables
@@ -85,8 +88,7 @@ opal_pointer_array_t ompi_info_f_to_c_table = {{0}};
8588 */
8689int ompi_mpiinfo_init (void )
8790{
88- const char * val ;
89- char * cptr ;
91+ char * cptr , * * tmp ;
9092
9193 /* initialize table */
9294
@@ -107,45 +109,43 @@ int ompi_mpiinfo_init(void)
107109 /* fill the env info object */
108110
109111 /* command for this app_context */
110- if (NULL != (cptr = getenv ("OMPI_COMMAND" ))) {
111- opal_info_set (& ompi_mpi_info_env .info .super , "command" , cptr );
112- }
113-
114- /* space-separated list of argv for this command */
115- if (NULL != (cptr = getenv ("OMPI_ARGV" ))) {
112+ if (NULL != ompi_process_info .command ) {
113+ tmp = opal_argv_split (ompi_process_info .command , ' ' );
114+ opal_info_set (& ompi_mpi_info_env .info .super , "command" , tmp [0 ]);
115+
116+ /* space-separated list of argv for this command */
117+ if (1 < opal_argv_count (tmp )) {
118+ cptr = opal_argv_join (& tmp [1 ], ' ' );
119+ } else {
120+ cptr = strdup (tmp [0 ]);
121+ }
122+ opal_argv_free (tmp );
116123 opal_info_set (& ompi_mpi_info_env .info .super , "argv" , cptr );
124+ free (cptr );
117125 }
118126
119127 /* max procs for the entire job */
120- if ( NULL != ( cptr = getenv ( "OMPI_MCA_num_procs" ))) {
121- opal_info_set (& ompi_mpi_info_env .info .super , "maxprocs" , cptr );
122- /* Open MPI does not support the "soft" option, so set it to maxprocs */
123- opal_info_set (& ompi_mpi_info_env .info .super , "soft" , cptr );
124- }
128+ opal_asprintf ( & cptr , "%u" , ompi_process_info . num_procs );
129+ opal_info_set (& ompi_mpi_info_env .info .super , "maxprocs" , cptr );
130+ /* Open MPI does not support the "soft" option, so set it to maxprocs */
131+ opal_info_set (& ompi_mpi_info_env .info .super , "soft" , cptr );
132+ free ( cptr );
125133
126134 /* local host name */
127- val = opal_gethostname ();
128- opal_info_set (& ompi_mpi_info_env .info .super , "host" , val );
135+ opal_info_set (& ompi_mpi_info_env .info .super , "host" , ompi_process_info .nodename );
129136
130- /* architecture name */
131- if (NULL != (cptr = getenv ("OMPI_MCA_cpu_type" ))) {
132- opal_info_set (& ompi_mpi_info_env .info .super , "arch" , cptr );
133- }
134137#ifdef HAVE_SYS_UTSNAME_H
135- else {
138+ {
136139 struct utsname sysname ;
137140 uname (& sysname );
138141 cptr = sysname .machine ;
139142 opal_info_set (& ompi_mpi_info_env .info .super , "arch" , cptr );
140143 }
141144#endif
142145
143- /* initial working dir of this process - only set when
144- * run by mpiexec as we otherwise have no reliable way
145- * of determining the value
146- */
147- if (NULL != (cptr = getenv ("OMPI_MCA_initial_wdir" ))) {
148- opal_info_set (& ompi_mpi_info_env .info .super , "wdir" , cptr );
146+ /* initial working dir of this process, if provided */
147+ if (NULL != ompi_process_info .initial_wdir ) {
148+ opal_info_set (& ompi_mpi_info_env .info .super , "wdir" , ompi_process_info .initial_wdir );
149149 }
150150
151151 /* provide the REQUESTED thread level - may be different
@@ -172,25 +172,25 @@ int ompi_mpiinfo_init(void)
172172 /**** now some OMPI-specific values that other MPIs may not provide ****/
173173
174174 /* the number of app_contexts in this job */
175- if ( NULL != ( cptr = getenv ( "OMPI_NUM_APP_CTX" ))) {
176- opal_info_set (& ompi_mpi_info_env .info .super , "ompi_num_apps" , cptr );
177- }
175+ opal_asprintf ( & cptr , "%u" , ompi_process_info . num_apps );
176+ opal_info_set (& ompi_mpi_info_env .info .super , "ompi_num_apps" , cptr );
177+ free ( cptr );
178178
179179 /* space-separated list of first MPI rank of each app_context */
180- if (NULL != ( cptr = getenv ( "OMPI_FIRST_RANKS" )) ) {
181- opal_info_set (& ompi_mpi_info_env .info .super , "ompi_first_rank" , cptr );
180+ if (NULL != ompi_process_info . app_ldrs ) {
181+ opal_info_set (& ompi_mpi_info_env .info .super , "ompi_first_rank" , ompi_process_info . app_ldrs );
182182 }
183183
184184 /* space-separated list of num procs for each app_context */
185- if (NULL != ( cptr = getenv ( "OMPI_APP_CTX_NUM_PROCS" )) ) {
186- opal_info_set (& ompi_mpi_info_env .info .super , "ompi_np" , cptr );
185+ if (NULL != ompi_process_info . app_sizes ) {
186+ opal_info_set (& ompi_mpi_info_env .info .super , "ompi_np" , ompi_process_info . app_sizes );
187187 }
188188
189189 /* location of the directory containing any prepositioned files
190190 * the user may have requested
191191 */
192- if (NULL != ( cptr = getenv ( "OMPI_FILE_LOCATION" )) ) {
193- opal_info_set (& ompi_mpi_info_env .info .super , "ompi_positioned_file_dir" , cptr );
192+ if (NULL != ompi_process_info . proc_session_dir ) {
193+ opal_info_set (& ompi_mpi_info_env .info .super , "ompi_positioned_file_dir" , ompi_process_info . proc_session_dir );
194194 }
195195
196196 /* All done */
@@ -334,9 +334,9 @@ static void info_constructor(ompi_info_t *info)
334334 info );
335335 info -> i_freed = false;
336336
337- /*
337+ /*
338338 * If the user doesn't want us to ever free it, then add an extra
339- * RETAIN here
339+ * RETAIN here
340340 */
341341 if (ompi_debug_no_free_handles ) {
342342 OBJ_RETAIN (& (info -> super ));
0 commit comments