2004-01-18 02:07:40 +03:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2004-11-28 23:09:25 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-01-18 02:07:40 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "opal_config.h"
|
2005-09-27 23:27:26 +04:00
|
|
|
|
2004-01-18 02:07:40 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2004-10-22 20:06:05 +04:00
|
|
|
#if HAVE_SYSLOG_H
|
|
|
|
#include <syslog.h>
|
|
|
|
#endif
|
2005-09-27 23:27:26 +04:00
|
|
|
#if HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
2005-08-13 00:46:25 +04:00
|
|
|
|
2005-07-04 03:31:27 +04:00
|
|
|
#include "opal/util/output.h"
|
2005-07-04 06:16:57 +04:00
|
|
|
#include "opal/util/printf.h"
|
2005-08-13 00:46:25 +04:00
|
|
|
#include "opal/mca/mca.h"
|
|
|
|
#include "opal/mca/base/base.h"
|
2005-09-01 16:16:36 +04:00
|
|
|
#include "opal/mca/base/mca_base_component_repository.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "opal/constants.h"
|
2004-01-18 02:07:40 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Public variables
|
|
|
|
*/
|
2004-08-02 04:24:22 +04:00
|
|
|
int mca_base_param_component_path = -1;
|
2004-01-22 03:37:58 +03:00
|
|
|
bool mca_base_opened = false;
|
2004-01-18 02:07:40 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Private functions
|
|
|
|
*/
|
2005-07-04 03:31:27 +04:00
|
|
|
static void set_defaults(opal_output_stream_t *lds);
|
|
|
|
static void parse_verbose(char *e, opal_output_stream_t *lds);
|
2004-01-18 02:07:40 +03:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Main MCA initialization.
|
|
|
|
*/
|
|
|
|
int mca_base_open(void)
|
|
|
|
{
|
|
|
|
int param_index;
|
|
|
|
char *value;
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output_stream_t lds;
|
2005-09-27 23:27:26 +04:00
|
|
|
char hostname[64];
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-01-22 03:37:58 +03:00
|
|
|
if (!mca_base_opened) {
|
|
|
|
mca_base_opened = true;
|
|
|
|
} else {
|
2006-02-12 04:33:29 +03:00
|
|
|
return OPAL_SUCCESS;
|
2004-01-22 03:37:58 +03:00
|
|
|
}
|
|
|
|
|
2004-01-18 02:07:40 +03:00
|
|
|
/* Register some params */
|
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
asprintf(&value, "%s:~/.openmpi/components", OMPI_PKGLIBDIR);
|
2004-08-02 04:24:22 +04:00
|
|
|
mca_base_param_component_path =
|
2005-08-02 02:38:17 +04:00
|
|
|
mca_base_param_reg_string_name("mca", "component_path",
|
|
|
|
"Path where to look for Open MPI and ORTE components",
|
|
|
|
false, false, value, NULL);
|
2004-08-31 13:49:56 +04:00
|
|
|
free(value);
|
2005-08-02 02:38:17 +04:00
|
|
|
param_index = mca_base_param_reg_string_name("mca", "verbose",
|
|
|
|
"Top-level verbosity parameter",
|
|
|
|
false, false, NULL, NULL);
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2005-08-02 02:38:17 +04:00
|
|
|
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);
|
2004-10-15 14:54:39 +04:00
|
|
|
|
2005-08-02 02:38:17 +04:00
|
|
|
mca_base_param_reg_int_name("mca", "component_disable_dlopen",
|
|
|
|
"Whether to attempt to disable opening dynamic components or not",
|
|
|
|
false, false, 0, NULL);
|
2005-07-14 22:05:30 +04:00
|
|
|
|
2004-01-18 02:07:40 +03:00
|
|
|
/* What verbosity level do we want? */
|
|
|
|
|
|
|
|
mca_base_param_lookup_string(param_index, &value);
|
|
|
|
memset(&lds, 0, sizeof(lds));
|
2004-01-21 02:22:44 +03:00
|
|
|
if (NULL != value) {
|
|
|
|
parse_verbose(value, &lds);
|
2004-08-31 13:49:56 +04:00
|
|
|
free(value);
|
2004-01-21 02:22:44 +03:00
|
|
|
} else {
|
|
|
|
set_defaults(&lds);
|
|
|
|
}
|
2005-09-27 23:27:26 +04:00
|
|
|
gethostname(hostname, sizeof(hostname));
|
|
|
|
asprintf(&lds.lds_prefix, "[%s:%05d] ", hostname, getpid());
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output_reopen(0, &lds);
|
|
|
|
opal_output_verbose(5, 0, "mca: base: opening components");
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
/* Open up the component repository */
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2005-09-01 16:16:36 +04:00
|
|
|
return mca_base_component_repository_init();
|
2004-01-18 02:07:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set sane default values for the lds
|
|
|
|
*/
|
2005-07-04 03:31:27 +04:00
|
|
|
static void set_defaults(opal_output_stream_t *lds)
|
2004-01-18 02:07:40 +03:00
|
|
|
{
|
2005-09-27 23:27:26 +04:00
|
|
|
|
|
|
|
/* Load up defaults */
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2005-09-09 14:46:54 +04:00
|
|
|
OBJ_CONSTRUCT(lds, opal_output_stream_t);
|
2005-12-13 01:01:51 +03:00
|
|
|
#ifndef __WINDOWS__
|
2005-09-09 14:46:54 +04:00
|
|
|
lds->lds_syslog_priority = LOG_INFO;
|
2004-10-22 20:06:05 +04:00
|
|
|
#endif
|
2005-09-09 14:46:54 +04:00
|
|
|
lds->lds_syslog_ident = "ompi";
|
|
|
|
lds->lds_want_stderr = true;
|
2004-01-18 02:07:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Parse the value of an environment variable describing verbosity
|
|
|
|
*/
|
2005-07-04 03:31:27 +04:00
|
|
|
static void parse_verbose(char *e, opal_output_stream_t *lds)
|
2004-01-18 02:07:40 +03:00
|
|
|
{
|
2004-01-21 02:22:44 +03:00
|
|
|
char *edup;
|
|
|
|
char *ptr, *next;
|
2004-02-13 17:25:40 +03:00
|
|
|
bool have_output = false;
|
2004-01-21 02:22:44 +03:00
|
|
|
|
2005-09-09 14:46:54 +04:00
|
|
|
if (NULL == e) {
|
2004-01-21 02:22:44 +03:00
|
|
|
return;
|
2005-09-09 14:46:54 +04:00
|
|
|
}
|
2004-01-21 02:22:44 +03:00
|
|
|
|
|
|
|
edup = strdup(e);
|
|
|
|
ptr = edup;
|
2004-01-18 02:07:40 +03:00
|
|
|
|
|
|
|
/* Now parse the environment variable */
|
|
|
|
|
|
|
|
while (NULL != ptr && strlen(ptr) > 0) {
|
|
|
|
next = strchr(ptr, ',');
|
2005-09-27 23:27:26 +04:00
|
|
|
if (NULL != next) {
|
2004-01-18 02:07:40 +03:00
|
|
|
*next = '\0';
|
2005-09-27 23:27:26 +04:00
|
|
|
}
|
2004-10-22 20:06:05 +04:00
|
|
|
|
2004-01-21 02:22:44 +03:00
|
|
|
if (0 == strcasecmp(ptr, "syslog")) {
|
2005-12-13 01:01:51 +03:00
|
|
|
#ifndef __WINDOWS__ /* there is no syslog */
|
2004-10-22 20:06:05 +04:00
|
|
|
lds->lds_want_syslog = true;
|
2004-02-13 17:25:40 +03:00
|
|
|
have_output = true;
|
2004-01-21 02:22:44 +03:00
|
|
|
}
|
2004-01-18 02:07:40 +03:00
|
|
|
else if (strncasecmp(ptr, "syslogpri:", 10) == 0) {
|
|
|
|
lds->lds_want_syslog = true;
|
2004-02-13 17:25:40 +03:00
|
|
|
have_output = true;
|
2004-01-18 02:07:40 +03:00
|
|
|
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;
|
2004-10-22 20:06:05 +04:00
|
|
|
#endif
|
2005-09-27 23:27:26 +04:00
|
|
|
}
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-01-21 02:22:44 +03:00
|
|
|
else if (strcasecmp(ptr, "stdout") == 0) {
|
2004-01-18 02:07:40 +03:00
|
|
|
lds->lds_want_stdout = true;
|
2004-02-13 17:25:40 +03:00
|
|
|
have_output = true;
|
2004-01-21 02:22:44 +03:00
|
|
|
} else if (strcasecmp(ptr, "stderr") == 0) {
|
2004-01-18 02:07:40 +03:00
|
|
|
lds->lds_want_stderr = true;
|
2004-02-13 17:25:40 +03:00
|
|
|
have_output = true;
|
2004-01-21 02:22:44 +03:00
|
|
|
}
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-01-21 02:22:44 +03:00
|
|
|
else if (strcasecmp(ptr, "file") == 0) {
|
2004-01-18 02:07:40 +03:00
|
|
|
lds->lds_want_file = true;
|
2004-02-13 17:25:40 +03:00
|
|
|
have_output = true;
|
2004-01-21 02:22:44 +03:00
|
|
|
} else if (strncasecmp(ptr, "file:", 5) == 0) {
|
2004-01-18 02:07:40 +03:00
|
|
|
lds->lds_want_file = true;
|
|
|
|
lds->lds_file_suffix = ptr + 5;
|
2004-02-13 17:25:40 +03:00
|
|
|
have_output = true;
|
2004-01-18 02:07:40 +03:00
|
|
|
} else if (strcasecmp(ptr, "fileappend") == 0) {
|
|
|
|
lds->lds_want_file = true;
|
|
|
|
lds->lds_want_file_append = 1;
|
2004-02-13 17:25:40 +03:00
|
|
|
have_output = true;
|
2004-01-21 02:22:44 +03:00
|
|
|
}
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-01-21 02:22:44 +03:00
|
|
|
else if (strncasecmp(ptr, "level", 5) == 0) {
|
2004-01-18 02:07:40 +03:00
|
|
|
lds->lds_verbose_level = 0;
|
|
|
|
if (ptr[5] == ':')
|
|
|
|
lds->lds_verbose_level = atoi(ptr + 6);
|
|
|
|
}
|
|
|
|
|
2005-09-27 23:27:26 +04:00
|
|
|
if (NULL == next) {
|
2004-01-18 02:07:40 +03:00
|
|
|
break;
|
2005-09-27 23:27:26 +04:00
|
|
|
}
|
2004-01-18 02:07:40 +03:00
|
|
|
ptr = next + 1;
|
|
|
|
}
|
|
|
|
|
2004-02-13 17:25:40 +03:00
|
|
|
/* If we didn't get an output, default to stderr */
|
|
|
|
|
|
|
|
if (!have_output) {
|
|
|
|
lds->lds_want_stderr = true;
|
|
|
|
}
|
|
|
|
|
2004-01-21 02:22:44 +03:00
|
|
|
/* All done */
|
|
|
|
|
2004-02-10 03:09:36 +03:00
|
|
|
free(edup);
|
2004-01-18 02:07:40 +03:00
|
|
|
}
|