2004-11-22 03:37:56 +03:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. 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-11-22 03:37:56 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-07-21 02:32:45 +04:00
|
|
|
#include "ompi_config.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "mpi.h"
|
2005-07-03 20:22:16 +04:00
|
|
|
#include "opal/class/opal_list.h"
|
2005-07-04 03:31:27 +04:00
|
|
|
#include "opal/util/output.h"
|
2005-09-01 16:16:36 +04:00
|
|
|
#include "opal/mca/mca.h"
|
|
|
|
#include "opal/mca/base/base.h"
|
|
|
|
#include "opal/mca/base/mca_base_component_repository.h"
|
|
|
|
#include "ompi/mca/topo/topo.h"
|
|
|
|
#include "ompi/mca/topo/base/base.h"
|
|
|
|
#include "ompi/include/constants.h"
|
2004-07-21 02:32:45 +04:00
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_t mca_topo_base_modules_available;
|
2004-07-21 02:32:45 +04:00
|
|
|
bool mca_topo_base_modules_available_valid = false;
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
static int init_query(const mca_base_component_t *m,
|
2005-03-27 17:05:23 +04:00
|
|
|
mca_base_component_priority_list_item_t *entry,
|
|
|
|
bool enable_progress_threads,
|
|
|
|
bool enable_mpi_threads);
|
2004-08-02 04:24:22 +04:00
|
|
|
static int init_query_1_0_0(const mca_base_component_t *component,
|
2005-03-27 17:05:23 +04:00
|
|
|
mca_base_component_priority_list_item_t *entry,
|
|
|
|
bool enable_progress_threads,
|
|
|
|
bool enable_mpi_threads);
|
2004-07-21 02:32:45 +04:00
|
|
|
|
2005-03-27 17:05:23 +04:00
|
|
|
int mca_topo_base_find_available(bool enable_progress_threads,
|
|
|
|
bool enable_mpi_threads)
|
2004-08-02 04:24:22 +04:00
|
|
|
{
|
2004-07-21 02:32:45 +04:00
|
|
|
bool found = false;
|
|
|
|
mca_base_component_priority_list_item_t *entry;
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t *p;
|
2004-07-21 02:32:45 +04:00
|
|
|
|
|
|
|
/* Initialize the list */
|
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
OBJ_CONSTRUCT(&mca_topo_base_components_available, opal_list_t);
|
2004-08-02 04:24:22 +04:00
|
|
|
mca_topo_base_components_available_valid = true;
|
2004-07-21 02:32:45 +04:00
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
/* The list of components which we should check is already present
|
|
|
|
in mca_topo_base_components_opened, which was established in
|
2004-07-21 02:32:45 +04:00
|
|
|
mca_topo_base_open */
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
for (found = false,
|
2005-07-03 20:22:16 +04:00
|
|
|
p = opal_list_remove_first (&mca_topo_base_components_opened);
|
2004-07-21 02:32:45 +04:00
|
|
|
NULL != p;
|
2005-07-03 20:22:16 +04:00
|
|
|
p = opal_list_remove_first (&mca_topo_base_components_opened)) {
|
2004-07-21 02:32:45 +04:00
|
|
|
entry = OBJ_NEW(mca_base_component_priority_list_item_t);
|
2004-11-12 19:55:41 +03:00
|
|
|
entry->super.cli_component =
|
2004-08-02 04:24:22 +04:00
|
|
|
((mca_base_component_list_item_t *)p)->cli_component;
|
2004-07-21 02:32:45 +04:00
|
|
|
|
|
|
|
/* Now for this entry, we have to determine the thread level. Call
|
|
|
|
a subroutine to do the job for us */
|
|
|
|
|
2005-03-27 17:05:23 +04:00
|
|
|
if (OMPI_SUCCESS == init_query(entry->super.cli_component, entry,
|
|
|
|
enable_progress_threads,
|
|
|
|
enable_mpi_threads)) {
|
2004-07-21 02:32:45 +04:00
|
|
|
/* Save the results in the list. The priority is not relvant at
|
|
|
|
this point in time. But we save the thread arguments so that
|
|
|
|
the initial selection algorithm can negotiate overall thread
|
|
|
|
level for this process */
|
|
|
|
entry->cpli_priority = 0;
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_append (&mca_topo_base_components_available,
|
|
|
|
(opal_list_item_t *) entry);
|
2004-07-21 02:32:45 +04:00
|
|
|
found = true;
|
|
|
|
} else {
|
|
|
|
/* The component does not want to run, so close it. Its close()
|
|
|
|
has already been invoked. Close it out of the DSO repository
|
|
|
|
(if it is there in the repository) */
|
2004-11-12 19:55:41 +03:00
|
|
|
mca_base_component_repository_release(entry->super.cli_component);
|
2004-07-21 02:32:45 +04:00
|
|
|
OBJ_RELEASE(entry);
|
|
|
|
}
|
|
|
|
/* Free entry from the "opened" list */
|
|
|
|
OBJ_RELEASE(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The opened list is no longer necessary, so we can free it */
|
2004-08-02 04:24:22 +04:00
|
|
|
OBJ_DESTRUCT (&mca_topo_base_components_opened);
|
|
|
|
mca_topo_base_components_opened_valid = false;
|
2004-07-21 02:32:45 +04:00
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
/* There should atleast be one topo component which was available */
|
2004-07-21 02:32:45 +04:00
|
|
|
if (false == found) {
|
|
|
|
/* Need to free all items in the list */
|
2004-08-02 04:24:22 +04:00
|
|
|
OBJ_DESTRUCT(&mca_topo_base_components_available);
|
|
|
|
mca_topo_base_components_available_valid = false;
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output_verbose (10, mca_topo_base_output,
|
2004-07-21 02:32:45 +04:00
|
|
|
"topo:find_available: no topo components available!");
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All done */
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
static int init_query(const mca_base_component_t *m,
|
2005-03-27 17:05:23 +04:00
|
|
|
mca_base_component_priority_list_item_t *entry,
|
|
|
|
bool enable_progress_threads,
|
|
|
|
bool enable_mpi_threads)
|
|
|
|
{
|
2004-07-21 02:32:45 +04:00
|
|
|
int ret;
|
|
|
|
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output_verbose(10, mca_topo_base_output,
|
2004-07-21 02:32:45 +04:00
|
|
|
"topo:find_available: querying topo component %s",
|
2004-08-02 04:24:22 +04:00
|
|
|
m->mca_component_name);
|
2004-07-21 02:32:45 +04:00
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
/* This component has been successfully opened, now try to query it */
|
2004-07-21 02:32:45 +04:00
|
|
|
if (1 == m->mca_type_major_version &&
|
|
|
|
0 == m->mca_type_minor_version &&
|
|
|
|
0 == m->mca_type_release_version) {
|
2005-03-27 17:05:23 +04:00
|
|
|
ret = init_query_1_0_0(m, entry, enable_progress_threads,
|
|
|
|
enable_mpi_threads);
|
2004-07-21 02:32:45 +04:00
|
|
|
} else {
|
|
|
|
/* unrecognised API version */
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output_verbose(10, mca_topo_base_output,
|
2004-07-21 02:32:45 +04:00
|
|
|
"topo:find_available:unrecognised topo API version (%d.%d.%d)",
|
|
|
|
m->mca_type_major_version,
|
|
|
|
m->mca_type_minor_version,
|
|
|
|
m->mca_type_release_version);
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Query done -- look at return value to see what happened */
|
|
|
|
if (OMPI_SUCCESS != ret) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output_verbose(10, mca_topo_base_output,
|
2004-07-21 02:32:45 +04:00
|
|
|
"topo:find_available topo 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-07-21 02:32:45 +04:00
|
|
|
}
|
|
|
|
} else {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output_verbose(10, mca_topo_base_output,
|
2004-07-21 02:32:45 +04:00
|
|
|
"topo:find_avalable: topo component %s is available",
|
2004-08-02 04:24:22 +04:00
|
|
|
m->mca_component_name);
|
2004-07-21 02:32:45 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
/* All done */
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
static int init_query_1_0_0(const mca_base_component_t *component,
|
2005-03-27 17:05:23 +04:00
|
|
|
mca_base_component_priority_list_item_t *entry,
|
|
|
|
bool enable_progress_threads,
|
|
|
|
bool enable_mpi_threads)
|
|
|
|
{
|
2004-08-02 04:24:22 +04:00
|
|
|
mca_topo_base_component_1_0_0_t *topo = (mca_topo_base_component_1_0_0_t *) component;
|
2004-07-21 02:32:45 +04:00
|
|
|
|
2005-03-27 17:05:23 +04:00
|
|
|
return topo->topom_init_query(enable_progress_threads,
|
|
|
|
enable_mpi_threads);
|
2004-07-21 02:32:45 +04:00
|
|
|
}
|