2004-07-11 00:10:52 +00:00
|
|
|
/*
|
2004-11-22 01:38:40 +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$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-07-11 00:10:52 +00:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2004-10-22 16:06:05 +00:00
|
|
|
#include "ompi_config.h"
|
2004-07-11 00:10:52 +00:00
|
|
|
#include <stdio.h>
|
2004-07-11 00:57:30 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2004-10-22 16:06:05 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2004-07-11 00:57:30 +00:00
|
|
|
#include <unistd.h>
|
2004-10-22 16:06:05 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
2004-07-11 02:21:23 +00:00
|
|
|
#include <sys/types.h>
|
2004-10-22 16:06:05 +00:00
|
|
|
#endif
|
2004-07-11 00:10:52 +00:00
|
|
|
#include "runtime/runtime.h"
|
|
|
|
#include "util/output.h"
|
|
|
|
#include "util/proc_info.h"
|
|
|
|
#include "mca/mca.h"
|
|
|
|
#include "mca/base/base.h"
|
2004-07-11 04:34:47 +00:00
|
|
|
#include "mca/ns/ns.h"
|
2004-07-11 00:10:52 +00:00
|
|
|
#include "mca/ns/base/base.h"
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2004-07-11 04:34:47 +00:00
|
|
|
* Function for selecting one component from all those that are
|
2004-07-11 00:10:52 +00:00
|
|
|
* available.
|
|
|
|
*/
|
|
|
|
int mca_ns_base_select(bool *allow_multi_user_threads,
|
2004-07-11 04:34:47 +00:00
|
|
|
bool *have_hidden_threads)
|
2004-07-11 00:10:52 +00:00
|
|
|
{
|
2004-07-11 04:34:47 +00:00
|
|
|
ompi_list_item_t *item;
|
2004-08-02 00:24:22 +00:00
|
|
|
mca_base_component_list_item_t *cli;
|
2004-07-11 04:34:47 +00:00
|
|
|
mca_ns_base_component_t *component, *best_component = NULL;
|
2004-08-02 00:24:22 +00:00
|
|
|
mca_ns_base_module_t *module, *best_module = NULL;
|
2004-07-11 04:34:47 +00:00
|
|
|
bool multi, hidden;
|
|
|
|
int priority, best_priority = -1;
|
|
|
|
|
|
|
|
/* Iterate through all the available components */
|
|
|
|
|
|
|
|
for (item = ompi_list_get_first(&mca_ns_base_components_available);
|
|
|
|
item != ompi_list_get_end(&mca_ns_base_components_available);
|
|
|
|
item = ompi_list_get_next(item)) {
|
2004-08-02 00:24:22 +00:00
|
|
|
cli = (mca_base_component_list_item_t *) item;
|
|
|
|
component = (mca_ns_base_component_t *) cli->cli_component;
|
2004-07-11 04:34:47 +00:00
|
|
|
|
|
|
|
/* Call the component's init function and see if it wants to be
|
|
|
|
selected */
|
|
|
|
|
|
|
|
module = component->ns_init(&multi, &hidden, &priority);
|
|
|
|
|
|
|
|
/* If we got a non-NULL module back, then the component wants to
|
|
|
|
be selected. So save its multi/hidden values and save the
|
|
|
|
module with the highest priority */
|
|
|
|
|
|
|
|
if (NULL != module) {
|
|
|
|
/* If this is the best one, save it */
|
|
|
|
|
|
|
|
if (priority > best_priority) {
|
|
|
|
|
|
|
|
/* If there was a previous best one, finalize */
|
|
|
|
|
|
|
|
if (NULL != best_component) {
|
|
|
|
best_component->ns_finalize();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Save the new best one */
|
|
|
|
|
|
|
|
best_module = module;
|
|
|
|
best_component = component;
|
|
|
|
*allow_multi_user_threads = multi;
|
|
|
|
*have_hidden_threads = hidden;
|
2004-07-12 03:20:54 +00:00
|
|
|
|
|
|
|
/* update the best priority */
|
|
|
|
best_priority = priority;
|
2004-07-11 04:34:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If it's not the best one, finalize it */
|
|
|
|
|
|
|
|
else {
|
|
|
|
component->ns_finalize();
|
|
|
|
}
|
2004-07-11 00:10:52 +00:00
|
|
|
}
|
2004-07-11 04:34:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If we didn't find one to select, barf */
|
|
|
|
|
|
|
|
if (NULL == best_component) {
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We have happiness -- save the component and module for later
|
|
|
|
usage */
|
|
|
|
|
|
|
|
ompi_name_server = *best_module;
|
|
|
|
mca_ns_base_selected_component = *best_component;
|
|
|
|
mca_ns_base_selected = true;
|
|
|
|
|
|
|
|
/* all done */
|
2004-07-11 00:10:52 +00:00
|
|
|
|
2004-07-11 04:34:47 +00:00
|
|
|
return OMPI_SUCCESS;
|
2004-07-11 00:10:52 +00:00
|
|
|
}
|