2004-01-30 06:54:52 +03: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-01-30 06:54:52 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "ompi_config.h"
|
2004-01-30 06:54:52 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "class/ompi_list.h"
|
2004-03-17 21:45:16 +03:00
|
|
|
#include "runtime/runtime.h"
|
2004-01-30 06:54:52 +03:00
|
|
|
#include "mca/mca.h"
|
2004-03-17 21:45:16 +03:00
|
|
|
#include "mca/base/base.h"
|
|
|
|
#include "mca/pml/pml.h"
|
|
|
|
#include "mca/pml/base/base.h"
|
2004-01-30 06:54:52 +03:00
|
|
|
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
typedef struct opened_component_t {
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_list_item_t super;
|
2004-08-02 04:24:22 +04:00
|
|
|
mca_pml_base_component_t *om_component;
|
|
|
|
} opened_component_t;
|
2004-01-30 06:54:52 +03:00
|
|
|
|
2004-01-31 02:00:48 +03:00
|
|
|
|
2004-01-30 06:54:52 +03:00
|
|
|
/**
|
2004-08-02 04:24:22 +04:00
|
|
|
* Function for selecting one component from all those that are
|
2004-01-30 06:54:52 +03:00
|
|
|
* available.
|
|
|
|
*
|
2004-08-02 04:24:22 +04:00
|
|
|
* Call the init function on all available components and get their
|
|
|
|
* priorities. Select the component with the highest priority. All
|
|
|
|
* other components will be closed and unloaded. The selected component
|
2004-01-31 02:00:48 +03:00
|
|
|
* will have all of its function pointers saved and returned to the
|
|
|
|
* caller.
|
2004-01-30 06:54:52 +03:00
|
|
|
*/
|
2005-03-27 17:05:23 +04:00
|
|
|
int mca_pml_base_select(bool enable_progress_threads,
|
|
|
|
bool enable_mpi_threads)
|
2004-01-30 06:54:52 +03:00
|
|
|
{
|
2005-03-27 17:05:23 +04:00
|
|
|
int priority = 0, best_priority = 0;
|
|
|
|
ompi_list_item_t *item = NULL;
|
|
|
|
mca_base_component_list_item_t *cli = NULL;
|
|
|
|
mca_pml_base_component_t *component = NULL, *best_component = NULL;
|
2005-04-26 22:26:17 +04:00
|
|
|
mca_pml_base_module_t *module = NULL, *best_module = NULL;
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_list_t opened;
|
2005-03-27 17:05:23 +04:00
|
|
|
opened_component_t *om = NULL;
|
2004-01-30 06:54:52 +03:00
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
/* Traverse the list of available components; call their init
|
2004-01-30 06:54:52 +03:00
|
|
|
functions. */
|
|
|
|
|
|
|
|
best_priority = -1;
|
2004-08-02 04:24:22 +04:00
|
|
|
best_component = NULL;
|
2005-03-27 17:05:23 +04:00
|
|
|
module = NULL;
|
2004-06-07 19:33:53 +04:00
|
|
|
OBJ_CONSTRUCT(&opened, ompi_list_t);
|
2004-08-02 04:24:22 +04:00
|
|
|
for (item = ompi_list_get_first(&mca_pml_base_components_available);
|
|
|
|
ompi_list_get_end(&mca_pml_base_components_available) != item;
|
2004-06-07 19:33:53 +04:00
|
|
|
item = ompi_list_get_next(item)) {
|
2004-08-02 04:24:22 +04:00
|
|
|
cli = (mca_base_component_list_item_t *) item;
|
|
|
|
component = (mca_pml_base_component_t *) cli->cli_component;
|
2004-01-30 06:54:52 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_output_verbose(10, mca_pml_base_output,
|
2004-08-02 04:24:22 +04:00
|
|
|
"select: initializing %s component %s",
|
|
|
|
component->pmlm_version.mca_type_name,
|
|
|
|
component->pmlm_version.mca_component_name);
|
|
|
|
if (NULL == component->pmlm_init) {
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_output_verbose(10, mca_pml_base_output,
|
2004-08-02 04:24:22 +04:00
|
|
|
"select: no init function; ignoring component");
|
2004-01-30 06:54:52 +03:00
|
|
|
} else {
|
2005-03-27 17:05:23 +04:00
|
|
|
module = component->pmlm_init(&priority, enable_progress_threads,
|
|
|
|
enable_mpi_threads);
|
|
|
|
if (NULL == module) {
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_output_verbose(10, mca_pml_base_output,
|
2004-01-30 06:54:52 +03:00
|
|
|
"select: init returned failure");
|
|
|
|
} else {
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_output_verbose(10, mca_pml_base_output,
|
2004-01-30 06:54:52 +03:00
|
|
|
"select: init returned priority %d", priority);
|
|
|
|
if (priority > best_priority) {
|
|
|
|
best_priority = priority;
|
2004-08-02 04:24:22 +04:00
|
|
|
best_component = component;
|
2005-04-26 22:26:17 +04:00
|
|
|
best_module = module;
|
2004-01-30 06:54:52 +03:00
|
|
|
}
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
om = malloc(sizeof(opened_component_t));
|
2004-01-30 06:54:52 +03:00
|
|
|
if (NULL == om) {
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
2004-01-30 06:54:52 +03:00
|
|
|
}
|
2004-06-07 19:33:53 +04:00
|
|
|
OBJ_CONSTRUCT(om, ompi_list_item_t);
|
2004-08-02 04:24:22 +04:00
|
|
|
om->om_component = component;
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_list_append(&opened, (ompi_list_item_t*) om);
|
2004-01-30 06:54:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
/* Finished querying all components. Check for the bozo case. */
|
2004-01-30 06:54:52 +03:00
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
if (NULL == best_component) {
|
2004-01-30 06:54:52 +03:00
|
|
|
/* JMS Replace with show_help */
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_abort(1, "No pml component available. This shouldn't happen.");
|
2004-01-30 06:54:52 +03:00
|
|
|
}
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
/* Finalize all non-selected components */
|
2004-01-30 06:54:52 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
for (item = ompi_list_remove_first(&opened);
|
2004-01-30 22:42:31 +03:00
|
|
|
NULL != item;
|
2004-06-07 19:33:53 +04:00
|
|
|
item = ompi_list_remove_first(&opened)) {
|
2004-08-02 04:24:22 +04:00
|
|
|
om = (opened_component_t *) item;
|
|
|
|
if (om->om_component != best_component) {
|
2004-01-30 06:54:52 +03:00
|
|
|
|
|
|
|
/* Finalize */
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
if (NULL != om->om_component->pmlm_finalize) {
|
2004-01-30 06:54:52 +03:00
|
|
|
|
|
|
|
/* Blatently ignore the return code (what would we do to
|
2004-08-02 04:24:22 +04:00
|
|
|
recover, anyway? This component is going away, so errors
|
2004-01-30 06:54:52 +03:00
|
|
|
don't matter anymore) */
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
om->om_component->pmlm_finalize();
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_output_verbose(10, mca_pml_base_output,
|
2004-08-02 04:24:22 +04:00
|
|
|
"select: component %s not selected / finalized",
|
|
|
|
component->pmlm_version.mca_component_name);
|
2004-01-30 06:54:52 +03:00
|
|
|
}
|
|
|
|
}
|
2004-02-10 03:09:36 +03:00
|
|
|
free(om);
|
2004-01-30 06:54:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This base function closes, unloads, and removes from the
|
2004-08-02 04:24:22 +04:00
|
|
|
available list all unselected components. The available list will
|
|
|
|
contain only the selected component. */
|
2004-01-30 06:54:52 +03:00
|
|
|
|
2005-03-27 17:05:23 +04:00
|
|
|
mca_base_components_close(mca_pml_base_output,
|
|
|
|
&mca_pml_base_components_available,
|
|
|
|
(mca_base_component_t *) best_component);
|
2004-01-30 06:54:52 +03:00
|
|
|
|
|
|
|
/* Save the winner */
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
mca_pml_base_selected_component = *best_component;
|
2005-04-26 22:26:17 +04:00
|
|
|
mca_pml = *best_module;
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_output_verbose(10, mca_pml_base_output,
|
2004-08-02 04:24:22 +04:00
|
|
|
"select: component %s selected",
|
|
|
|
component->pmlm_version.mca_component_name);
|
2004-01-30 06:54:52 +03:00
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
/* register the winner's callback */
|
|
|
|
ompi_progress_register(mca_pml.pml_progress);
|
|
|
|
|
2004-01-30 06:54:52 +03:00
|
|
|
/* All done */
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-01-30 06:54:52 +03:00
|
|
|
}
|