1
1

Check for multiple declarations of a given MCA param and error out if detected as that can create an ambiguous definition of the param value.

Refs trac:4897

This commit was SVN r32719.

The following Trac tickets were found above:
  Ticket 4897 --> https://svn.open-mpi.org/trac/ompi/ticket/4897
Этот коммит содержится в:
Ralph Castain 2014-09-12 22:21:30 +00:00
родитель dc05b709a7
Коммит 0445052a1c
2 изменённых файлов: 59 добавлений и 43 удалений

Просмотреть файл

@ -9,6 +9,7 @@
* University of Stuttgart. All rights reserved. * University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* Copyright (c) 2014 Intel, Inc. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
* Additional copyrights may follow * Additional copyrights may follow
@ -24,6 +25,7 @@
#include "opal/util/cmd_line.h" #include "opal/util/cmd_line.h"
#include "opal/util/argv.h" #include "opal/util/argv.h"
#include "opal/util/opal_environ.h" #include "opal/util/opal_environ.h"
#include "opal/util/show_help.h"
#include "opal/mca/base/base.h" #include "opal/mca/base/base.h"
#include "opal/constants.h" #include "opal/constants.h"
@ -82,50 +84,54 @@ int mca_base_cmd_line_setup(opal_cmd_line_t *cmd)
int mca_base_cmd_line_process_args(opal_cmd_line_t *cmd, int mca_base_cmd_line_process_args(opal_cmd_line_t *cmd,
char ***context_env, char ***global_env) char ***context_env, char ***global_env)
{ {
int i, num_insts; int i, num_insts, rc;
char **params; char **params;
char **values; char **values;
/* If no relevant parameters were given, just return */ /* If no relevant parameters were given, just return */
if (!opal_cmd_line_is_taken(cmd, "mca") && if (!opal_cmd_line_is_taken(cmd, "mca") &&
!opal_cmd_line_is_taken(cmd, "gmca")) { !opal_cmd_line_is_taken(cmd, "gmca")) {
return OPAL_SUCCESS; return OPAL_SUCCESS;
} }
/* Handle app context-specific parameters */ /* Handle app context-specific parameters */
num_insts = opal_cmd_line_get_ninsts(cmd, "mca"); num_insts = opal_cmd_line_get_ninsts(cmd, "mca");
params = values = NULL; params = values = NULL;
for (i = 0; i < num_insts; ++i) { for (i = 0; i < num_insts; ++i) {
process_arg(opal_cmd_line_get_param(cmd, "mca", i, 0), if (OPAL_SUCCESS != (rc = process_arg(opal_cmd_line_get_param(cmd, "mca", i, 0),
opal_cmd_line_get_param(cmd, "mca", i, 1), opal_cmd_line_get_param(cmd, "mca", i, 1),
&params, &values); &params, &values))) {
} return rc;
if (NULL != params) { }
add_to_env(params, values, context_env); }
opal_argv_free(params); if (NULL != params) {
opal_argv_free(values); add_to_env(params, values, context_env);
} opal_argv_free(params);
opal_argv_free(values);
}
/* Handle global parameters */ /* Handle global parameters */
num_insts = opal_cmd_line_get_ninsts(cmd, "gmca"); num_insts = opal_cmd_line_get_ninsts(cmd, "gmca");
params = values = NULL; params = values = NULL;
for (i = 0; i < num_insts; ++i) { for (i = 0; i < num_insts; ++i) {
process_arg(opal_cmd_line_get_param(cmd, "gmca", i, 0), if (OPAL_SUCCESS != (rc = process_arg(opal_cmd_line_get_param(cmd, "gmca", i, 0),
opal_cmd_line_get_param(cmd, "gmca", i, 1), opal_cmd_line_get_param(cmd, "gmca", i, 1),
&params, &values); &params, &values))) {
} return rc;
if (NULL != params) { }
add_to_env(params, values, global_env); }
opal_argv_free(params); if (NULL != params) {
opal_argv_free(values); add_to_env(params, values, global_env);
} opal_argv_free(params);
opal_argv_free(values);
}
/* All done */ /* All done */
return OPAL_SUCCESS; return OPAL_SUCCESS;
} }
@ -148,15 +154,23 @@ static int process_arg(const char *param, const char *value,
/* Look to see if we've already got an -mca argument for the same /* Look to see if we've already got an -mca argument for the same
param. Check against the list of MCA param's that we've param. Check against the list of MCA param's that we've
already saved arguments for - if found, REPLACE the old already saved arguments for - if found, return an error. */
argument with the new value. */
for (i = 0; NULL != *params && NULL != (*params)[i]; ++i) { for (i = 0; NULL != *params && NULL != (*params)[i]; ++i) {
if (0 == strcmp(param, (*params)[i])) { if (0 == strcmp(param, (*params)[i])) {
free((*values)[i]); /* cannot use show_help here as it may not get out prior
(*values)[i] = p1; * to the process exiting */
fprintf(stderr,
return OPAL_SUCCESS; "---------------------------------------------------------------------------\n"
"The following MCA parameter has been listed multiple times on the"
"cmd line:\n\n"
" MCA param: %s\n\n"
"MCA parameters can only be listed once on a cmd line to ensure there\n"
"is no ambiguity as to its value. Please correct the situation and\n"
"try again.\n"
"---------------------------------------------------------------------------\n",
param);
return OPAL_ERROR;
} }
} }

Просмотреть файл

@ -667,7 +667,9 @@ int orterun(int argc, char *argv[])
* Since this process can now handle MCA/GMCA parameters, make sure to * Since this process can now handle MCA/GMCA parameters, make sure to
* process them. * process them.
*/ */
mca_base_cmd_line_process_args(&cmd_line, &environ, &environ); if (OPAL_SUCCESS != mca_base_cmd_line_process_args(&cmd_line, &environ, &environ)) {
exit(1);
}
/* Ensure that enough of OPAL is setup for us to be able to run */ /* Ensure that enough of OPAL is setup for us to be able to run */
/* /*