Skip to content

Commit 5ba8344

Browse files
author
rhc54
committed
Merge pull request open-mpi#1650 from rhc54/topic/envlist
Move the registration of MCA params out of the init of the var system…
2 parents 5ec1eed + 42ecffb commit 5ba8344

File tree

21 files changed

+157
-103
lines changed

21 files changed

+157
-103
lines changed

opal/mca/base/mca_base_parse_paramfile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "opal/mca/base/base.h"
3030
#include "opal/mca/base/mca_base_vari.h"
3131
#include "opal/util/keyval_parse.h"
32-
32+
#include "opal/util/output.h"
3333
static void save_value(const char *name, const char *value);
3434

3535
static char * file_being_read;

opal/mca/base/mca_base_var.c

Lines changed: 15 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,9 @@ static char *mca_base_var_override_file = NULL;
6666
static char *mca_base_var_file_prefix = NULL;
6767
static char *mca_base_envar_file_prefix = NULL;
6868
static char *mca_base_param_file_path = NULL;
69-
static char *mca_base_env_list = NULL;
70-
#define MCA_BASE_ENV_LIST_SEP_DEFAULT ";"
71-
static char *mca_base_env_list_sep = MCA_BASE_ENV_LIST_SEP_DEFAULT;
72-
static char *mca_base_env_list_internal = NULL;
69+
char *mca_base_env_list = NULL;
70+
char *mca_base_env_list_sep = MCA_BASE_ENV_LIST_SEP_DEFAULT;
71+
char *mca_base_env_list_internal = NULL;
7372
static bool mca_base_var_suppress_override_warning = false;
7473
static opal_list_t mca_base_var_file_values;
7574
static opal_list_t mca_base_envar_file_values;
@@ -130,7 +129,6 @@ static const char *info_lvl_strings[] = {
130129
*/
131130
static int fixup_files(char **file_list, char * path, bool rel_path_search, char sep);
132131
static int read_files (char *file_list, opal_list_t *file_values, char sep);
133-
static int mca_base_var_cache_files (bool rel_path_search);
134132
static int var_set_initial (mca_base_var_t *var, mca_base_var_t *original);
135133
static int var_get (int vari, mca_base_var_t **var_out, bool original);
136134
static int var_value_string (mca_base_var_t *var, char **value_string);
@@ -242,7 +240,6 @@ static char *append_filename_to_list(const char *filename)
242240
int mca_base_var_init(void)
243241
{
244242
int ret;
245-
char *name = NULL;
246243

247244
if (!mca_base_var_initialized) {
248245
/* Init the value array for the param storage */
@@ -282,41 +279,6 @@ int mca_base_var_init(void)
282279

283280
mca_base_var_initialized = true;
284281

285-
mca_base_var_cache_files(false);
286-
287-
/* register the envar-forwarding params */
288-
(void)mca_base_var_register ("opal", "mca", "base", "env_list",
289-
"Set SHELL env variables",
290-
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3,
291-
MCA_BASE_VAR_SCOPE_READONLY, &mca_base_env_list);
292-
293-
mca_base_env_list_sep = MCA_BASE_ENV_LIST_SEP_DEFAULT;
294-
(void)mca_base_var_register ("opal", "mca", "base", "env_list_delimiter",
295-
"Set SHELL env variables delimiter. Default: semicolon ';'",
296-
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3,
297-
MCA_BASE_VAR_SCOPE_READONLY, &mca_base_env_list_sep);
298-
299-
/* Set OMPI_MCA_mca_base_env_list variable, it might not be set before
300-
* if mca variable was taken from amca conf file. Need to set it
301-
* here because mca_base_var_process_env_list is called from schizo_ompi.c
302-
* only when this env variable was set.
303-
*/
304-
if (NULL != mca_base_env_list) {
305-
(void) mca_base_var_env_name ("mca_base_env_list", &name);
306-
if (NULL != name) {
307-
opal_setenv(name, mca_base_env_list, false, &environ);
308-
free(name);
309-
}
310-
}
311-
312-
/* Register internal MCA variable mca_base_env_list_internal. It can be set only during
313-
* parsing of amca conf file and contains SHELL env variables specified via -x there.
314-
* Its format is the same as for mca_base_env_list.
315-
*/
316-
(void)mca_base_var_register ("opal", "mca", "base", "env_list_internal",
317-
"Store SHELL env variables from amca conf file",
318-
MCA_BASE_VAR_TYPE_STRING, NULL, 0, MCA_BASE_VAR_FLAG_INTERNAL, OPAL_INFO_LVL_3,
319-
MCA_BASE_VAR_SCOPE_READONLY, &mca_base_env_list_internal);
320282
}
321283

322284
return OPAL_SUCCESS;
@@ -419,15 +381,15 @@ static void resolve_relative_paths(char **file_prefix, char *file_path, bool rel
419381
}
420382
}
421383

422-
static int mca_base_var_cache_files(bool rel_path_search)
384+
int mca_base_var_cache_files(bool rel_path_search)
423385
{
424386
char *tmp;
425387
int ret;
426388

427389
/* We may need this later */
428390
home = (char*)opal_home_directory();
429391

430-
if(NULL == cwd) {
392+
if (NULL == cwd) {
431393
cwd = (char *) malloc(sizeof(char) * MAXPATHLEN);
432394
if( NULL == (cwd = getcwd(cwd, MAXPATHLEN) )) {
433395
opal_output(0, "Error: Unable to get the current working directory\n");
@@ -452,7 +414,8 @@ static int mca_base_var_cache_files(bool rel_path_search)
452414
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_2,
453415
MCA_BASE_VAR_SCOPE_READONLY, &mca_base_var_files);
454416
free (tmp);
455-
if (OPAL_SUCCESS != ret) {
417+
if (0 > ret) {
418+
opal_output(0, "FAILED PARAM FILES: %d", ret);
456419
return ret;
457420
}
458421

@@ -464,6 +427,7 @@ static int mca_base_var_cache_files(bool rel_path_search)
464427
ret = asprintf(&mca_base_var_override_file, "%s" OPAL_PATH_SEP "openmpi-mca-params-override.conf",
465428
opal_install_dirs.sysconfdir);
466429
if (0 > ret) {
430+
opal_output(0, "FAILED OVERRIDE");
467431
return OPAL_ERR_OUT_OF_RESOURCE;
468432
}
469433

@@ -476,6 +440,7 @@ static int mca_base_var_cache_files(bool rel_path_search)
476440
&mca_base_var_override_file);
477441
free (tmp);
478442
if (0 > ret) {
443+
opal_output(0, "FAILED OVERRIDE PARAM FILES");
479444
return ret;
480445
}
481446

@@ -490,6 +455,7 @@ static int mca_base_var_cache_files(bool rel_path_search)
490455
MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, OPAL_INFO_LVL_2,
491456
MCA_BASE_VAR_SCOPE_LOCAL, &mca_base_var_suppress_override_warning);
492457
if (0 > ret) {
458+
opal_output(0, "FAILED OVERRIDE WARNING");
493459
return ret;
494460
}
495461

@@ -503,6 +469,7 @@ static int mca_base_var_cache_files(bool rel_path_search)
503469
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3,
504470
MCA_BASE_VAR_SCOPE_READONLY, &mca_base_var_file_prefix);
505471
if (0 > ret) {
472+
opal_output(0, "FAILED PARAM PREFIX");
506473
return ret;
507474
}
508475

@@ -512,12 +479,14 @@ static int mca_base_var_cache_files(bool rel_path_search)
512479
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3,
513480
MCA_BASE_VAR_SCOPE_READONLY, &mca_base_envar_file_prefix);
514481
if (0 > ret) {
482+
opal_output(0, "FAILED ENV PREFIX");
515483
return ret;
516484
}
517485

518486
ret = asprintf(&mca_base_param_file_path, "%s" OPAL_PATH_SEP "amca-param-sets%c%s",
519487
opal_install_dirs.opaldatadir, OPAL_ENV_SEP, cwd);
520488
if (0 > ret) {
489+
opal_output(0, "FAILED PARAM FILE PATH");
521490
return OPAL_ERR_OUT_OF_RESOURCE;
522491
}
523492

@@ -528,6 +497,7 @@ static int mca_base_var_cache_files(bool rel_path_search)
528497
MCA_BASE_VAR_SCOPE_READONLY, &mca_base_param_file_path);
529498
free (tmp);
530499
if (0 > ret) {
500+
opal_output(0, "FAILED PARAM FILE PATH2");
531501
return ret;
532502
}
533503

