1
1

Extend the mca param display capability to allow independent output of the params based on where they were last set (default, enviro, file, or API), and to out

put the name of the file that set them if they were set by file. This is of great assistance to support personnel trying to understand why a user is having pro
blems.

Coordinated with Jeff.

This commit was SVN r19111.
Этот коммит содержится в:
Ralph Castain 2008-07-31 20:00:45 +00:00
родитель dbafe83999
Коммит f7d1c2d229
6 изменённых файлов: 214 добавлений и 85 удалений

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

@ -57,9 +57,15 @@ bool ompi_mpi_leave_pinned_pipeline = false;
bool ompi_have_sparse_group_storage = OPAL_INT_TO_BOOL(OMPI_GROUP_SPARSE);
bool ompi_use_sparse_group_storage = OPAL_INT_TO_BOOL(OMPI_GROUP_SPARSE);
static bool show_default_mca_params = false;
static bool show_file_mca_params = false;
static bool show_enviro_mca_params = false;
static bool show_override_mca_params = false;
int ompi_mpi_register_params(void)
{
int value;
char *param;
/* Whether we want MPI API function parameter checking or not */
@ -132,11 +138,27 @@ int ompi_mpi_register_params(void)
&ompi_debug_show_mpi_alloc_mem_leaks);
/* Whether or not to print all MCA parameters in MPI_INIT */
mca_base_param_reg_int_name("mpi", "show_mca_params",
"Whether to show all MCA parameter value during MPI_INIT or not (good for reproducability of MPI jobs)",
false, false,
(int) ompi_mpi_show_mca_params, &value);
ompi_mpi_show_mca_params = OPAL_INT_TO_BOOL(value);
mca_base_param_reg_string_name("mpi", "show_mca_params",
"Whether to show all MCA parameter values during MPI_INIT or not (good for reproducability of MPI jobs "
"for debug purposes). Accepted values are all, default, file, api, and enviro",
false, false, NULL, &param);
if (NULL != param) {
ompi_mpi_show_mca_params = true;
if (0 == strcmp(param, "all")) {
show_default_mca_params = true;
show_file_mca_params = true;
show_enviro_mca_params = true;
show_override_mca_params = true;
} else if (0 == strcmp(param, "default")) {
show_default_mca_params = true;
} else if (0 == strcmp(param, "file")) {
show_file_mca_params = true;
} else if (0 == strcmp(param, "enviro")) {
show_enviro_mca_params = true;
} else if (0 == strcmp(param, "api")) {
show_override_mca_params = true;
}
}
/* File to use when dumping the parameters */
mca_base_param_reg_string_name("mpi", "show_mca_params_file",
@ -262,64 +284,131 @@ int ompi_mpi_register_params(void)
}
int ompi_show_all_mca_params(int32_t rank, int requested, char *nodename) {
opal_list_t *info;
opal_list_item_t *i;
mca_base_param_info_t *item;
char *value_string;
int value_int;
FILE *fp = NULL;
time_t timestamp;
if (rank != 0) {
return OMPI_SUCCESS;
}
timestamp = time(NULL);
/* Open the file if one is specified */
if (0 != strlen(ompi_mpi_show_mca_params_file)) {
if ( NULL == (fp = fopen(ompi_mpi_show_mca_params_file, "w")) ) {
opal_output(0, "Unable to open file <%s> to write MCA parameters", ompi_mpi_show_mca_params_file);
return OMPI_ERR_FILE_OPEN_FAILURE;
}
fprintf(fp, "#\n");
fprintf(fp, "# This file was automatically generated on %s", ctime(&timestamp));
fprintf(fp, "# by MPI_COMM_WORLD rank %d (out of a total of %d) on %s\n", rank, requested, nodename );
fprintf(fp, "#\n");
}
mca_base_param_dump(&info, false);
for (i = opal_list_get_first(info);
i != opal_list_get_last(info);
i = opal_list_get_next(i)) {
item = (mca_base_param_info_t*) i;
/* Get the parameter name, and convert it to a printable string */
if (MCA_BASE_PARAM_TYPE_STRING == item->mbpp_type) {
mca_base_param_lookup_string(item->mbpp_index, &value_string);
if (NULL == value_string) {
value_string = strdup("");
}
} else {
mca_base_param_lookup_int(item->mbpp_index, &value_int);
asprintf(&value_string, "%d", value_int);
}
/* Print the parameter */
if (0 != strlen(ompi_mpi_show_mca_params_file)) {
fprintf(fp, "%s=%s\n", item->mbpp_full_name, value_string);
} else {
opal_output(0, "%s=%s", item->mbpp_full_name, value_string);
}
free(value_string);
}
/* Close file, cleanup allocated memory*/
if (0 != strlen(ompi_mpi_show_mca_params_file)) {
fclose(fp);
}
mca_base_param_dump_release(info);
return OMPI_SUCCESS;
opal_list_t *info;
opal_list_item_t *i;
mca_base_param_info_t *item;
char *value_string;
int value_int;
FILE *fp = NULL;
time_t timestamp;
mca_base_param_source_t source;
char *src_file;
char *src_string;
if (rank != 0) {
return OMPI_SUCCESS;
}
timestamp = time(NULL);
/* Open the file if one is specified */
if (0 != strlen(ompi_mpi_show_mca_params_file)) {
if ( NULL == (fp = fopen(ompi_mpi_show_mca_params_file, "w")) ) {
opal_output(0, "Unable to open file <%s> to write MCA parameters", ompi_mpi_show_mca_params_file);
return OMPI_ERR_FILE_OPEN_FAILURE;
}
fprintf(fp, "#\n");
fprintf(fp, "# This file was automatically generated on %s", ctime(&timestamp));
fprintf(fp, "# by MPI_COMM_WORLD rank %d (out of a total of %d) on %s\n", rank, requested, nodename );
fprintf(fp, "#\n");
}
mca_base_param_dump(&info, false);
for (i = opal_list_get_first(info);
i != opal_list_get_last(info);
i = opal_list_get_next(i)) {
item = (mca_base_param_info_t*) i;
/* get the source - where the param was last set */
if (OPAL_SUCCESS !=
mca_base_param_lookup_source(item->mbpp_index, &source, &src_file)) {
continue;
}
/* is this a default value and we are not displaying
* defaults, ignore this one
*/
if (MCA_BASE_PARAM_SOURCE_DEFAULT == source && !show_default_mca_params) {
continue;
}
/* is this a file value and we are not displaying files,
* ignore it
*/
if (MCA_BASE_PARAM_SOURCE_FILE == source && !show_file_mca_params) {
continue;
}
/* is this an enviro value and we are not displaying enviros,
* ignore it
*/
if (MCA_BASE_PARAM_SOURCE_ENV == source && !show_enviro_mca_params) {
continue;
}
/* is this an API value and we are not displaying APIs,
* ignore it
*/
if (MCA_BASE_PARAM_SOURCE_OVERRIDE == source && !show_override_mca_params) {
continue;
}
/* Get the parameter name, and convert it to a printable string */
if (MCA_BASE_PARAM_TYPE_STRING == item->mbpp_type) {
mca_base_param_lookup_string(item->mbpp_index, &value_string);
if (NULL == value_string) {
value_string = strdup("");
}
} else {
mca_base_param_lookup_int(item->mbpp_index, &value_int);
asprintf(&value_string, "%d", value_int);
}
switch(source) {
case MCA_BASE_PARAM_SOURCE_DEFAULT:
src_string = "default value";
break;
case MCA_BASE_PARAM_SOURCE_ENV:
src_string = "environment";
break;
case MCA_BASE_PARAM_SOURCE_FILE:
src_string = "file";
break;
case MCA_BASE_PARAM_SOURCE_OVERRIDE:
src_string = "API override";
break;
default:
src_string = NULL;
break;
}
/* Print the parameter */
if (0 != strlen(ompi_mpi_show_mca_params_file)) {
if (NULL == src_file) {
fprintf(fp, "%s=%s (%s)\n", item->mbpp_full_name, value_string,
(NULL != src_string ? src_string : "unknown"));
} else {
fprintf(fp, "%s=%s (%s:%s)\n", item->mbpp_full_name, value_string,
(NULL != src_string ? src_string : "unknown"), src_file);
}
} else {
if (NULL == src_file) {
opal_output(0, "%s=%s (%s)\n", item->mbpp_full_name, value_string,
(NULL != src_string ? src_string : "unknown"));
} else {
opal_output(0, "%s=%s (%s:%s)\n", item->mbpp_full_name, value_string,
(NULL != src_string ? src_string : "unknown"), src_file);
}
}
free(value_string);
}
/* Close file, cleanup allocated memory*/
if (0 != strlen(ompi_mpi_show_mca_params_file)) {
fclose(fp);
}
mca_base_param_dump_release(info);
return OMPI_SUCCESS;
}

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

