Opal: add a new MCA parameter that allows the user to specify a list of environment variables. This parameter will become the standard mechanism by which environment variables are set for OMPI applications replacing the -x option.
mpirun ... -x env_foo1=val1 -x env_foo2 -x env_foo3=val3 should now be expressed as mpirun ... -mca mca_base_env_list env_foo1=val1+env_foo2+env_foo3=val3. The motivation for doing this is so that a list of environment variables may be set via standard MCA mechanisms such as mca parameter files, amca lists, etc. This feature was developed by Elena Shipunova and was reviewed by Josh Ladd. This commit was SVN r32163.
Этот коммит содержится в:
родитель
5081f958a6
Коммит
30da6d3a17
@ -121,3 +121,14 @@ starting your job.
|
||||
|
||||
Value: %s
|
||||
Source: %s
|
||||
#
|
||||
[incorrect-env-list-param]
|
||||
WARNING: The format of MCA parameter "mca_base_env_list" is a plus-sign (+) delimited
|
||||
list of VAR=VAL and/or VAR instances, e.g.: -mca mca_base_env_list VAR1=VAL1+VAR2+VAR3=VAL3;...
|
||||
If a variable, VAR, is listed but not explicitly assigned a value in the command line, VAR will
|
||||
be assigned the value set in the executing environment.
|
||||
|
||||
The following environment variable was listed unassigned in "mca_base_env_list", but was
|
||||
not found in your environment:
|
||||
Variable: %s
|
||||
MCA variable value: %s
|
||||
|
@ -62,6 +62,7 @@ static char **mca_base_var_file_list = NULL;
|
||||
static char *mca_base_var_override_file = NULL;
|
||||
static char *mca_base_var_file_prefix = NULL;
|
||||
static char *mca_base_param_file_path = NULL;
|
||||
static char *mca_base_env_list = NULL;
|
||||
static bool mca_base_var_suppress_override_warning = false;
|
||||
static opal_list_t mca_base_var_file_values;
|
||||
static opal_list_t mca_base_var_override_values;
|
||||
@ -123,6 +124,7 @@ static int mca_base_var_cache_files (bool rel_path_search);
|
||||
static int var_set_initial (mca_base_var_t *var);
|
||||
static int var_get (int vari, mca_base_var_t **var_out, bool original);
|
||||
static int var_value_string (mca_base_var_t *var, char **value_string);
|
||||
static int mca_base_var_process_env_list(void);
|
||||
|
||||
/*
|
||||
* classes
|
||||
@ -255,11 +257,61 @@ int mca_base_var_init(void)
|
||||
mca_base_var_initialized = true;
|
||||
|
||||
mca_base_var_cache_files(false);
|
||||
|
||||
/* set nesessary env variables for external usage */
|
||||
mca_base_var_process_env_list();
|
||||
}
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
static int mca_base_var_process_env_list(void)
|
||||
{
|
||||
int i, ret;
|
||||
char** tokens;
|
||||
char* ptr;
|
||||
char* param, *value;
|
||||
ret = mca_base_var_register ("opal", "mca", "base", "env_list",
|
||||
"Set SHELL env variables",
|
||||
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3,
|
||||
MCA_BASE_VAR_SCOPE_READONLY, &mca_base_env_list);
|
||||
if ((0 > ret) || (NULL == mca_base_env_list)) {
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
tokens = opal_argv_split(mca_base_env_list, '+');
|
||||
if (NULL != tokens) {
|
||||
for (i = 0; NULL != tokens[i]; i++) {
|
||||
if (NULL == (ptr = strchr(tokens[i], '='))) {
|
||||
value = getenv(tokens[i]);
|
||||
if (NULL != value) {
|
||||
if (NULL != strchr(value, '=')) {
|
||||
param = strdup(value);
|
||||
value = strchr(param, '=');
|
||||
*value = '\0';
|
||||
value++;
|
||||
opal_setenv(param, value, true, &environ);
|
||||
free(param);
|
||||
} else {
|
||||
opal_setenv(tokens[i], value, true, &environ);
|
||||
}
|
||||
} else {
|
||||
opal_show_help("help-mca-var.txt", "incorrect-env-list-param",
|
||||
true, tokens[i], mca_base_env_list);
|
||||
}
|
||||
} else {
|
||||
param = strdup(tokens[i]);
|
||||
value = strchr(param, '=');
|
||||
*value = '\0';
|
||||
value++;
|
||||
opal_setenv(param, value, true, &environ);
|
||||
free(param);
|
||||
}
|
||||
}
|
||||
opal_argv_free(tokens);
|
||||
}
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
static int mca_base_var_cache_files(bool rel_path_search)
|
||||
{
|
||||
char *tmp;
|
||||
|
@ -649,4 +649,15 @@ reached:
|
||||
The job will now be aborted. Please check your code and/or
|
||||
adjust/remove the job execution time limit (as specified
|
||||
by MPIEXEC_TIMEOUT in your environment).
|
||||
|
||||
#
|
||||
[orterun:deprecated-env-set]
|
||||
WARNING: The mechanism by which environment variables are passed to OMPI is changing!!
|
||||
Specifically, beginning in the 1.9.x/2.0.x series, using "-x" to set environment
|
||||
variables is deprecated. Please use the "mca_base_env_list" MCA parameter. With this new
|
||||
mechanism, mpirun ... -x env_foo1=bar1 -x env_foo2=bar2 -x env_foo3 ...
|
||||
becomes: mpirun ... -mca mca_base_env_list env_foo1=bar1+env_foo2=bar2+env_foo3 ...
|
||||
#
|
||||
[orterun:conflict-env-set]
|
||||
ERROR: You have attempted to pass environment variables to OMPI with both the "-x" method (deprecated starting
|
||||
in the 1.9.x/2.0.x series) and by setting the MCA parameter "mca_base_env_list". OMPI does not support mixing
|
||||
these two methods. Please choose one method and try launching your job again. You job will now abort.
|
||||
|
@ -1722,6 +1722,13 @@ static int create_app(int argc, char* argv[],
|
||||
|
||||
/* Did the user request to export any environment variables on the cmd line? */
|
||||
if (opal_cmd_line_is_taken(&cmd_line, "x")) {
|
||||
char* env_set_flag = getenv("OMPI_MCA_mca_base_env_list");
|
||||
if (NULL != env_set_flag) {
|
||||
orte_show_help("help-orterun.txt", "orterun:conflict-env-set", false);
|
||||
return ORTE_ERR_FATAL;
|
||||
} else {
|
||||
orte_show_help("help-orterun.txt", "orterun:deprecated-env-set", false);
|
||||
}
|
||||
j = opal_cmd_line_get_ninsts(&cmd_line, "x");
|
||||
for (i = 0; i < j; ++i) {
|
||||
param = opal_cmd_line_get_param(&cmd_line, "x", i, 0);
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user