19
19
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
20
20
* Copyright (c) 2019 Triad National Security, LLC. All rights
21
21
* reserved.
22
+ * Copyright (c) 2020 Intel, Inc. All rights reserved.
22
23
* $COPYRIGHT$
23
24
*
24
25
* Additional copyrights may follow
46
47
#include "opal/util/argv.h"
47
48
#include "opal/util/opal_getcwd.h"
48
49
#include "opal/util/output.h"
50
+ #include "opal/util/printf.h"
49
51
#include "opal/util/info.h"
50
52
51
53
#include "ompi/info/info.h"
52
54
#include "ompi/runtime/mpiruntime.h"
53
55
#include "ompi/runtime/params.h"
56
+ #include "ompi/runtime/ompi_rte.h"
54
57
55
58
/*
56
59
* Global variables
@@ -85,8 +88,7 @@ opal_pointer_array_t ompi_info_f_to_c_table = {{0}};
85
88
*/
86
89
int ompi_mpiinfo_init (void )
87
90
{
88
- const char * val ;
89
- char * cptr ;
91
+ char * cptr , * * tmp ;
90
92
91
93
/* initialize table */
92
94
@@ -107,45 +109,43 @@ int ompi_mpiinfo_init(void)
107
109
/* fill the env info object */
108
110
109
111
/* 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 );
116
123
opal_info_set (& ompi_mpi_info_env .info .super , "argv" , cptr );
124
+ free (cptr );
117
125
}
118
126
119
127
/* 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 );
125
133
126
134
/* 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 );
129
136
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
- }
134
137
#ifdef HAVE_SYS_UTSNAME_H
135
- else {
138
+ {
136
139
struct utsname sysname ;
137
140
uname (& sysname );
138
141
cptr = sysname .machine ;
139
142
opal_info_set (& ompi_mpi_info_env .info .super , "arch" , cptr );
140
143
}
141
144
#endif
142
145
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 );
149
149
}
150
150
151
151
/* provide the REQUESTED thread level - may be different
@@ -172,25 +172,25 @@ int ompi_mpiinfo_init(void)
172
172
/**** now some OMPI-specific values that other MPIs may not provide ****/
173
173
174
174
/* 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 );
178
178
179
179
/* 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 );
182
182
}
183
183
184
184
/* 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 );
187
187
}
188
188
189
189
/* location of the directory containing any prepositioned files
190
190
* the user may have requested
191
191
*/
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 );
194
194
}
195
195
196
196
/* All done */
@@ -334,9 +334,9 @@ static void info_constructor(ompi_info_t *info)
334
334
info );
335
335
info -> i_freed = false;
336
336
337
- /*
337
+ /*
338
338
* If the user doesn't want us to ever free it, then add an extra
339
- * RETAIN here
339
+ * RETAIN here
340
340
*/
341
341
if (ompi_debug_no_free_handles ) {
342
342
OBJ_RETAIN (& (info -> super ));
0 commit comments