2004-06-29 04:02:25 +04: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-06-29 04:02:25 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "mpi.h"
|
|
|
|
#include "communicator/communicator.h"
|
|
|
|
#include "util/argv.h"
|
2004-09-05 20:05:37 +04:00
|
|
|
#include "util/show_help.h"
|
2004-06-29 04:02:25 +04:00
|
|
|
#include "class/ompi_list.h"
|
|
|
|
#include "class/ompi_object.h"
|
|
|
|
#include "mca/mca.h"
|
|
|
|
#include "mca/base/base.h"
|
|
|
|
#include "mca/coll/coll.h"
|
|
|
|
#include "mca/coll/base/base.h"
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables
|
|
|
|
*/
|
2004-08-02 04:24:22 +04:00
|
|
|
static mca_coll_base_module_1_0_0_t null_module = {
|
2004-06-29 04:02:25 +04:00
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
/* Module init and finalize */
|
|
|
|
|
|
|
|
NULL, NULL,
|
2004-06-29 04:02:25 +04:00
|
|
|
|
|
|
|
/* Collective function pointers */
|
|
|
|
|
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
2004-07-30 23:14:55 +04:00
|
|
|
NULL, NULL, NULL, NULL,
|
|
|
|
NULL, NULL, NULL, NULL, NULL
|
2004-06-29 04:02:25 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local types
|
|
|
|
*/
|
|
|
|
struct avail_coll_t {
|
2005-01-30 21:42:37 +03:00
|
|
|
ompi_list_item_t super;
|
2004-06-29 04:02:25 +04:00
|
|
|
|
2005-01-30 21:42:37 +03:00
|
|
|
int ac_priority;
|
|
|
|
const mca_coll_base_component_1_0_0_t *ac_component;
|
|
|
|
const mca_coll_base_module_1_0_0_t *ac_module;
|
|
|
|
struct mca_coll_base_comm_t *ac_data;
|
2004-06-29 04:02:25 +04:00
|
|
|
};
|
|
|
|
typedef struct avail_coll_t avail_coll_t;
|
|
|
|
|
2005-01-30 21:42:37 +03:00
|
|
|
|
2004-06-29 04:02:25 +04:00
|
|
|
/*
|
|
|
|
* Local functions
|
|
|
|
*/
|
|
|
|
static ompi_list_t *check_components(ompi_list_t *components,
|
|
|
|
ompi_communicator_t *comm,
|
|
|
|
char **names, int num_names);
|
|
|
|
static int check_one_component(ompi_communicator_t *comm,
|
2004-08-02 04:24:22 +04:00
|
|
|
const mca_base_component_t *component,
|
2005-01-30 21:42:37 +03:00
|
|
|
const mca_coll_base_module_1_0_0_t **module,
|
|
|
|
struct mca_coll_base_comm_t **data);
|
2004-06-29 04:02:25 +04:00
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
static int query(const mca_base_component_t *component,
|
2004-06-29 04:02:25 +04:00
|
|
|
ompi_communicator_t *comm, int *priority,
|
2005-01-30 21:42:37 +03:00
|
|
|
const mca_coll_base_module_1_0_0_t **module,
|
|
|
|
struct mca_coll_base_comm_t **data);
|
2004-08-02 04:24:22 +04:00
|
|
|
static int query_1_0_0(const mca_coll_base_component_1_0_0_t *coll_component,
|
2004-06-29 04:02:25 +04:00
|
|
|
ompi_communicator_t *comm, int *priority,
|
2005-01-30 21:42:37 +03:00
|
|
|
const mca_coll_base_module_1_0_0_t **module,
|
|
|
|
struct mca_coll_base_comm_t **data);
|
2004-06-29 04:02:25 +04:00
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
static void unquery(const mca_coll_base_component_1_0_0_t *coll_component,
|
2005-01-30 21:42:37 +03:00
|
|
|
ompi_communicator_t *comm,
|
|
|
|
struct mca_coll_base_comm_t *data);
|
2004-08-02 04:24:22 +04:00
|
|
|
static void unquery_1_0_0(const mca_coll_base_component_1_0_0_t *coll_component,
|
2005-01-30 21:42:37 +03:00
|
|
|
ompi_communicator_t *comm,
|
|
|
|
struct mca_coll_base_comm_t *data);
|
2004-06-29 04:02:25 +04:00
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
static int module_init(const mca_coll_base_module_1_0_0_t *module,
|
2004-06-29 04:02:25 +04:00
|
|
|
ompi_communicator_t *comm);
|
|
|
|
|
|
|
|
static int query_basic(ompi_communicator_t *comm);
|
2004-07-30 23:14:55 +04:00
|
|
|
static int replace_null_with_basic(ompi_communicator_t *comm);
|
2004-06-29 04:02:25 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stuff for the OBJ interface
|
|
|
|
*/
|
2004-09-23 04:00:01 +04:00
|
|
|
static OBJ_CLASS_INSTANCE(avail_coll_t, ompi_list_item_t, NULL, NULL);
|
2004-06-29 04:02:25 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This function is called at the initialization time of every
|
|
|
|
* communicator. It is used to select which coll component will be
|
|
|
|
* active for a given communicator.
|
|
|
|
*
|
|
|
|
* This selection logic is not for the weak.
|
|
|
|
*/
|
|
|
|
int mca_coll_base_comm_select(ompi_communicator_t *comm,
|
2004-08-02 04:24:22 +04:00
|
|
|
mca_base_component_t *preferred)
|
2004-06-29 04:02:25 +04:00
|
|
|
{
|
|
|
|
bool found, using_basic;
|
|
|
|
int err, num_names;
|
|
|
|
char name[MPI_MAX_OBJECT_NAME + 32];
|
|
|
|
char *names, **name_array;
|
|
|
|
char *str;
|
|
|
|
avail_coll_t *avail;
|
|
|
|
ompi_list_t *selectable;
|
|
|
|
ompi_list_item_t *item;
|
2004-08-02 04:24:22 +04:00
|
|
|
const mca_coll_base_component_1_0_0_t *selected_component, *component;
|
|
|
|
const mca_coll_base_module_1_0_0_t *selected_module;
|
2005-01-30 21:42:37 +03:00
|
|
|
struct mca_coll_base_comm_t *selected_data;
|
2004-06-29 04:02:25 +04:00
|
|
|
|
|
|
|
/* Announce */
|
|
|
|
|
|
|
|
snprintf(name, sizeof(name), "%s (cid %d)", comm->c_name,
|
|
|
|
comm->c_contextid);
|
|
|
|
name[sizeof(name) - 1] = '\0';
|
|
|
|
ompi_output_verbose(10, mca_coll_base_output,
|
|
|
|
"coll:base:comm_select: new communicator: %s",
|
|
|
|
name);
|
|
|
|
|
|
|
|
/* Initialize all the relevant pointers, since they're used as
|
|
|
|
sentinel values */
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
comm->c_coll = null_module;
|
2004-06-29 04:02:25 +04:00
|
|
|
|
2004-10-16 02:32:48 +04:00
|
|
|
comm->c_coll_selected_component = NULL;
|
2004-06-29 04:02:25 +04:00
|
|
|
comm->c_coll_selected_data = NULL;
|
|
|
|
comm->c_coll_selected_module = NULL;
|
|
|
|
|
|
|
|
comm->c_coll_basic_data = NULL;
|
|
|
|
comm->c_coll_basic_module = NULL;
|
|
|
|
|
|
|
|
/* See if a set of component was requested by the MCA parameter.
|
|
|
|
Don't check for error. */
|
|
|
|
|
|
|
|
names = NULL;
|
|
|
|
mca_base_param_lookup_string(mca_coll_base_param, &names);
|
|
|
|
|
|
|
|
/* Compute the intersection of all of my available components with
|
|
|
|
the components from all the other processes in this
|
|
|
|
communicator */
|
|
|
|
|
|
|
|
/* JMS CONTINUE HERE */
|
|
|
|
|
|
|
|
/* See if a preferred component was provided. If so, try to select
|
|
|
|
it. If we don't succeed, fall through and do a normal
|
|
|
|
selection. */
|
|
|
|
|
|
|
|
err = OMPI_ERROR;
|
|
|
|
if (NULL != preferred) {
|
2004-08-02 04:24:22 +04:00
|
|
|
str = &(preferred->mca_component_name[0]);
|
2004-06-29 04:02:25 +04:00
|
|
|
|
|
|
|
ompi_output_verbose(10, mca_coll_base_output,
|
|
|
|
"coll:base:comm_select: Checking preferred module: %s",
|
|
|
|
str);
|
|
|
|
selectable = check_components(&mca_coll_base_components_available,
|
|
|
|
comm, &str, 1);
|
|
|
|
|
|
|
|
/* If we didn't get a preferred module, then call again without a
|
|
|
|
preferred module. This makes the logic below dramatically
|
|
|
|
simpler. */
|
|
|
|
|
|
|
|
if (NULL == selectable) {
|
|
|
|
return mca_coll_base_comm_select(comm, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We only fall through here if we were able to select one of the
|
|
|
|
preferred modules */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If there was no preferred module, then see if there were any listed
|
|
|
|
in the MCA parameter; parse them and check them all */
|
|
|
|
|
|
|
|
else if (NULL != names && 0 < strlen(names)) {
|
2004-07-13 08:43:16 +04:00
|
|
|
name_array = ompi_argv_split(names, ',');
|
2004-06-29 04:02:25 +04:00
|
|
|
num_names = ompi_argv_count(name_array);
|
|
|
|
|
|
|
|
ompi_output_verbose(10, mca_coll_base_output,
|
|
|
|
"coll:base:comm_select: Checking specific modules: %s",
|
|
|
|
names);
|
|
|
|
selectable = check_components(&mca_coll_base_components_available,
|
|
|
|
comm, name_array, num_names);
|
|
|
|
ompi_argv_free(name_array);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Nope -- a specific [set of] component[s] was not requested. Go
|
|
|
|
check them all. */
|
|
|
|
|
|
|
|
else {
|
|
|
|
ompi_output_verbose(10, mca_coll_base_output,
|
|
|
|
"coll:base:comm_select: Checking all available modules");
|
|
|
|
selectable = check_components(&mca_coll_base_components_available,
|
|
|
|
comm, NULL, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Upon return from the above, the modules list will contain the
|
|
|
|
list of modules that returned (priority >= 0). If we have no
|
|
|
|
collective modules available, then use the basic component */
|
|
|
|
|
|
|
|
if (NULL == selectable) {
|
|
|
|
found = false;
|
|
|
|
if (NULL != mca_coll_base_basic_component) {
|
|
|
|
query_basic(comm);
|
|
|
|
if (NULL != comm->c_coll_basic_module) {
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
/* There's no modules available -- including basic. Doh! */
|
2004-09-05 20:05:37 +04:00
|
|
|
ompi_show_help("help-mca-coll-base",
|
|
|
|
"comm-select:none-available", true);
|
2004-06-29 04:02:25 +04:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Do some kind of collective operation to find a module that
|
|
|
|
everyone has available */
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
/* For the moment, just take the top module off the list */
|
|
|
|
|
|
|
|
if (NULL != selectable) {
|
|
|
|
using_basic = false;
|
|
|
|
item = ompi_list_remove_first(selectable);
|
|
|
|
avail = (avail_coll_t *) item;
|
|
|
|
selected_component = avail->ac_component;
|
|
|
|
selected_module = avail->ac_module;
|
2005-01-30 21:42:37 +03:00
|
|
|
selected_data = avail->ac_data;
|
2004-06-29 04:02:25 +04:00
|
|
|
OBJ_RELEASE(avail);
|
|
|
|
} else {
|
|
|
|
using_basic = true;
|
|
|
|
selected_component = mca_coll_base_basic_component;
|
|
|
|
selected_module = comm->c_coll_basic_module;
|
2005-01-30 21:42:37 +03:00
|
|
|
selected_data = comm->c_coll_basic_data;
|
2004-06-29 04:02:25 +04:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
/* JMS CONTINUE HERE */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Everything left in the selectable list is therefore unwanted,
|
|
|
|
and we call their unquery() method (because they all had query()
|
|
|
|
invoked, but will never have init() invoked in this scope). */
|
|
|
|
|
|
|
|
if (NULL != selectable) {
|
|
|
|
for (item = ompi_list_remove_first(selectable); item != NULL;
|
|
|
|
item = ompi_list_remove_first(selectable)) {
|
|
|
|
avail = (avail_coll_t *) item;
|
|
|
|
component = avail->ac_component;
|
2005-01-30 21:42:37 +03:00
|
|
|
unquery(component, comm, avail->ac_data);
|
2004-06-29 04:02:25 +04:00
|
|
|
OBJ_RELEASE(avail);
|
|
|
|
}
|
2004-09-03 00:58:54 +04:00
|
|
|
OBJ_RELEASE(selectable);
|
2004-06-29 04:02:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If we're not using the basic module, then set it up, replace all
|
|
|
|
NULL function pointers with those from basic, and then initialize
|
|
|
|
it. */
|
|
|
|
|
2004-10-16 02:32:48 +04:00
|
|
|
comm->c_coll_selected_component = selected_component;
|
2005-01-30 21:42:37 +03:00
|
|
|
comm->c_coll_selected_data = selected_data;
|
2004-06-29 04:02:25 +04:00
|
|
|
if (!using_basic) {
|
|
|
|
comm->c_coll = *selected_module;
|
|
|
|
replace_null_with_basic(comm);
|
|
|
|
|
|
|
|
/* Finally -- intialize the selected module. If it's the basic
|
|
|
|
module, we've initialized it already. */
|
|
|
|
|
|
|
|
err = module_init(selected_module, comm);
|
|
|
|
if (OMPI_SUCCESS != err) {
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now double check because we may have gotten a different module
|
|
|
|
back from the init function; ensure that there are no NULL's in
|
|
|
|
there */
|
|
|
|
|
|
|
|
replace_null_with_basic(comm);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Announce the winner */
|
|
|
|
|
|
|
|
ompi_output_verbose(10, mca_coll_base_output,
|
|
|
|
"coll:base:comm_select: Selected coll module %s",
|
2004-08-02 04:24:22 +04:00
|
|
|
selected_component->collm_version.mca_component_name);
|
2004-06-29 04:02:25 +04:00
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For each module in the list, if it is in the list of names (or the
|
|
|
|
* list of names is NULL), then check and see if it wants to run, and
|
|
|
|
* do the resulting priority comparison. Make a list of modules to be
|
|
|
|
* only those who returned that they want to run, and put them in
|
|
|
|
* priority order.
|
|
|
|
*/
|
|
|
|
static ompi_list_t *check_components(ompi_list_t *components,
|
|
|
|
ompi_communicator_t *comm,
|
|
|
|
char **names, int num_names)
|
|
|
|
{
|
|
|
|
int i, priority;
|
2004-08-02 04:24:22 +04:00
|
|
|
const mca_base_component_t *component;
|
2004-08-04 01:29:23 +04:00
|
|
|
ompi_list_item_t *item, *item2;
|
|
|
|
const mca_coll_base_module_1_0_0_t *module;
|
2004-06-29 04:02:25 +04:00
|
|
|
bool want_to_check;
|
|
|
|
ompi_list_t *selectable;
|
2004-07-30 23:14:55 +04:00
|
|
|
avail_coll_t *avail, *avail2;
|
2005-01-30 21:42:37 +03:00
|
|
|
struct mca_coll_base_comm_t *data;
|
2004-09-14 13:10:23 +04:00
|
|
|
|
2004-06-29 04:02:25 +04:00
|
|
|
/* Make a list of the components that query successfully */
|
|
|
|
|
|
|
|
selectable = OBJ_NEW(ompi_list_t);
|
|
|
|
|
|
|
|
/* Scan through the list of components. This nested loop is O(N^2),
|
|
|
|
but we should never have too many components and/or names, so this
|
|
|
|
*hopefully* shouldn't matter... */
|
|
|
|
|
|
|
|
for (item = ompi_list_get_first(components);
|
|
|
|
item != ompi_list_get_end(components);
|
2004-08-04 01:29:23 +04:00
|
|
|
item = ompi_list_get_next(item)) {
|
2004-06-29 04:02:25 +04:00
|
|
|
component = ((mca_base_component_priority_list_item_t *)
|
2004-11-12 19:55:41 +03:00
|
|
|
item)->super.cli_component;
|
2004-06-29 04:02:25 +04:00
|
|
|
|
|
|
|
/* If we have a list of names, scan through it */
|
|
|
|
|
|
|
|
if (0 == num_names) {
|
|
|
|
want_to_check = true;
|
|
|
|
} else {
|
|
|
|
want_to_check = false;
|
|
|
|
for (i = 0; i < num_names; ++i) {
|
2004-08-02 04:24:22 +04:00
|
|
|
if (0 == strcmp(names[i], component->mca_component_name)) {
|
2004-06-29 04:02:25 +04:00
|
|
|
want_to_check = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we determined that we want to check this component, then do
|
|
|
|
so */
|
|
|
|
|
|
|
|
if (want_to_check) {
|
2005-01-30 21:42:37 +03:00
|
|
|
priority = check_one_component(comm, component, &module, &data);
|
2005-02-10 07:15:16 +03:00
|
|
|
if (priority >= 0) {
|
2004-06-29 04:02:25 +04:00
|
|
|
|
|
|
|
/* We have a component that indicated that it wants to run by
|
|
|
|
giving us a module */
|
|
|
|
|
|
|
|
avail = OBJ_NEW(avail_coll_t);
|
2004-09-03 18:57:00 +04:00
|
|
|
avail->ac_priority = priority;
|
2004-08-02 04:24:22 +04:00
|
|
|
avail->ac_component = (mca_coll_base_component_1_0_0_t *) component;
|
2004-08-04 01:29:23 +04:00
|
|
|
avail->ac_module = module;
|
2005-01-30 21:42:37 +03:00
|
|
|
avail->ac_data = data;
|
2004-06-29 04:02:25 +04:00
|
|
|
|
2004-07-30 23:14:55 +04:00
|
|
|
/* Put this item on the list in priority order (highest
|
|
|
|
priority first). Should it go first? */
|
|
|
|
|
2005-02-10 07:15:16 +03:00
|
|
|
if (ompi_list_is_empty(selectable)) {
|
|
|
|
ompi_list_prepend(selectable, (ompi_list_item_t *) avail);
|
2004-07-30 23:14:55 +04:00
|
|
|
} else {
|
2005-02-10 07:15:16 +03:00
|
|
|
item2 = ompi_list_get_first(selectable);
|
2004-07-30 23:14:55 +04:00
|
|
|
avail2 = (avail_coll_t *) item2;
|
|
|
|
if (avail->ac_priority > avail2->ac_priority) {
|
2005-02-10 07:15:16 +03:00
|
|
|
ompi_list_prepend(selectable, (ompi_list_item_t *) avail);
|
|
|
|
} else {
|
|
|
|
for (i = 1; item2 != ompi_list_get_end(selectable);
|
|
|
|
item2 = ompi_list_get_next(item2), ++i) {
|
|
|
|
avail2 = (avail_coll_t *) item2;
|
|
|
|
if (avail->ac_priority > avail2->ac_priority) {
|
|
|
|
ompi_list_insert(selectable,
|
|
|
|
(ompi_list_item_t *) avail, i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we didn't find a place to put it in the list, then
|
|
|
|
append it (because it has the lowest priority found so
|
|
|
|
far) */
|
|
|
|
|
|
|
|
if (ompi_list_get_end(selectable) == item2) {
|
|
|
|
ompi_list_append(selectable, (ompi_list_item_t *) avail);
|
|
|
|
}
|
2004-07-30 23:14:55 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-06-29 04:02:25 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we didn't find any available components, return an error */
|
|
|
|
|
|
|
|
if (0 == ompi_list_get_size(selectable)) {
|
|
|
|
OBJ_RELEASE(selectable);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All done */
|
|
|
|
|
|
|
|
return selectable;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check a single component
|
|
|
|
*/
|
|
|
|
static int check_one_component(ompi_communicator_t *comm,
|
2004-08-02 04:24:22 +04:00
|
|
|
const mca_base_component_t *component,
|
2005-01-30 21:42:37 +03:00
|
|
|
const mca_coll_base_module_1_0_0_t **module,
|
|
|
|
struct mca_coll_base_comm_t **data)
|
2004-06-29 04:02:25 +04:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
int priority = -1;
|
|
|
|
|
2005-01-30 21:42:37 +03:00
|
|
|
err = query(component, comm, &priority, module, data);
|
2004-06-29 04:02:25 +04:00
|
|
|
|
|
|
|
if (OMPI_SUCCESS == err) {
|
|
|
|
priority = (priority < 100) ? priority : 100;
|
|
|
|
ompi_output_verbose(10, mca_coll_base_output,
|
|
|
|
"coll:base:comm_select: component available: %s, priority: %d",
|
2004-08-02 04:24:22 +04:00
|
|
|
component->mca_component_name, priority);
|
2004-06-29 04:02:25 +04:00
|
|
|
|
|
|
|
} else {
|
|
|
|
priority = -1;
|
|
|
|
ompi_output_verbose(10, mca_coll_base_output,
|
|
|
|
"coll:base:comm_select: component not available: %s",
|
2004-08-02 04:24:22 +04:00
|
|
|
component->mca_component_name);
|
2004-06-29 04:02:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return priority;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* Query functions
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Take any version of a coll module, query it, and return the right
|
2004-08-04 01:29:23 +04:00
|
|
|
* module struct
|
2004-06-29 04:02:25 +04:00
|
|
|
*/
|
2004-08-02 04:24:22 +04:00
|
|
|
static int query(const mca_base_component_t *component,
|
2004-06-29 04:02:25 +04:00
|
|
|
ompi_communicator_t *comm,
|
2005-01-30 21:42:37 +03:00
|
|
|
int *priority, const mca_coll_base_module_1_0_0_t **module,
|
|
|
|
struct mca_coll_base_comm_t **data)
|
2004-06-29 04:02:25 +04:00
|
|
|
{
|
|
|
|
/* coll v1.0.0 */
|
|
|
|
|
|
|
|
*module = NULL;
|
|
|
|
if (1 == component->mca_major_version &&
|
|
|
|
0 == component->mca_minor_version &&
|
|
|
|
0 == component->mca_release_version) {
|
2004-08-02 04:24:22 +04:00
|
|
|
const mca_coll_base_component_1_0_0_t *coll100 =
|
|
|
|
(mca_coll_base_component_1_0_0_t *) component;
|
2004-06-29 04:02:25 +04:00
|
|
|
|
2005-01-30 21:42:37 +03:00
|
|
|
return query_1_0_0(coll100, comm, priority, module, data);
|
2004-06-29 04:02:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Unknown coll API version -- return error */
|
|
|
|
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
static int query_1_0_0(const mca_coll_base_component_1_0_0_t *component,
|
2004-06-29 04:02:25 +04:00
|
|
|
ompi_communicator_t *comm, int *priority,
|
2005-01-30 21:42:37 +03:00
|
|
|
const mca_coll_base_module_1_0_0_t **module,
|
|
|
|
struct mca_coll_base_comm_t **data)
|
2004-06-29 04:02:25 +04:00
|
|
|
{
|
2004-08-02 04:24:22 +04:00
|
|
|
const mca_coll_base_module_1_0_0_t *ret;
|
2004-06-29 04:02:25 +04:00
|
|
|
|
|
|
|
/* There's currently no need for conversion */
|
|
|
|
|
2005-01-30 21:42:37 +03:00
|
|
|
ret = component->collm_comm_query(comm, priority, data);
|
2004-06-29 04:02:25 +04:00
|
|
|
if (NULL != ret) {
|
|
|
|
*module = ret;
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* Unquery functions
|
|
|
|
**************************************************************************/
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
static void unquery(const mca_coll_base_component_1_0_0_t *component,
|
2005-01-30 21:42:37 +03:00
|
|
|
ompi_communicator_t *comm,
|
|
|
|
struct mca_coll_base_comm_t *data)
|
2004-06-29 04:02:25 +04:00
|
|
|
{
|
|
|
|
if (1 == component->collm_version.mca_major_version &&
|
|
|
|
0 == component->collm_version.mca_minor_version &&
|
|
|
|
0 == component->collm_version.mca_release_version) {
|
2004-08-02 04:24:22 +04:00
|
|
|
const mca_coll_base_component_1_0_0_t *coll100 =
|
|
|
|
(mca_coll_base_component_1_0_0_t *) component;
|
2004-06-29 04:02:25 +04:00
|
|
|
|
2005-01-30 21:42:37 +03:00
|
|
|
unquery_1_0_0(coll100, comm, data);
|
2004-06-29 04:02:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* There's no way to have a version that we don't recognize here --
|
|
|
|
it would have already been removed from the list */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
static void unquery_1_0_0(const mca_coll_base_component_1_0_0_t *component,
|
2005-01-30 21:42:37 +03:00
|
|
|
ompi_communicator_t *comm,
|
|
|
|
struct mca_coll_base_comm_t *data)
|
2004-06-29 04:02:25 +04:00
|
|
|
{
|
2005-01-30 21:42:37 +03:00
|
|
|
if (NULL != component->collm_comm_unquery) {
|
|
|
|
component->collm_comm_unquery(comm, data);
|
|
|
|
}
|
2004-06-29 04:02:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* Module_Init functions
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize a module
|
|
|
|
*/
|
2004-08-02 04:24:22 +04:00
|
|
|
static int module_init(const mca_coll_base_module_1_0_0_t *module,
|
2004-06-29 04:02:25 +04:00
|
|
|
ompi_communicator_t *comm)
|
|
|
|
{
|
2004-08-02 04:24:22 +04:00
|
|
|
const mca_coll_base_module_1_0_0_t *ret;
|
2004-06-29 04:02:25 +04:00
|
|
|
|
|
|
|
/* There's currently no need for conversion */
|
|
|
|
|
|
|
|
ret = module->coll_module_init(comm);
|
|
|
|
if (NULL != ret) {
|
|
|
|
if (comm->c_coll_selected_module != ret) {
|
|
|
|
comm->c_coll = *ret;
|
|
|
|
comm->c_coll_selected_module = ret;
|
|
|
|
}
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* Misc functions
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the basic module has not already been setup on this
|
|
|
|
* communicator, query and initialize it.
|
|
|
|
*/
|
|
|
|
static int query_basic(ompi_communicator_t *comm)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
int priority;
|
2005-01-30 21:42:37 +03:00
|
|
|
struct mca_coll_base_comm_t *data;
|
2004-06-29 04:02:25 +04:00
|
|
|
|
|
|
|
ret = OMPI_SUCCESS;
|
|
|
|
if (NULL == comm->c_coll_basic_module) {
|
2004-08-02 04:24:22 +04:00
|
|
|
ret = query((mca_base_component_t *) mca_coll_base_basic_component, comm,
|
2005-01-30 21:42:37 +03:00
|
|
|
&priority, &comm->c_coll_basic_module, &data);
|
2004-06-29 04:02:25 +04:00
|
|
|
if (ret != OMPI_SUCCESS) {
|
|
|
|
comm->c_coll_basic_module = NULL;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-01-30 21:42:37 +03:00
|
|
|
comm->c_coll_basic_data = data;
|
2004-06-29 04:02:25 +04:00
|
|
|
ret = module_init(comm->c_coll_basic_module, comm);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Replace the NULL pointers by corresponsing ompi_basic pointers
|
|
|
|
*/
|
2004-07-30 23:14:55 +04:00
|
|
|
static int replace_null_with_basic(ompi_communicator_t *comm)
|
2004-06-29 04:02:25 +04:00
|
|
|
{
|
2004-07-30 23:14:55 +04:00
|
|
|
int err;
|
|
|
|
|
2004-06-29 04:02:25 +04:00
|
|
|
#define CHECK(name) \
|
|
|
|
if (NULL == comm->c_coll.coll_##name) { \
|
2004-07-30 23:14:55 +04:00
|
|
|
if (OMPI_SUCCESS != (err = query_basic(comm))) { \
|
|
|
|
return err; \
|
|
|
|
} \
|
2004-06-29 04:02:25 +04:00
|
|
|
comm->c_coll.coll_##name = comm->c_coll_basic_module->coll_##name; \
|
|
|
|
}
|
|
|
|
|
|
|
|
CHECK(allgather);
|
|
|
|
CHECK(allgatherv);
|
|
|
|
CHECK(allreduce);
|
|
|
|
CHECK(alltoall);
|
|
|
|
CHECK(alltoallv);
|
|
|
|
CHECK(alltoallw);
|
|
|
|
CHECK(barrier);
|
|
|
|
CHECK(bcast);
|
|
|
|
CHECK(exscan);
|
|
|
|
CHECK(gather);
|
|
|
|
CHECK(gatherv);
|
|
|
|
CHECK(reduce);
|
|
|
|
CHECK(reduce_scatter);
|
|
|
|
CHECK(scan);
|
|
|
|
CHECK(scatter);
|
|
|
|
CHECK(scatterv);
|
2004-07-30 23:14:55 +04:00
|
|
|
|
|
|
|
/* Happiness; all done */
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
2004-06-29 04:02:25 +04:00
|
|
|
}
|