4c1dd716c7
- new preferred API calls for registering MCA parameters are mca_base_param_reg_{int|string} and mca_base_param_reg_{int|string}_name. - See opal/mca/base/mca_base_param.h for docs on new calls. - Can now register and lookup a value at the same time. - Can now mark a parameter "read only" at registration time - Can now mark a parameter "internal" at registration time - Can now associate a help message with the parameter at registration time; displayed in the ompi_info output. The old API calls are still available for backwards compatibility (mca_base_param_register_{int|string}. They will eventually be removed -- all developers are encouraged to use the new APIs from here on out and replace any old calls with the new API. Some params were also renamed -- the previous convention of using "base_" as a prefix for any param that was not associated with a component is henceforth deprecated. Instead, use one of the following prefixes: mca: for anything in the MCA base itself opal: for anything in OPAL orte: for anything in ORTE mpi: for anything in OMPI This commit was SVN r6698.
214 строки
5.4 KiB
C
214 строки
5.4 KiB
C
/*
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
* All rights reserved.
|
|
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
* All rights reserved.
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
* University of Stuttgart. All rights reserved.
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
* All rights reserved.
|
|
* $COPYRIGHT$
|
|
*
|
|
* Additional copyrights may follow
|
|
*
|
|
* $HEADER$
|
|
*/
|
|
|
|
|
|
#include "ompi_config.h"
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#if HAVE_SYSLOG_H
|
|
#include <syslog.h>
|
|
#endif
|
|
#include "include/constants.h"
|
|
#include "opal/util/output.h"
|
|
#include "opal/util/printf.h"
|
|
#include "mca/mca.h"
|
|
#include "mca/base/base.h"
|
|
|
|
/*
|
|
* Public variables
|
|
*/
|
|
int mca_base_param_component_path = -1;
|
|
bool mca_base_opened = false;
|
|
|
|
/*
|
|
* Private functions
|
|
*/
|
|
static void set_defaults(opal_output_stream_t *lds);
|
|
static void parse_verbose(char *e, opal_output_stream_t *lds);
|
|
|
|
|
|
/*
|
|
* Main MCA initialization.
|
|
*/
|
|
int mca_base_open(void)
|
|
{
|
|
int param_index;
|
|
char *value;
|
|
opal_output_stream_t lds;
|
|
|
|
if (!mca_base_opened) {
|
|
mca_base_opened = true;
|
|
} else {
|
|
return OMPI_SUCCESS;
|
|
}
|
|
|
|
/* Setup the parameter system */
|
|
|
|
mca_base_param_init();
|
|
|
|
/* Register some params */
|
|
|
|
#ifdef WIN32
|
|
asprintf(&value, "%s;~/.openmpi/components", OMPI_PKGLIBDIR);
|
|
#else
|
|
asprintf(&value, "%s:~/.openmpi/components", OMPI_PKGLIBDIR);
|
|
#endif
|
|
mca_base_param_component_path =
|
|
mca_base_param_reg_string_name("mca", "component_path",
|
|
"Path where to look for Open MPI and ORTE components",
|
|
false, false, value, NULL);
|
|
free(value);
|
|
param_index = mca_base_param_reg_string_name("mca", "verbose",
|
|
"Top-level verbosity parameter",
|
|
false, false, NULL, NULL);
|
|
|
|
mca_base_param_reg_int_name("mca", "component_show_load_errors",
|
|
"Whether to show errors for components that failed to load or not",
|
|
false, false, 1, NULL);
|
|
|
|
mca_base_param_reg_int_name("mca", "component_disable_dlopen",
|
|
"Whether to attempt to disable opening dynamic components or not",
|
|
false, false, 0, NULL);
|
|
|
|
/* What verbosity level do we want? */
|
|
|
|
mca_base_param_lookup_string(param_index, &value);
|
|
memset(&lds, 0, sizeof(lds));
|
|
if (NULL != value) {
|
|
parse_verbose(value, &lds);
|
|
free(value);
|
|
} else {
|
|
set_defaults(&lds);
|
|
}
|
|
opal_output_reopen(0, &lds);
|
|
opal_output_verbose(5, 0, "mca: base: opening components");
|
|
|
|
/* Open up the component repository */
|
|
|
|
return mca_base_component_repository_initialize();
|
|
}
|
|
|
|
|
|
/*
|
|
* Set sane default values for the lds
|
|
*/
|
|
static void set_defaults(opal_output_stream_t *lds)
|
|
{
|
|
/* Load up defaults */
|
|
|
|
lds->lds_is_debugging = false;
|
|
lds->lds_verbose_level = 0;
|
|
lds->lds_want_syslog = false;
|
|
#ifndef WIN32
|
|
lds->lds_syslog_priority = LOG_INFO;
|
|
#endif
|
|
lds->lds_syslog_ident = "ompi";
|
|
lds->lds_want_stdout = false;
|
|
lds->lds_want_stderr = true;
|
|
lds->lds_want_file = false;
|
|
lds->lds_want_file_append = false;
|
|
lds->lds_file_suffix = NULL;
|
|
lds->lds_file_suffix = "mca.txt";
|
|
}
|
|
|
|
|
|
/*
|
|
* Parse the value of an environment variable describing verbosity
|
|
*/
|
|
static void parse_verbose(char *e, opal_output_stream_t *lds)
|
|
{
|
|
char *edup;
|
|
char *ptr, *next;
|
|
bool have_output = false;
|
|
|
|
if (NULL == e)
|
|
return;
|
|
|
|
edup = strdup(e);
|
|
ptr = edup;
|
|
|
|
/* Now parse the environment variable */
|
|
|
|
while (NULL != ptr && strlen(ptr) > 0) {
|
|
next = strchr(ptr, ',');
|
|
if (NULL != next)
|
|
*next = '\0';
|
|
|
|
|
|
if (0 == strcasecmp(ptr, "syslog")) {
|
|
#ifndef WIN32 /* there is no syslog */
|
|
lds->lds_want_syslog = true;
|
|
have_output = true;
|
|
}
|
|
else if (strncasecmp(ptr, "syslogpri:", 10) == 0) {
|
|
lds->lds_want_syslog = true;
|
|
have_output = true;
|
|
if (strcasecmp(ptr + 10, "notice") == 0)
|
|
lds->lds_syslog_priority = LOG_NOTICE;
|
|
else if (strcasecmp(ptr + 10, "INFO") == 0)
|
|
lds->lds_syslog_priority = LOG_INFO;
|
|
else if (strcasecmp(ptr + 10, "DEBUG") == 0)
|
|
lds->lds_syslog_priority = LOG_DEBUG;
|
|
} else if (strncasecmp(ptr, "syslogid:", 9) == 0) {
|
|
lds->lds_want_syslog = true;
|
|
lds->lds_syslog_ident = ptr + 9;
|
|
#endif
|
|
}
|
|
|
|
else if (strcasecmp(ptr, "stdout") == 0) {
|
|
lds->lds_want_stdout = true;
|
|
have_output = true;
|
|
} else if (strcasecmp(ptr, "stderr") == 0) {
|
|
lds->lds_want_stderr = true;
|
|
have_output = true;
|
|
}
|
|
|
|
else if (strcasecmp(ptr, "file") == 0) {
|
|
lds->lds_want_file = true;
|
|
have_output = true;
|
|
} else if (strncasecmp(ptr, "file:", 5) == 0) {
|
|
lds->lds_want_file = true;
|
|
lds->lds_file_suffix = ptr + 5;
|
|
have_output = true;
|
|
} else if (strcasecmp(ptr, "fileappend") == 0) {
|
|
lds->lds_want_file = true;
|
|
lds->lds_want_file_append = 1;
|
|
have_output = true;
|
|
}
|
|
|
|
else if (strncasecmp(ptr, "level", 5) == 0) {
|
|
lds->lds_verbose_level = 0;
|
|
if (ptr[5] == ':')
|
|
lds->lds_verbose_level = atoi(ptr + 6);
|
|
}
|
|
|
|
if (NULL == next)
|
|
break;
|
|
ptr = next + 1;
|
|
}
|
|
|
|
/* If we didn't get an output, default to stderr */
|
|
|
|
if (!have_output) {
|
|
lds->lds_want_stderr = true;
|
|
}
|
|
|
|
/* All done */
|
|
|
|
free(edup);
|
|
}
|