Skip to content

Commit ddc1955

Browse files
authored
Merge pull request #7535 from rhc54/topic/rte
Cleanup singleton detection and data retrieval
2 parents 9ffee98 + 6b4fb50 commit ddc1955

File tree

9 files changed

+259
-235
lines changed

9 files changed

+259
-235
lines changed

ompi/attribute/attribute_predefined.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2017 Research Organization for Information Science
1515
* and Technology (RIST). All rights reserved.
16+
* Copyright (c) 2020 Intel, Inc. All rights reserved.
1617
* $COPYRIGHT$
1718
*
1819
* Additional copyrights may follow
@@ -87,6 +88,7 @@
8788
#include "ompi/errhandler/errcode.h"
8889
#include "ompi/communicator/communicator.h"
8990
#include "ompi/mca/pml/pml.h"
91+
#include "ompi/runtime/ompi_rte.h"
9092

9193
/*
9294
* Private functions
@@ -103,8 +105,6 @@ static int set_f(int keyval, MPI_Fint value);
103105
int ompi_attr_create_predefined(void)
104106
{
105107
int ret;
106-
char *univ_size;
107-
int usize;
108108

109109
/* Create all the keyvals */
110110

@@ -138,14 +138,8 @@ int ompi_attr_create_predefined(void)
138138
return ret;
139139
}
140140

141-
/* If the universe size is set, then use it. Otherwise default
142-
* to the size of MPI_COMM_WORLD */
143-
univ_size = getenv("OMPI_UNIVERSE_SIZE");
144-
if (NULL == univ_size || (usize = strtol(univ_size, NULL, 0)) <= 0) {
145-
ret = set_f(MPI_UNIVERSE_SIZE, ompi_comm_size(MPI_COMM_WORLD));
146-
} else {
147-
ret = set_f(MPI_UNIVERSE_SIZE, usize);
148-
}
141+
/* set the universe size */
142+
ret = set_f(MPI_UNIVERSE_SIZE, ompi_process_info.univ_size);
149143
if (OMPI_SUCCESS != ret) {
150144
return ret;
151145
}

ompi/info/info.c

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
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
@@ -46,11 +47,13 @@
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
*/
8689
int 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));

ompi/runtime/ompi_mpi_init.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -504,23 +504,8 @@ int ompi_mpi_init(int argc, char **argv, int requested, int *provided,
504504

505505
OMPI_TIMING_NEXT("initialization");
506506

507-
/* if we were not externally started, then we need to setup
508-
* some envars so the MPI_INFO_ENV can get the cmd name
509-
* and argv (but only if the user supplied a non-NULL argv!), and
510-
* the requested thread level
511-
*/
512-
if (NULL == getenv("OMPI_COMMAND") && NULL != argv && NULL != argv[0]) {
513-
opal_setenv("OMPI_COMMAND", argv[0], true, &environ);
514-
}
515-
if (NULL == getenv("OMPI_ARGV") && 1 < argc) {
516-
char *tmp;
517-
tmp = opal_argv_join(&argv[1], ' ');
518-
opal_setenv("OMPI_ARGV", tmp, true, &environ);
519-
free(tmp);
520-
}
521-
522507
/* Setup RTE */
523-
if (OMPI_SUCCESS != (ret = ompi_rte_init(NULL, NULL))) {
508+
if (OMPI_SUCCESS != (ret = ompi_rte_init(&argc, &argv))) {
524509
error = "ompi_mpi_init: ompi_rte_init failed";
525510
goto error;
526511
}

0 commit comments

Comments
 (0)