2004-01-30 03:55:39 +00:00
|
|
|
/*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
#include "ompi_config.h"
|
2004-01-30 03:55:39 +00:00
|
|
|
|
2004-03-17 18:45:16 +00:00
|
|
|
#include "runtime/runtime.h"
|
2004-01-30 03:55:39 +00:00
|
|
|
#include "mca/mca.h"
|
2004-03-17 18:45:16 +00:00
|
|
|
#include "mca/base/base.h"
|
|
|
|
#include "mca/ptl/ptl.h"
|
|
|
|
#include "mca/ptl/base/base.h"
|
2004-01-30 03:55:39 +00:00
|
|
|
|
|
|
|
|
2004-01-30 23:02:39 +00:00
|
|
|
/**
|
|
|
|
* Function for weeding out ptl modules that don't want to run.
|
|
|
|
*
|
|
|
|
* Call the init function on all available modules to find out if they
|
|
|
|
* want to run. Select all modules that don't fail. Failing modules
|
|
|
|
* will be closed and unloaded. The selected modules will be returned
|
2004-06-07 15:33:53 +00:00
|
|
|
* to the caller in a ompi_list_t.
|
2004-01-30 23:02:39 +00:00
|
|
|
*/
|
2004-01-31 21:45:32 +00:00
|
|
|
int mca_ptl_base_select(bool *allow_multi_user_threads,
|
|
|
|
bool *have_hidden_threads)
|
2004-01-30 03:55:39 +00:00
|
|
|
{
|
2004-01-30 23:02:39 +00:00
|
|
|
int i, num_ptls;
|
2004-01-31 21:45:32 +00:00
|
|
|
bool user_threads, hidden_threads;
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_list_item_t *item;
|
2004-01-30 23:02:39 +00:00
|
|
|
mca_base_module_list_item_t *mli;
|
|
|
|
mca_ptl_base_module_t *module;
|
|
|
|
mca_ptl_t **actions;
|
|
|
|
mca_ptl_base_selected_module_t *sm;
|
|
|
|
|
|
|
|
/* Traverse the list of available modules; call their init
|
|
|
|
functions. */
|
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
for (item = ompi_list_get_first(&mca_ptl_base_modules_available);
|
|
|
|
ompi_list_get_end(&mca_ptl_base_modules_available) != item;
|
|
|
|
item = ompi_list_get_next(item)) {
|
2004-01-30 23:02:39 +00:00
|
|
|
mli = (mca_base_module_list_item_t *) item;
|
|
|
|
module = (mca_ptl_base_module_t *) mli->mli_module;
|
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_output_verbose(10, mca_ptl_base_output,
|
2004-01-30 23:02:39 +00:00
|
|
|
"select: initializing %s module %s",
|
|
|
|
module->ptlm_version.mca_type_name,
|
|
|
|
module->ptlm_version.mca_module_name);
|
|
|
|
if (NULL == module->ptlm_init) {
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_output_verbose(10, mca_ptl_base_output,
|
2004-01-30 23:02:39 +00:00
|
|
|
"select: no init function; ignoring module");
|
|
|
|
} else {
|
2004-01-31 21:45:32 +00:00
|
|
|
actions = module->ptlm_init(&num_ptls, &user_threads,
|
|
|
|
&hidden_threads);
|
2004-01-30 23:02:39 +00:00
|
|
|
|
|
|
|
/* If the module didn't initialize, unload it */
|
|
|
|
|
|
|
|
if (NULL == actions) {
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_output_verbose(10, mca_ptl_base_output,
|
2004-01-30 23:02:39 +00:00
|
|
|
"select: init returned failure");
|
|
|
|
|
2004-03-19 06:06:04 +00:00
|
|
|
mca_base_module_repository_release((mca_base_module_t *) module);
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_output_verbose(10, mca_ptl_base_output,
|
2004-01-30 23:02:39 +00:00
|
|
|
"select: module %s unloaded",
|
|
|
|
module->ptlm_version.mca_module_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Otherwise, it initialized properly. Save it. */
|
|
|
|
|
|
|
|
else {
|
2004-01-31 21:45:32 +00:00
|
|
|
*allow_multi_user_threads |= user_threads;
|
|
|
|
*have_hidden_threads |= hidden_threads;
|
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_output_verbose(10, mca_ptl_base_output,
|
2004-01-30 23:02:39 +00:00
|
|
|
"select: init returned success");
|
|
|
|
|
|
|
|
for (i = 0; i < num_ptls; ++i) {
|
2004-02-10 00:09:36 +00:00
|
|
|
sm = malloc(sizeof(mca_ptl_base_selected_module_t));
|
2004-01-30 23:02:39 +00:00
|
|
|
if (NULL == sm) {
|
2004-06-07 15:33:53 +00:00
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
2004-01-30 23:02:39 +00:00
|
|
|
}
|
2004-06-07 15:33:53 +00:00
|
|
|
OBJ_CONSTRUCT(sm, ompi_list_item_t);
|
2004-01-30 23:02:39 +00:00
|
|
|
sm->pbsm_module = module;
|
|
|
|
sm->pbsm_actions = actions[i];
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_list_append(&mca_ptl_base_modules_initialized,
|
|
|
|
(ompi_list_item_t*) sm);
|
2004-01-30 23:02:39 +00:00
|
|
|
}
|
2004-02-10 00:09:36 +00:00
|
|
|
free(actions);
|
2004-01-30 23:02:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finished querying all modules. Check for the bozo case. */
|
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
if (0 == ompi_list_get_size(&mca_ptl_base_modules_initialized)) {
|
2004-01-30 23:02:39 +00:00
|
|
|
/* JMS Replace with show_help */
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_abort(1, "No ptl module available. This shouldn't happen.");
|
2004-01-30 23:02:39 +00:00
|
|
|
}
|
|
|
|
|
2004-01-30 03:55:39 +00:00
|
|
|
/* All done */
|
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
return OMPI_SUCCESS;
|
2004-01-30 03:55:39 +00:00
|
|
|
}
|