2004-01-30 06:54:52 +03:00
|
|
|
/*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "lam_config.h"
|
|
|
|
|
|
|
|
#include "lam/lfc/list.h"
|
|
|
|
#include "lam/runtime/runtime.h"
|
|
|
|
#include "mca/mca.h"
|
|
|
|
#include "mca/lam/base/base.h"
|
|
|
|
#include "mca/mpi/pml/pml.h"
|
|
|
|
#include "mca/mpi/pml/base/base.h"
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct opened_module_t {
|
2004-01-30 22:42:31 +03:00
|
|
|
lam_list_item_t super;
|
|
|
|
|
2004-01-30 06:54:52 +03:00
|
|
|
mca_pml_base_module_t *om_module;
|
|
|
|
} opened_module_t;
|
|
|
|
|
2004-01-31 02:00:48 +03:00
|
|
|
|
2004-01-30 06:54:52 +03:00
|
|
|
/**
|
|
|
|
* Function for selecting one module from all those that are
|
|
|
|
* available.
|
|
|
|
*
|
|
|
|
* Call the init function on all available modules and get their
|
|
|
|
* priorities. Select the module with the highest priority. All
|
|
|
|
* other modules will be closed and unloaded. The selected module
|
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
|
|
|
*/
|
2004-02-01 00:45:32 +03:00
|
|
|
int mca_pml_base_select(mca_pml_t *selected, bool *allow_multi_user_threads,
|
|
|
|
bool *have_hidden_threads)
|
2004-01-30 06:54:52 +03:00
|
|
|
{
|
|
|
|
int priority, best_priority;
|
2004-02-01 00:45:32 +03:00
|
|
|
bool user_threads, hidden_threads;
|
|
|
|
bool best_user_threads, best_hidden_threads;
|
2004-01-30 06:54:52 +03:00
|
|
|
lam_list_item_t *item;
|
|
|
|
mca_base_module_list_item_t *mli;
|
|
|
|
mca_pml_base_module_t *module, *best_module;
|
|
|
|
mca_pml_t *actions;
|
|
|
|
lam_list_t opened;
|
|
|
|
opened_module_t *om;
|
|
|
|
|
|
|
|
/* Traverse the list of available modules; call their init
|
|
|
|
functions. */
|
|
|
|
|
|
|
|
best_priority = -1;
|
|
|
|
best_module = NULL;
|
2004-02-10 17:04:27 +03:00
|
|
|
lam_list_construct(&opened);
|
2004-01-30 06:54:52 +03:00
|
|
|
for (item = lam_list_get_first(&mca_pml_base_modules_available);
|
|
|
|
lam_list_get_end(&mca_pml_base_modules_available) != item;
|
|
|
|
item = lam_list_get_next(item)) {
|
|
|
|
mli = (mca_base_module_list_item_t *) item;
|
|
|
|
module = (mca_pml_base_module_t *) mli->mli_module;
|
|
|
|
|
|
|
|
lam_output_verbose(10, mca_pml_base_output,
|
|
|
|
"select: initializing %s module %s",
|
|
|
|
module->pmlm_version.mca_type_name,
|
|
|
|
module->pmlm_version.mca_module_name);
|
|
|
|
if (NULL == module->pmlm_init) {
|
|
|
|
lam_output_verbose(10, mca_pml_base_output,
|
|
|
|
"select: no init function; ignoring module");
|
|
|
|
} else {
|
2004-02-01 00:45:32 +03:00
|
|
|
actions = module->pmlm_init(&priority, &user_threads,
|
|
|
|
&hidden_threads);
|
2004-01-30 06:54:52 +03:00
|
|
|
if (NULL == actions) {
|
|
|
|
lam_output_verbose(10, mca_pml_base_output,
|
|
|
|
"select: init returned failure");
|
|
|
|
} else {
|
|
|
|
lam_output_verbose(10, mca_pml_base_output,
|
|
|
|
"select: init returned priority %d", priority);
|
|
|
|
if (priority > best_priority) {
|
|
|
|
best_priority = priority;
|
2004-02-01 00:45:32 +03:00
|
|
|
best_user_threads = user_threads;
|
|
|
|
best_hidden_threads = hidden_threads;
|
2004-01-30 06:54:52 +03:00
|
|
|
best_module = module;
|
|
|
|
}
|
|
|
|
|
2004-02-10 03:09:36 +03:00
|
|
|
om = malloc(sizeof(opened_module_t));
|
2004-01-30 06:54:52 +03:00
|
|
|
if (NULL == om) {
|
|
|
|
return LAM_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
2004-02-10 17:04:27 +03:00
|
|
|
lam_list_item_construct((lam_list_item_t *) om);
|
2004-01-30 06:54:52 +03:00
|
|
|
om->om_module = module;
|
|
|
|
lam_list_append(&opened, (lam_list_item_t*) om);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finished querying all modules. Check for the bozo case. */
|
|
|
|
|
|
|
|
if (NULL == best_module) {
|
|
|
|
/* JMS Replace with show_help */
|
|
|
|
lam_abort(1, "No pml module available. This shouldn't happen.");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finalize all non-selected modules */
|
|
|
|
|
2004-01-30 22:42:31 +03:00
|
|
|
for (item = lam_list_remove_first(&opened);
|
|
|
|
NULL != item;
|
|
|
|
item = lam_list_remove_first(&opened)) {
|
2004-01-30 06:54:52 +03:00
|
|
|
om = (opened_module_t *) item;
|
|
|
|
if (om->om_module != best_module) {
|
|
|
|
|
|
|
|
/* Finalize */
|
|
|
|
|
2004-02-01 00:45:32 +03:00
|
|
|
if (NULL != om->om_module->pmlm_finalize) {
|
2004-01-30 06:54:52 +03:00
|
|
|
|
|
|
|
/* Blatently ignore the return code (what would we do to
|
|
|
|
recover, anyway? This module is going away, so errors
|
|
|
|
don't matter anymore) */
|
|
|
|
|
2004-02-01 00:45:32 +03:00
|
|
|
om->om_module->pmlm_finalize();
|
2004-01-30 06:54:52 +03:00
|
|
|
lam_output_verbose(10, mca_pml_base_output,
|
|
|
|
"select: module %s not selected / finalized",
|
|
|
|
module->pmlm_version.mca_module_name);
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
available list all unselected modules. The available list will
|
|
|
|
contain only the selected module. */
|
|
|
|
|
|
|
|
mca_base_modules_close(mca_pml_base_output, &mca_pml_base_modules_available,
|
|
|
|
(mca_base_module_t *) best_module);
|
|
|
|
|
|
|
|
/* Save the winner */
|
|
|
|
|
|
|
|
mca_pml_base_selected_module = *best_module;
|
|
|
|
*selected = *actions;
|
2004-02-01 00:45:32 +03:00
|
|
|
*allow_multi_user_threads = best_user_threads;
|
|
|
|
*have_hidden_threads = best_hidden_threads;
|
2004-01-30 06:54:52 +03:00
|
|
|
lam_output_verbose(10, mca_pml_base_output,
|
|
|
|
"select: module %s selected",
|
|
|
|
module->pmlm_version.mca_module_name);
|
|
|
|
|
|
|
|
/* All done */
|
|
|
|
|
|
|
|
return LAM_SUCCESS;
|
|
|
|
}
|