2004-08-02 04:24:22 +04:00
|
|
|
/*
|
2004-11-22 04:38:40 +03:00
|
|
|
* 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.
|
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-08-02 04:24:22 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
#include "opal/class/opal_list.h"
|
2005-07-04 06:38:44 +04:00
|
|
|
#include "opal/util/strncpy.h"
|
2005-07-04 04:13:44 +04:00
|
|
|
#include "opal/util/argv.h"
|
2005-07-04 03:31:27 +04:00
|
|
|
#include "opal/util/output.h"
|
2005-07-12 22:06:31 +04:00
|
|
|
#include "opal/util/show_help.h"
|
2004-08-02 04:24:22 +04:00
|
|
|
#include "mca/mca.h"
|
|
|
|
#include "mca/base/base.h"
|
2004-11-05 10:52:30 +03:00
|
|
|
#include "include/constants.h"
|
2004-08-02 04:24:22 +04:00
|
|
|
|
|
|
|
struct component_name_t {
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t super;
|
2004-08-02 04:24:22 +04:00
|
|
|
|
|
|
|
char mn_name[MCA_BASE_MAX_COMPONENT_NAME_LEN];
|
|
|
|
};
|
|
|
|
typedef struct component_name_t component_name_t;
|
|
|
|
|
|
|
|
|
2004-10-15 14:54:39 +04:00
|
|
|
/*
|
|
|
|
* Local variables
|
|
|
|
*/
|
|
|
|
static bool show_errors = false;
|
|
|
|
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
/*
|
|
|
|
* Local functions
|
|
|
|
*/
|
|
|
|
static int open_components(const char *type_name, int output_id,
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_t *components_found,
|
|
|
|
opal_list_t *components_available,
|
2004-08-02 04:24:22 +04:00
|
|
|
char **requested_component_names);
|
|
|
|
static int parse_requested(int mca_param, char ***requested_component_names);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function for finding and opening either all MCA components, or the
|
|
|
|
* one that was specifically requested via a MCA parameter.
|
|
|
|
*/
|
|
|
|
int mca_base_components_open(const char *type_name, int output_id,
|
|
|
|
const mca_base_component_t **static_components,
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_t *components_available,
|
2005-04-13 07:19:48 +04:00
|
|
|
bool open_dso_components)
|
2004-08-02 04:24:22 +04:00
|
|
|
{
|
2004-10-15 14:54:39 +04:00
|
|
|
int ret, param;
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t *item;
|
|
|
|
opal_list_t components_found;
|
2004-08-02 04:24:22 +04:00
|
|
|
char **requested_component_names;
|
|
|
|
int param_verbose = -1;
|
|
|
|
int param_type = -1;
|
|
|
|
int verbose_level;
|
|
|
|
|
|
|
|
/* Register MCA parameters */
|
|
|
|
|
|
|
|
param_verbose = mca_base_param_register_int(type_name, "base",
|
|
|
|
"verbose", NULL, 0);
|
|
|
|
param_type = mca_base_param_register_string(type_name, "base", NULL,
|
|
|
|
type_name, NULL);
|
|
|
|
|
2004-10-15 14:54:39 +04:00
|
|
|
param = mca_base_param_find("base", NULL, "component_show_load_errors");
|
|
|
|
mca_base_param_lookup_int(param, &ret);
|
|
|
|
show_errors = (0 != ret) ? true : false;
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
/* Setup verbosity for this MCA type */
|
|
|
|
|
|
|
|
mca_base_param_lookup_int(param_verbose, &verbose_level);
|
|
|
|
if (output_id != 0) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output_set_verbosity(output_id, verbose_level);
|
2004-08-02 04:24:22 +04:00
|
|
|
}
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output_verbose(10, output_id,
|
2004-10-15 14:54:39 +04:00
|
|
|
"mca: base: components_open: Looking for components");
|
2004-08-02 04:24:22 +04:00
|
|
|
|
|
|
|
/* Find and load all available components */
|
|
|
|
|
|
|
|
if (OMPI_SUCCESS !=
|
|
|
|
mca_base_component_find(NULL, type_name, static_components,
|
2005-04-13 07:19:48 +04:00
|
|
|
&components_found, open_dso_components)) {
|
2004-08-02 04:24:22 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* See if one or more specific components were requested */
|
|
|
|
|
|
|
|
ret = parse_requested(param_type, &requested_component_names);
|
|
|
|
if (OMPI_SUCCESS == ret) {
|
|
|
|
ret = open_components(type_name, output_id, &components_found,
|
|
|
|
components_available,
|
|
|
|
requested_component_names);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free resources */
|
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
for (item = opal_list_remove_first(&components_found); NULL != item;
|
|
|
|
item = opal_list_remove_first(&components_found)) {
|
2004-08-02 04:24:22 +04:00
|
|
|
OBJ_RELEASE(item);
|
|
|
|
}
|
|
|
|
if (NULL != requested_component_names) {
|
2005-07-04 04:13:44 +04:00
|
|
|
opal_argv_free(requested_component_names);
|
2004-08-02 04:24:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* All done */
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int parse_requested(int mca_param, char ***requested_component_names)
|
|
|
|
{
|
|
|
|
char *requested;
|
|
|
|
|
|
|
|
*requested_component_names = NULL;
|
|
|
|
|
|
|
|
/* See if the user requested anything */
|
|
|
|
|
|
|
|
if (OMPI_ERROR == mca_base_param_lookup_string(mca_param, &requested)) {
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
if (NULL == requested) {
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2005-07-04 04:13:44 +04:00
|
|
|
*requested_component_names = opal_argv_split(requested, ',');
|
2004-08-02 04:24:22 +04:00
|
|
|
|
|
|
|
/* All done */
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Traverse the entire list of found components (a list of
|
|
|
|
* mca_base_component_t instances). If the requested_component_names
|
|
|
|
* array is empty, or the name of each component in the list of found
|
|
|
|
* components is in the requested_components_array, try to open it.
|
|
|
|
* If it opens, add it to the components_available list.
|
|
|
|
*/
|
|
|
|
static int open_components(const char *type_name, int output_id,
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_t *components_found,
|
|
|
|
opal_list_t *components_available,
|
2004-08-02 04:24:22 +04:00
|
|
|
char **requested_component_names)
|
|
|
|
{
|
|
|
|
int i;
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t *item;
|
2004-08-02 04:24:22 +04:00
|
|
|
const mca_base_component_t *component;
|
|
|
|
mca_base_component_list_item_t *cli;
|
|
|
|
bool acceptable;
|
2005-07-12 22:06:31 +04:00
|
|
|
bool any_acceptable = true;
|
2004-08-02 04:24:22 +04:00
|
|
|
bool called_open;
|
|
|
|
bool opened;
|
|
|
|
|
|
|
|
/* Announce */
|
|
|
|
|
|
|
|
if (NULL == requested_component_names) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output_verbose(10, output_id,
|
2004-10-15 14:54:39 +04:00
|
|
|
"mca: base: components_open: "
|
2004-08-20 05:12:50 +04:00
|
|
|
"looking for any %s components", type_name);
|
2004-08-02 04:24:22 +04:00
|
|
|
} else {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output_verbose(10, output_id,
|
2004-10-15 14:54:39 +04:00
|
|
|
"mca: base: components_open: looking for specific %s components:",
|
2004-08-02 04:24:22 +04:00
|
|
|
type_name);
|
|
|
|
for (i = 0; NULL != requested_component_names[i]; ++i) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output_verbose(10, output_id, "mca: base: components_open: %s",
|
2004-08-02 04:24:22 +04:00
|
|
|
requested_component_names[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-12 22:06:31 +04:00
|
|
|
/*
|
|
|
|
* Check requested components for validity
|
|
|
|
*/
|
|
|
|
if (NULL != requested_component_names) {
|
|
|
|
any_acceptable = false;
|
|
|
|
|
|
|
|
/* For every requested component ... */
|
|
|
|
for (i = 0; NULL != requested_component_names[i]; ++i) {
|
|
|
|
acceptable = false;
|
|
|
|
|
|
|
|
/* Try to match it to an item in the list */
|
|
|
|
for (item = opal_list_get_first(components_found);
|
|
|
|
opal_list_get_end(components_found) != item;
|
|
|
|
item = opal_list_get_next(item)) {
|
|
|
|
|
|
|
|
cli = (mca_base_component_list_item_t *) item;
|
|
|
|
component = cli->cli_component;
|
|
|
|
|
|
|
|
if (0 == strcmp(requested_component_names[i],
|
|
|
|
component->mca_component_name)) {
|
|
|
|
acceptable = true;
|
|
|
|
any_acceptable = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Didn't find it in the list, warn the user */
|
|
|
|
if (!acceptable) {
|
|
|
|
opal_show_help("help-mca-base.txt", "find-available:not-valid", true,
|
|
|
|
requested_component_names[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* None of the listed components were acceptable :( */
|
|
|
|
if(!any_acceptable) {
|
|
|
|
opal_show_help("help-mca-base.txt", "find-available:none-found", true,
|
|
|
|
type_name);
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
/* Traverse the list of found components */
|
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
OBJ_CONSTRUCT(components_available, opal_list_t);
|
|
|
|
for (item = opal_list_get_first(components_found);
|
|
|
|
opal_list_get_end(components_found) != item;
|
|
|
|
item = opal_list_get_next(item)) {
|
2004-08-02 04:24:22 +04:00
|
|
|
cli = (mca_base_component_list_item_t *) item;
|
|
|
|
component = cli->cli_component;
|
|
|
|
|
|
|
|
/* Do we need to check for specific components? */
|
|
|
|
|
|
|
|
if (NULL != requested_component_names) {
|
|
|
|
acceptable = false;
|
|
|
|
for (i = 0; NULL != requested_component_names[i]; ++i) {
|
|
|
|
if (0 == strcmp(requested_component_names[i],
|
|
|
|
component->mca_component_name)) {
|
|
|
|
acceptable = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
acceptable = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If this is an acceptable component, try to open it */
|
|
|
|
|
|
|
|
if (acceptable) {
|
|
|
|
opened = called_open = false;
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output_verbose(10, output_id,
|
2004-10-15 14:54:39 +04:00
|
|
|
"mca: base: components_open: found loaded component %s",
|
2004-08-02 04:24:22 +04:00
|
|
|
component->mca_component_name);
|
|
|
|
|
|
|
|
if (NULL == component->mca_open_component) {
|
|
|
|
opened = true;
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output_verbose(10, output_id,
|
2004-10-15 14:54:39 +04:00
|
|
|
"mca: base: components_open: "
|
2004-08-20 05:12:50 +04:00
|
|
|
"component %s has no open function",
|
2004-08-02 04:24:22 +04:00
|
|
|
component->mca_component_name);
|
|
|
|
} else {
|
|
|
|
called_open = true;
|
|
|
|
if (MCA_SUCCESS == component->mca_open_component()) {
|
|
|
|
opened = true;
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output_verbose(10, output_id,
|
2004-10-15 14:54:39 +04:00
|
|
|
"mca: base: components_open: "
|
2004-08-20 05:12:50 +04:00
|
|
|
"component %s open function successful",
|
2004-08-02 04:24:22 +04:00
|
|
|
component->mca_component_name);
|
|
|
|
} else {
|
2004-10-15 14:54:39 +04:00
|
|
|
/* We may end up displaying this twice, but it may go to
|
|
|
|
separate streams. So better to be redundant than to
|
|
|
|
not display the error in the stream where it was
|
|
|
|
expected. */
|
|
|
|
|
|
|
|
if (show_errors) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0, "mca: base: components_open: "
|
2004-10-15 14:54:39 +04:00
|
|
|
"component %s open function failed",
|
|
|
|
component->mca_component_name);
|
|
|
|
}
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output_verbose(10, output_id,
|
2004-10-15 14:54:39 +04:00
|
|
|
"mca: base: components_open: "
|
|
|
|
"component %s open function failed",
|
|
|
|
component->mca_component_name);
|
2004-08-02 04:24:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If it didn't open, close it out and get rid of it */
|
|
|
|
|
|
|
|
if (!opened) {
|
|
|
|
if (called_open) {
|
|
|
|
if (NULL != component->mca_close_component) {
|
|
|
|
component->mca_close_component();
|
|
|
|
}
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output_verbose(10, output_id,
|
2004-10-15 14:54:39 +04:00
|
|
|
"mca: base: components_open: component %s closed",
|
2004-08-02 04:24:22 +04:00
|
|
|
component->mca_component_name);
|
|
|
|
called_open = false;
|
|
|
|
}
|
|
|
|
mca_base_component_repository_release(component);
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output_verbose(10, output_id,
|
2004-10-15 14:54:39 +04:00
|
|
|
"mca: base: components_open: component %s unloaded",
|
2004-08-02 04:24:22 +04:00
|
|
|
component->mca_component_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If it did open, register its "priority" MCA parameter (if it
|
|
|
|
doesn't already have one) and save it in the opened_components
|
|
|
|
list */
|
|
|
|
|
|
|
|
else {
|
|
|
|
if (OMPI_ERROR == mca_base_param_find(type_name,
|
|
|
|
component->mca_component_name,
|
|
|
|
"priority")) {
|
|
|
|
mca_base_param_register_int(type_name,
|
|
|
|
component->mca_component_name,
|
|
|
|
"priority", NULL, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
cli = OBJ_NEW(mca_base_component_list_item_t);
|
|
|
|
if (NULL == cli) {
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
cli->cli_component = component;
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_append(components_available, (opal_list_item_t *) cli);
|
2004-08-02 04:24:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All done */
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|