@@ -537,6 +507,7 @@ static int mca_base_var_cache_files(bool rel_path_search)
537507
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3,
538508
MCA_BASE_VAR_SCOPE_READONLY, &force_agg_path);
539509
if (0 > ret) {
510+
opal_output(0, "FAILED PARAM FILE FORCE");
540511
return ret;
541512
}
542513

opal/mca/base/mca_base_var.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,17 @@ OPAL_DECLSPEC int mca_base_var_dump(int vari, char ***out, mca_base_var_dump_typ
733733
OPAL_DECLSPEC int mca_base_var_process_env_list(char *list, char ***argv);
734734
OPAL_DECLSPEC int mca_base_var_process_env_list_from_file(char ***argv);
735735

736+
/*
737+
* Initialize any file-based params
738+
*/
739+
OPAL_DECLSPEC int mca_base_var_cache_files(bool rel_path_search);
740+
741+
742+
extern char *mca_base_env_list;
743+
#define MCA_BASE_ENV_LIST_SEP_DEFAULT ";"
744+
extern char *mca_base_env_list_sep;
745+
extern char *mca_base_env_list_internal;
746+
736747
END_C_DECLS
737748

738749
#endif /* OPAL_MCA_BASE_VAR_H */

opal/runtime/opal_info_support.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
1313
* Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved.
14-
* Copyright (c) 2010-2015 Los Alamos National Security, LLC.
15-
* All rights reserved.
14+
* Copyright (c) 2010-2016 Los Alamos National Security, LLC. All rights
15+
* reserved.
1616
* Copyright (c) 2011-2012 University of Houston. All rights reserved.
1717
* $COPYRIGHT$
1818
*
@@ -174,7 +174,7 @@ int opal_info_init(int argc, char **argv,
174174
}
175175

176176
/* Do the parsing */
177-
ret = opal_cmd_line_parse(opal_info_cmd_line, false, argc, argv);
177+
ret = opal_cmd_line_parse(opal_info_cmd_line, false, false, argc, argv);
178178
if (OPAL_SUCCESS != ret) {
179179
cmd_error = true;
180180
if (OPAL_ERR_SILENT != ret) {

opal/runtime/opal_init.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "opal/util/proc.h"
4141
#include "opal/memoryhooks/memory.h"
4242
#include "opal/mca/base/base.h"
43+
#include "opal/mca/base/mca_base_var.h"
4344
#include "opal/runtime/opal.h"
4445
#include "opal/util/net.h"
4546
#include "opal/datatype/opal_datatype.h"
@@ -414,6 +415,13 @@ opal_init(int* pargc, char*** pargv)
414415
return ret;
415416
}
416417

418+
/* read any param files that were provided */
419+
if (OPAL_SUCCESS != (ret = mca_base_var_cache_files(false))) {
420+
error = "failed to cache files";
421+
goto return_error;
422+
}
423+
424+
417425
/* open hwloc - since this is a static framework, no
418426
* select is required
419427
*/

opal/runtime/opal_params.c

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "opal/mca/base/mca_base_var.h"
4444
#include "opal/runtime/opal_params.h"
4545
#include "opal/dss/dss.h"
46+
#include "opal/util/opal_environ.h"
4647
#include "opal/util/show_help.h"
4748
#include "opal/util/timings.h"
4849

@@ -292,7 +293,7 @@ int opal_register_params(void)
292293
MCA_BASE_VAR_SCOPE_READONLY,
293294
&opal_abort_delay);
294295
if (0 > ret) {
295-
return ret;
296+
return ret;
296297
}
297298

298299
opal_abort_print_stack = false;
@@ -313,9 +314,44 @@ int opal_register_params(void)
313314
#endif
314315
&opal_abort_print_stack);
315316
if (0 > ret) {
316-
return ret;
317+
return ret;
318+
}
319+
320+
/* register the envar-forwarding params */
321+
(void)mca_base_var_register ("opal", "mca", "base", "env_list",
322+
"Set SHELL env variables",
323+
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3,
324+
MCA_BASE_VAR_SCOPE_READONLY, &mca_base_env_list);
325+
326+
mca_base_env_list_sep = MCA_BASE_ENV_LIST_SEP_DEFAULT;
327+
(void)mca_base_var_register ("opal", "mca", "base", "env_list_delimiter",
328+
"Set SHELL env variables delimiter. Default: semicolon ';'",
329+
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3,
330+
MCA_BASE_VAR_SCOPE_READONLY, &mca_base_env_list_sep);
331+
332+
/* Set OMPI_MCA_mca_base_env_list variable, it might not be set before
333+
* if mca variable was taken from amca conf file. Need to set it
334+
* here because mca_base_var_process_env_list is called from schizo_ompi.c
335+
* only when this env variable was set.
336+
*/
337+
if (NULL != mca_base_env_list) {
338+
char *name = NULL;
339+
(void) mca_base_var_env_name ("mca_base_env_list", &name);
340+
if (NULL != name) {
341+
opal_setenv(name, mca_base_env_list, false, &environ);
342+
free(name);
343+
}
317344
}
318345

