2004-06-29 04:02:25 +04:00
|
|
|
/*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2004-11-05 10:52:30 +03:00
|
|
|
#include <string.h>
|
2004-06-29 04:02:25 +04:00
|
|
|
|
|
|
|
#include "mpi.h"
|
|
|
|
#include "include/constants.h"
|
|
|
|
#include "class/ompi_list.h"
|
|
|
|
#include "util/output.h"
|
2004-09-05 20:05:37 +04:00
|
|
|
#include "util/show_help.h"
|
2004-06-29 04:02:25 +04:00
|
|
|
#include "mca/mca.h"
|
|
|
|
#include "mca/base/base.h"
|
|
|
|
#include "mca/coll/coll.h"
|
|
|
|
#include "mca/coll/base/base.h"
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Global variables
|
|
|
|
*/
|
|
|
|
bool mca_coll_base_components_available_valid = false;
|
|
|
|
ompi_list_t mca_coll_base_components_available;
|
2004-08-02 04:24:22 +04:00
|
|
|
const mca_coll_base_component_1_0_0_t *mca_coll_base_basic_component = NULL;
|
2004-06-29 04:02:25 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Private functions
|
|
|
|
*/
|
2004-08-02 04:24:22 +04:00
|
|
|
static int init_query(const mca_base_component_t *ls,
|
2004-06-29 04:02:25 +04:00
|
|
|
mca_base_component_priority_list_item_t *entry);
|
2004-08-02 04:24:22 +04:00
|
|
|
static int init_query_1_0_0(const mca_base_component_t *ls,
|
2004-06-29 04:02:25 +04:00
|
|
|
mca_base_component_priority_list_item_t *entry);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Scan down the list of successfully opened components and query each of
|
|
|
|
* them (the opened list will be one or more components. If the user
|
|
|
|
* requested a specific component, it will be the only component in the
|
|
|
|
* opened list). Create and populate the available list of all
|
|
|
|
* components who indicate that they want to be considered for selection.
|
|
|
|
* Close all components who do not want to be considered for selection,
|
|
|
|
* and destroy the opened list.
|
|
|
|
*
|
|
|
|
* Also find the basic component while we're doing all of this, and save
|
|
|
|
* it in a global variable so that we can find it easily later (e.g.,
|
|
|
|
* during scope selection).
|
|
|
|
*/
|
|
|
|
int mca_coll_base_find_available(bool *allow_multi_user_threads,
|
|
|
|
bool *have_hidden_threads)
|
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
mca_base_component_priority_list_item_t *entry;
|
|
|
|
ompi_list_item_t *p;
|
2004-08-02 04:24:22 +04:00
|
|
|
const mca_base_component_t *component;
|
2004-06-29 04:02:25 +04:00
|
|
|
|
|
|
|
/* Initialize the list */
|
|
|
|
|
|
|
|
OBJ_CONSTRUCT(&mca_coll_base_components_available, ompi_list_t);
|
|
|
|
mca_coll_base_components_available_valid = true;
|
|
|
|
|
|
|
|
/* The list of components that we should check has already been
|
|
|
|
established in mca_coll_base_open. */
|
|
|
|
|
|
|
|
for (found = false,
|
|
|
|
p = ompi_list_remove_first(&mca_coll_base_components_opened);
|
|
|
|
p != NULL;
|
|
|
|
p = ompi_list_remove_first(&mca_coll_base_components_opened)) {
|
2004-08-02 04:24:22 +04:00
|
|
|
component = ((mca_base_component_list_item_t *) p)->cli_component;
|
2004-06-29 04:02:25 +04:00
|
|
|
|
|
|
|
/* Call a subroutine to do the work, because the component may
|
|
|
|
represent different versions of the coll MCA. */
|
|
|
|
|
2004-07-14 00:41:46 +04:00
|
|
|
entry = OBJ_NEW(mca_base_component_priority_list_item_t);
|
2004-11-12 19:55:41 +03:00
|
|
|
entry->super.cli_component = component;
|
2004-07-14 00:41:46 +04:00
|
|
|
entry->cpli_priority = 0;
|
2004-07-13 08:43:16 +04:00
|
|
|
if (OMPI_SUCCESS == init_query(component, entry)) {
|
2004-06-29 04:02:25 +04:00
|
|
|
|
|
|
|
/* Is this the basic component? If so, save it, because it's
|
|
|
|
special. Keep it off the available list -- we'll use it
|
|
|
|
specially in the selection process. */
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
if (0 == strcmp(component->mca_component_name, "basic")) {
|
2004-06-29 04:02:25 +04:00
|
|
|
mca_coll_base_basic_component =
|
2004-08-02 04:24:22 +04:00
|
|
|
(mca_coll_base_component_1_0_0_t *) component;
|
2004-08-04 01:29:23 +04:00
|
|
|
OBJ_RELEASE(entry);
|
2004-06-29 04:02:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Otherwise, save the results in the list. The priority isn't
|
|
|
|
relevant, because selection is decided at
|
|
|
|
communicator-constructor time. But we save the thread
|
|
|
|
arguments (set in the init_query() function) so that the
|
|
|
|
initial selection algorithm can negotiate the overall thread
|
|
|
|
level for this process. */
|
|
|
|
|
|
|
|
else {
|
|
|
|
ompi_list_append(&mca_coll_base_components_available,
|
|
|
|
(ompi_list_item_t *) entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Either way, we found something :-) */
|
|
|
|
|
|
|
|
found = true;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* If the component doesn't want to run, then close it. It's
|
|
|
|
already had its close() method invoked; now close it out of
|
|
|
|
the DSO repository (if it's there). */
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
mca_base_component_repository_release(component);
|
2004-07-14 00:41:46 +04:00
|
|
|
OBJ_RELEASE(entry);
|
2004-06-29 04:02:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Free the entry from the "opened" list */
|
|
|
|
|
2004-07-13 08:43:16 +04:00
|
|
|
OBJ_RELEASE(p);
|
2004-06-29 04:02:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The opened list is now no longer useful and we can free it */
|
|
|
|
|
|
|
|
OBJ_DESTRUCT(&mca_coll_base_components_opened);
|
|
|
|
mca_coll_base_components_opened_valid = false;
|
|
|
|
|
|
|
|
/* If we have no collective components available, it's an error.
|
|
|
|
Thanks for playing! */
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
/* Need to free all items in the list */
|
|
|
|
OBJ_DESTRUCT(&mca_coll_base_components_available);
|
|
|
|
mca_coll_base_components_available_valid = false;
|
|
|
|
ompi_output_verbose(10, mca_coll_base_output,
|
|
|
|
"coll:find_available: no coll components available!");
|
2004-09-05 20:05:37 +04:00
|
|
|
ompi_show_help("help-mca-base", "find-available:none-found", true,
|
|
|
|
"coll");
|
2004-06-29 04:02:25 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All done */
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Query a component, see if it wants to run at all. If it does, save
|
|
|
|
* some information. If it doesn't, close it.
|
|
|
|
*/
|
2004-08-02 04:24:22 +04:00
|
|
|
static int init_query(const mca_base_component_t *m,
|
2004-06-29 04:02:25 +04:00
|
|
|
mca_base_component_priority_list_item_t *entry)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ompi_output_verbose(10, mca_coll_base_output,
|
|
|
|
"coll:find_available: querying coll component %s",
|
2004-08-02 04:24:22 +04:00
|
|
|
m->mca_component_name);
|
2004-06-29 04:02:25 +04:00
|
|
|
|
|
|
|
/* This component has already been successfully opened. So now query
|
|
|
|
it. */
|
|
|
|
|
2004-07-13 08:43:16 +04:00
|
|
|
if (1 == m->mca_type_major_version &&
|
|
|
|
0 == m->mca_type_minor_version &&
|
|
|
|
0 == m->mca_type_release_version) {
|
2004-06-29 04:02:25 +04:00
|
|
|
ret = init_query_1_0_0(m, entry);
|
|
|
|
} else {
|
|
|
|
/* Unrecognized coll API version */
|
|
|
|
|
|
|
|
ompi_output_verbose(10, mca_coll_base_output,
|
2004-09-05 20:05:37 +04:00
|
|
|
"coll:find_available: unrecognized coll API version (%d.%d.%d, ignored)",
|
2004-06-29 04:02:25 +04:00
|
|
|
m->mca_type_major_version,
|
|
|
|
m->mca_type_minor_version,
|
|
|
|
m->mca_type_release_version);
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Query done -- look at the return value to see what happened */
|
|
|
|
|
2004-07-13 08:43:16 +04:00
|
|
|
if (OMPI_SUCCESS != ret) {
|
2004-06-29 04:02:25 +04:00
|
|
|
ompi_output_verbose(10, mca_coll_base_output,
|
|
|
|
"coll:find_available: coll component %s is not available",
|
2004-08-02 04:24:22 +04:00
|
|
|
m->mca_component_name);
|
|
|
|
if (NULL != m->mca_close_component) {
|
|
|
|
m->mca_close_component();
|
2004-06-29 04:02:25 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ompi_output_verbose(10, mca_coll_base_output,
|
|
|
|
"coll:find_available: coll component %s is available",
|
2004-08-02 04:24:22 +04:00
|
|
|
m->mca_component_name);
|
2004-06-29 04:02:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* All done */
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Query a specific component, coll v1.0.0
|
|
|
|
*/
|
|
|
|
static int
|
2004-08-02 04:24:22 +04:00
|
|
|
init_query_1_0_0(const mca_base_component_t *component,
|
2004-06-29 04:02:25 +04:00
|
|
|
mca_base_component_priority_list_item_t *entry)
|
|
|
|
{
|
2004-08-02 04:24:22 +04:00
|
|
|
mca_coll_base_component_1_0_0_t *coll =
|
|
|
|
(mca_coll_base_component_1_0_0_t *) component;
|
2004-06-29 04:02:25 +04:00
|
|
|
|
|
|
|
return coll->collm_init_query(&(entry->cpli_allow_multi_user_threads),
|
|
|
|
&(entry->cpli_have_hidden_threads));
|
|
|
|
}
|