1
1
openmpi/orte/mca/iof/base/iof_base_select.c
Jeff Squyres 3962c53e2e - Add to AM_CPPFLAGS $(OPAL_LTDL_CPPFLAGS) where necessary in order to
add a -I to find the included ltdl.h (vs. a system-installed ltdl.h)
- Clean up kruft in a bunch of Makefile.am's to remove now-unnecessary
  AM_CPPFLAGS settings to get static-components.h for each framework
- Move the component_repository API functions out of opal/mca/base/base.h
  and into opal/mca/base/mca_base_component_repository.h in order to
  decrease unnecessary dependencies (e.g., before this, almost
  everything in the tree depended on ltdl.h, which is unnecessary --
  only a small number of files really need ltdl.h)

This commit was SVN r7127.
2005-09-01 12:16:36 +00:00

116 строки
4.2 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 "opal/util/output.h"
#include "opal/mca/mca.h"
#include "opal/mca/base/base.h"
#include "opal/mca/base/mca_base_component_repository.h"
#include "orte/mca/iof/iof.h"
#include "orte/mca/iof/base/base.h"
orte_iof_base_module_t orte_iof;
/**
* Call the init function on all available components to find out if
* they want to run. Select the single component with the highest
* priority.
*/
int orte_iof_base_select(void)
{
opal_list_item_t *item;
mca_base_component_list_item_t *cli;
int selected_priority = -1;
orte_iof_base_component_t *selected_component = NULL;
orte_iof_base_module_t *selected_module = NULL;
bool selected_allow_user;
bool selected_have_hidden;
/* Traverse the list of opened modules; call their init functions. */
for(item = opal_list_get_first(&orte_iof_base.iof_components_opened);
item != opal_list_get_end(&orte_iof_base.iof_components_opened);
item = opal_list_get_next(item)) {
orte_iof_base_component_t* component;
cli = (mca_base_component_list_item_t *) item;
component = (orte_iof_base_component_t *) cli->cli_component;
opal_output_verbose(10, orte_iof_base.iof_output,
"orte_iof_base_select: initializing %s component %s",
component->iof_version.mca_type_name,
component->iof_version.mca_component_name);
if (NULL == component->iof_init) {
opal_output_verbose(10, orte_iof_base.iof_output,
"orte_iof_base_select: no init function; ignoring component");
} else {
bool allow_user;
bool have_hidden;
int priority;
orte_iof_base_module_t* module = component->iof_init(&priority, &allow_user, &have_hidden);
/* If the component didn't initialize, remove it from the opened
list and remove it from the component repository */
if (NULL == module) {
opal_output_verbose(10, orte_iof_base.iof_output,
"orte_iof_base_select: init returned failure");
continue;
}
if(priority > selected_priority) {
selected_priority = priority;
selected_component = component;
selected_module = module;
selected_allow_user = allow_user;
selected_have_hidden = have_hidden;
}
}
}
/* unload all components that were not selected */
item = opal_list_get_first(&orte_iof_base.iof_components_opened);
while(item != opal_list_get_end(&orte_iof_base.iof_components_opened)) {
opal_list_item_t* next = opal_list_get_next(item);
orte_iof_base_component_t* component;
cli = (mca_base_component_list_item_t *) item;
component = (orte_iof_base_component_t *) cli->cli_component;
if(component != selected_component) {
opal_output_verbose(10, orte_iof_base.iof_output,
"orte_iof_base_select: module %s unloaded",
component->iof_version.mca_component_name);
mca_base_component_repository_release((mca_base_component_t *) component);
opal_list_remove_item(&orte_iof_base.iof_components_opened, item);
OBJ_RELEASE(item);
}
item = next;
}
/* setup reference to selected module */
if (NULL != selected_module) {
orte_iof = *selected_module;
orte_iof_base.iof_flush = true;
return ORTE_SUCCESS;
}
/* Oops -- this shouldn't happen */
opal_output(orte_iof_base.iof_output, "iof:select: no components found!");
return ORTE_ERR_OUT_OF_RESOURCE;
}