346+
/* Register internal MCA variable mca_base_env_list_internal. It can be set only during
347+
* parsing of amca conf file and contains SHELL env variables specified via -x there.
348+
* Its format is the same as for mca_base_env_list.
349+
*/
350+
(void)mca_base_var_register ("opal", "mca", "base", "env_list_internal",
351+
"Store SHELL env variables from amca conf file",
352+
MCA_BASE_VAR_TYPE_STRING, NULL, 0, MCA_BASE_VAR_FLAG_INTERNAL, OPAL_INFO_LVL_3,
353+
MCA_BASE_VAR_SCOPE_READONLY, &mca_base_env_list_internal);
354+
319355
/* The ddt engine has a few parameters */
320356
ret = opal_datatype_register_params();
321357
if (OPAL_SUCCESS != ret) {

opal/tools/opal-checkpoint/opal-checkpoint.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* University of Stuttgart. All rights reserved.
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
13-
* Copyright (c) 2007-2013 Los Alamos National Security, LLC. All rights
13+
* Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights
1414
* reserved.
1515
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
1616
* $COPYRIGHT$
@@ -283,7 +283,7 @@ static int parse_args(int argc, char *argv[]) {
283283
opal_cmd_line_create(&cmd_line, cmd_line_opts);
284284
mca_base_open();
285285
mca_base_cmd_line_setup(&cmd_line);
286-
ret = opal_cmd_line_parse(&cmd_line, true, argc, argv);
286+
ret = opal_cmd_line_parse(&cmd_line, true, false, argc, argv);
287287

288288
if (OPAL_SUCCESS != ret) {
289289
if (OPAL_ERR_SILENT != ret) {

opal/tools/opal-restart/opal-restart.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* University of Stuttgart. All rights reserved.
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
13-
* Copyright (c) 2007-2013 Los Alamos National Security, LLC. All rights
13+
* Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights
1414
* reserved.
1515
* Copyright (c) 2007 Evergrid, Inc. All rights reserved.
1616
* Copyright (c) 2011 Oak Ridge National Labs. All rights reserved.
@@ -522,7 +522,7 @@ static int parse_args(int argc, char *argv[])
522522

523523
mca_base_open();
524524
mca_base_cmd_line_setup(&cmd_line);
525-
ret = opal_cmd_line_parse(&cmd_line, false, argc, argv);
525+
ret = opal_cmd_line_parse(&cmd_line, false, false, argc, argv);
526526
if (OPAL_SUCCESS != ret) {
527527
if (OPAL_ERR_SILENT != ret) {
528528
fprintf(stderr, "%s: command line error (%s)\n", argv[0],

opal/util/cmd_line.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
12
/*
23
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
34
* University Research and Technology
@@ -9,8 +10,8 @@
910
* University of Stuttgart. All rights reserved.
1011
* Copyright (c) 2004-2005 The Regents of the University of California.
1112
* All rights reserved.
12-
* Copyright (c) 2012 Los Alamos National Security, LLC.
13-
* All rights reserved.
13+
* Copyright (c) 2012-2016 Los Alamos National Security, LLC. All rights
14+
* reserved.
1415
* Copyright (c) 2012-2015 Cisco Systems, Inc. All rights reserved.
1516
* Copyright (c) 2015 Research Organization for Information Science
1617
* and Technology (RIST). All rights reserved.
@@ -239,7 +240,7 @@ int opal_cmd_line_make_opt3(opal_cmd_line_t *cmd, char short_name,
239240
* Parse a command line according to a pre-built OPAL command line
240241
* handle.
241242
*/
242-
int opal_cmd_line_parse(opal_cmd_line_t *cmd, bool ignore_unknown,
243+
int opal_cmd_line_parse(opal_cmd_line_t *cmd, bool ignore_unknown, bool ignore_unknown_option,
243244
int argc, char **argv)
244245
{
245246
int i, j, orig, ret;
@@ -345,7 +346,7 @@ int opal_cmd_line_parse(opal_cmd_line_t *cmd, bool ignore_unknown,
345346

346347
if (NULL != option) {
347348
opal_argv_delete(&cmd->lcl_argc,
348-
&cmd->lcl_argv, i,
349+
&cmd->lcl_argv, i,
349350
1 + num_args_used);
350351
opal_argv_insert(&cmd->lcl_argv, i, shortsv);
351352
cmd->lcl_argc = opal_argv_count(cmd->lcl_argv);
@@ -476,7 +477,7 @@ int opal_cmd_line_parse(opal_cmd_line_t *cmd, bool ignore_unknown,
476477
into the tail. If we're not ignoring unknowns, then print
477478
an error and return. */
478479
if (is_unknown_option || is_unknown_token) {
479-
if (!ignore_unknown || is_unknown_option) {
480+
if (!ignore_unknown || (is_unknown_option && !ignore_unknown_option)) {
480481
fprintf(stderr, "%s: Error: unknown option \"%s\"\n",
481482
cmd->lcl_argv[0], cmd->lcl_argv[i]);
482483
printed_error = true;

0 commit comments

Comments
 (0)