2004-12-21 22:16:09 +00: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.
|
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
|
|
|
|
#include "util/output.h"
|
|
|
|
#include "mca/mca.h"
|
|
|
|
#include "mca/base/base.h"
|
|
|
|
#include "mca/iof/iof.h"
|
|
|
|
#include "mca/iof/base/base.h"
|
|
|
|
|
2005-01-12 20:51:34 +00:00
|
|
|
mca_iof_base_module_t mca_iof;
|
|
|
|
|
|
|
|
|
2004-12-21 22:16:09 +00:00
|
|
|
/**
|
|
|
|
* Call the init function on all available components to find out if
|
|
|
|
* they want to run. Select the single component with the highest
|
|
|
|
* priority.
|
|
|
|
*/
|
2005-01-12 20:51:34 +00:00
|
|
|
int mca_iof_base_select(bool *allow_multi_user_threads, bool* have_hidden_threads)
|
2004-12-21 22:16:09 +00:00
|
|
|
{
|
|
|
|
ompi_list_item_t *item;
|
|
|
|
mca_base_component_list_item_t *cli;
|
|
|
|
int selected_priority = -1;
|
|
|
|
mca_iof_base_component_t *selected_component = NULL;
|
|
|
|
mca_iof_base_module_t *selected_module = NULL;
|
2005-01-18 21:30:23 +00:00
|
|
|
bool selected_allow_user = true;
|
|
|
|
bool selected_have_hidden = false;
|
2004-12-21 22:16:09 +00:00
|
|
|
|
|
|
|
/* Traverse the list of opened modules; call their init functions. */
|
2005-01-12 20:51:34 +00:00
|
|
|
for(item = ompi_list_get_first(&mca_iof_base.iof_components_opened);
|
|
|
|
item != ompi_list_get_end(&mca_iof_base.iof_components_opened);
|
2004-12-21 22:16:09 +00:00
|
|
|
item = ompi_list_get_next(item)) {
|
|
|
|
mca_iof_base_component_t* component;
|
|
|
|
|
|
|
|
cli = (mca_base_component_list_item_t *) item;
|
|
|
|
component = (mca_iof_base_component_t *) cli->cli_component;
|
|
|
|
|
2005-01-12 20:51:34 +00:00
|
|
|
ompi_output_verbose(10, mca_iof_base.iof_output,
|
2004-12-21 22:16:09 +00:00
|
|
|
"mca_iof_base_select: initializing %s component %s",
|
|
|
|
component->iof_version.mca_type_name,
|
|
|
|
component->iof_version.mca_component_name);
|
|
|
|
|
|
|
|
if (NULL == component->iof_init) {
|
2005-01-12 20:51:34 +00:00
|
|
|
ompi_output_verbose(10, mca_iof_base.iof_output,
|
2004-12-21 22:16:09 +00:00
|
|
|
"mca_iof_base_select: no init function; ignoring component");
|
|
|
|
} else {
|
2005-01-12 20:51:34 +00:00
|
|
|
bool allow_user;
|
|
|
|
bool have_hidden;
|
2004-12-21 22:16:09 +00:00
|
|
|
int priority;
|
2005-01-12 20:51:34 +00:00
|
|
|
mca_iof_base_module_t* module = component->iof_init(&priority, &allow_user, &have_hidden);
|
2004-12-21 22:16:09 +00:00
|
|
|
|
|
|
|
/* If the component didn't initialize, remove it from the opened
|
|
|
|
list and remove it from the component repository */
|
|
|
|
if (NULL == module) {
|
2005-01-12 20:51:34 +00:00
|
|
|
ompi_output_verbose(10, mca_iof_base.iof_output,
|
2004-12-21 22:16:09 +00:00
|
|
|
"mca_iof_base_select: init returned failure");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(priority > selected_priority) {
|
|
|
|
selected_priority = priority;
|
|
|
|
selected_component = component;
|
|
|
|
selected_module = module;
|
2005-01-12 20:51:34 +00:00
|
|
|
selected_allow_user = allow_user;
|
|
|
|
selected_have_hidden = have_hidden;
|
2004-12-21 22:16:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* unload all components that were not selected */
|
2005-01-12 20:51:34 +00:00
|
|
|
item = ompi_list_get_first(&mca_iof_base.iof_components_opened);
|
|
|
|
while(item != ompi_list_get_end(&mca_iof_base.iof_components_opened)) {
|
2004-12-21 22:16:09 +00:00
|
|
|
ompi_list_item_t* next = ompi_list_get_next(item);
|
2005-01-12 20:51:34 +00:00
|
|
|
mca_iof_base_component_t* component;
|
2004-12-21 22:16:09 +00:00
|
|
|
cli = (mca_base_component_list_item_t *) item;
|
2005-01-12 20:51:34 +00:00
|
|
|
component = (mca_iof_base_component_t *) cli->cli_component;
|
2004-12-21 22:16:09 +00:00
|
|
|
if(component != selected_component) {
|
2005-01-12 20:51:34 +00:00
|
|
|
ompi_output_verbose(10, mca_iof_base.iof_output,
|
2004-12-21 22:16:09 +00:00
|
|
|
"mca_iof_base_select: module %s unloaded",
|
|
|
|
component->iof_version.mca_component_name);
|
|
|
|
mca_base_component_repository_release((mca_base_component_t *) component);
|
2005-01-12 20:51:34 +00:00
|
|
|
ompi_list_remove_item(&mca_iof_base.iof_components_opened, item);
|
2004-12-21 22:16:09 +00:00
|
|
|
OBJ_RELEASE(item);
|
|
|
|
}
|
|
|
|
item = next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* setup reference to selected module */
|
|
|
|
if(NULL != selected_module) {
|
2005-01-12 20:51:34 +00:00
|
|
|
*allow_multi_user_threads = selected_allow_user;
|
|
|
|
*have_hidden_threads = selected_have_hidden;
|
2004-12-21 22:16:09 +00:00
|
|
|
mca_iof = *selected_module;
|
|
|
|
}
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|