@ -150,6 +150,7 @@ void ompi_info::show_mca_params(opal_list_t *info,
string message, content, tmp;
int value_int, j;
mca_base_param_source_t source;
char *src_file;
for (i = opal_list_get_first(info); i != opal_list_get_last(info);
i = opal_list_get_next(i)) {
@ -163,7 +164,7 @@ void ompi_info::show_mca_params(opal_list_t *info,
// Find the source of the value
if (OPAL_SUCCESS !=
mca_base_param_lookup_source(p->mbpp_index, &source)) {
mca_base_param_lookup_source(p->mbpp_index, &source, &src_file)) {
continue;
}
@ -222,7 +223,9 @@ void ompi_info::show_mca_params(opal_list_t *info,
content += "environment";
break;
case MCA_BASE_PARAM_SOURCE_FILE:
content += "file";
content += "file [";
content += src_file;
content += "]";
break;
case MCA_BASE_PARAM_SOURCE_OVERRIDE:
content += "API override";

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

@ -113,7 +113,8 @@ static int syn_register(int index_orig, const char *syn_type_name,
const char *syn_param_name, bool deprecated);
static bool param_lookup(size_t index, mca_base_param_storage_t *storage,
opal_hash_table_t *attrs,
mca_base_param_source_t *source);
mca_base_param_source_t *source,
char **source_file);
static bool param_set_override(size_t index,
mca_base_param_storage_t *storage,
mca_base_param_type_t type);
@ -122,7 +123,8 @@ static bool lookup_override(mca_base_param_t *param,
static bool lookup_env(mca_base_param_t *param,
mca_base_param_storage_t *storage);
static bool lookup_file(mca_base_param_t *param,
mca_base_param_storage_t *storage);
mca_base_param_storage_t *storage,
char **source_file);
static bool lookup_default(mca_base_param_t *param,
mca_base_param_storage_t *storage);
static bool set(mca_base_param_type_t type,
@ -480,7 +482,7 @@ int mca_base_param_lookup_int(int index, int *value)
{
mca_base_param_storage_t storage;
if (param_lookup(index, &storage, NULL, NULL)) {
if (param_lookup(index, &storage, NULL, NULL, NULL)) {
*value = storage.intval;
return OPAL_SUCCESS;
}
@ -509,7 +511,7 @@ int mca_base_param_lookup_string(int index, char **value)
{
mca_base_param_storage_t storage;
if (param_lookup(index, &storage, NULL, NULL)) {
if (param_lookup(index, &storage, NULL, NULL, NULL)) {
*value = storage.stringval;
return OPAL_SUCCESS;
}
@ -534,11 +536,11 @@ int mca_base_param_set_string(int index, char *value)
/*
* Lookup the source of an MCA param's value
*/
bool mca_base_param_lookup_source(int index, mca_base_param_source_t *source)
bool mca_base_param_lookup_source(int index, mca_base_param_source_t *source, char **source_file)
{
mca_base_param_storage_t storage;
if (param_lookup(index, &storage, NULL, source)) {
if (param_lookup(index, &storage, NULL, source, source_file)) {
return OPAL_SUCCESS;
}
return OPAL_ERROR;
@ -832,7 +834,7 @@ int mca_base_param_build_env(char ***env, int *num_env, bool internal)
}
if (array[i].mbp_internal == internal || internal) {
if (param_lookup(i, &storage, NULL, NULL)) {
if (param_lookup(i, &storage, NULL, NULL, NULL)) {
if (MCA_BASE_PARAM_TYPE_INT == array[i].mbp_type) {
asprintf(&str, "%s=%d", array[i].mbp_env_var_name,
storage.intval);
@ -1493,7 +1495,7 @@ static int param_register(const char *type_name,
/* Finally, if we have a lookup value, look it up */
if (NULL != current_value) {
if (!param_lookup(i, current_value, NULL, NULL)) {
if (!param_lookup(i, current_value, NULL, NULL, NULL)) {
return OPAL_ERR_NOT_FOUND;
}
}
@ -1517,7 +1519,7 @@ static int param_register(const char *type_name,
/* Finally, if we have a lookup value, look it up */
if (NULL != current_value) {
if (!param_lookup(ret, current_value, NULL, NULL)) {
if (!param_lookup(ret, current_value, NULL, NULL, NULL)) {
return OPAL_ERR_NOT_FOUND;
}
}
@ -1688,13 +1690,19 @@ static bool param_set_override(size_t index,
*/
static bool param_lookup(size_t index, mca_base_param_storage_t *storage,
opal_hash_table_t *attrs,
mca_base_param_source_t *source_param)
mca_base_param_source_t *source_param,
char **source_file)
{
size_t size;
mca_base_param_t *array;
char *p, *q;
mca_base_param_source_t source = MCA_BASE_PARAM_SOURCE_MAX;
/* default the value */
if (NULL != source_file) {
*source_file = NULL;
}
/* Lookup the index and see if it's valid */
if (!initialized) {
@ -1720,7 +1728,7 @@ static bool param_lookup(size_t index, mca_base_param_storage_t *storage,
if (array[index].mbp_read_only) {
if (lookup_override(&array[index], storage) ||
lookup_env(&array[index], storage) ||
lookup_file(&array[index], storage)) {
lookup_file(&array[index], storage, source_file)) {
opal_show_help("help-mca-param.txt", "read-only-param-set",
true, array[index].mbp_full_name);
}
@ -1734,7 +1742,7 @@ static bool param_lookup(size_t index, mca_base_param_storage_t *storage,
source = MCA_BASE_PARAM_SOURCE_OVERRIDE;
} else if (lookup_env(&array[index], storage)) {
source = MCA_BASE_PARAM_SOURCE_ENV;
} else if (lookup_file(&array[index], storage)) {
} else if (lookup_file(&array[index], storage, source_file)) {
source = MCA_BASE_PARAM_SOURCE_FILE;
} else if (lookup_default(&array[index], storage)) {
source = MCA_BASE_PARAM_SOURCE_DEFAULT;
@ -1874,7 +1882,8 @@ static bool lookup_env(mca_base_param_t *param,
* Lookup a param in the files
*/
static bool lookup_file(mca_base_param_t *param,
mca_base_param_storage_t *storage)
mca_base_param_storage_t *storage,
char **source_file)
{
bool found = false;
syn_info_t *si;
@ -1887,6 +1896,9 @@ static bool lookup_file(mca_base_param_t *param,
return that */
if (param->mbp_file_value_set) {
if (NULL != source_file) {
*source_file = param->mbp_source_file;
}
return set(param->mbp_type, storage, &param->mbp_file_value);
}
@ -1945,6 +1957,9 @@ static bool lookup_file(mca_base_param_t *param,
param->mbp_file_value.stringval = fv->mbpfv_value;
fv->mbpfv_value = NULL;
}
if (NULL != fv->mbpfv_file) {
param->mbp_source_file = strdup(fv->mbpfv_file);
}
param->mbp_file_value_set = true;
/* Since this is now cached on the param, we might as well
@ -2027,6 +2042,7 @@ static void param_constructor(mca_base_param_t *p)
p->mbp_default_value.stringval = NULL;
p->mbp_file_value_set = false;
p->mbp_file_value.stringval = NULL;
p->mbp_source_file = NULL;
p->mbp_override_value_set = false;
p->mbp_override_value.stringval = NULL;
@ -2063,9 +2079,13 @@ static void param_destructor(mca_base_param_t *p)
if (NULL != p->mbp_default_value.stringval) {
free(p->mbp_default_value.stringval);
}
if (p->mbp_file_value_set &&
NULL != p->mbp_file_value.stringval) {
free(p->mbp_file_value.stringval);
if (p->mbp_file_value_set) {
if (NULL != p->mbp_file_value.stringval) {
free(p->mbp_file_value.stringval);
}
if (NULL != p->mbp_source_file) {
free(p->mbp_source_file);
}
}
if (p->mbp_override_value_set &&
NULL != p->mbp_override_value.stringval) {
@ -2093,6 +2113,7 @@ static void fv_constructor(mca_base_param_file_value_t *f)
{
f->mbpfv_param = NULL;
f->mbpfv_value = NULL;
f->mbpfv_file = NULL;
}
@ -2104,6 +2125,9 @@ static void fv_destructor(mca_base_param_file_value_t *f)
if (NULL != f->mbpfv_value) {
free(f->mbpfv_value);
}
if (NULL != f->mbpfv_file) {
free(f->mbpfv_file);
}
fv_constructor(f);
}

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

@ -515,7 +515,9 @@ extern "C" {
* Lookup the source of an MCA parameter's value
*
* @param index [in] Index of MCA parameter to set
* @param value [in] The integer value to set
* @param source [out] Enum value indicating source
* @param source_file [out] If value came from source, name of the file
* that set it
*
* @retval OPAL_ERROR If the parameter was not found.
* @retval OPAL_SUCCESS Upon success.
@ -524,7 +526,8 @@ extern "C" {
* parameter came from.
*/
OPAL_DECLSPEC bool mca_base_param_lookup_source(int index,
mca_base_param_source_t *source);
mca_base_param_source_t *source,
char **source_file);
/**
* Sets an "override" value for an integer MCA parameter.

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

@ -114,6 +114,8 @@ struct mca_base_param_t {
bool mbp_file_value_set;
/** Value of the parameter found in a file */
mca_base_param_storage_t mbp_file_value;
/** File the value came from */
char *mbp_source_file;
/** Whether or not we have an override value */
bool mbp_override_value_set;
@ -148,6 +150,8 @@ struct mca_base_param_file_value_t {
char *mbpfv_param;
/** Parameter value */
char *mbpfv_value;
/** File it came from */
char *mbpfv_file;
};
/**
* \internal

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

@ -31,8 +31,12 @@
static void save_value(const char *name, const char *value);
static char * file_being_read;
int mca_base_parse_paramfile(const char *paramfile)
{
file_being_read = (char*)paramfile;
return opal_util_keyval_parse(paramfile, save_value);
}
@ -58,6 +62,7 @@ static void save_value(const char *name, const char *value)
} else {
fv->mbpfv_value = NULL;
}
fv->mbpfv_file = strdup(file_being_read);
return;
}
}
@ -72,6 +77,7 @@ static void save_value(const char *name, const char *value)
} else {
fv->mbpfv_value = NULL;
}
fv->mbpfv_file = strdup(file_being_read);
opal_list_append(&mca_base_param_file_values, (opal_list_item_t*) fv);
}
}