1
1
openmpi/ompi/tools/ompi_info/components.cc

240 строки
6.0 KiB
C++
Исходник Обычный вид История

//
// 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 (c) 2004-2005 High Performance Computing Center Stuttgart,
// University of Stuttgart. All rights reserved.
// Copyright (c) 2004-2005 The Regents of the University of California.
// All rights reserved.
// $COPYRIGHT$
//
// Additional copyrights may follow
//
// $HEADER$
//
#include "ompi_config.h"
#include <iostream>
#include <string>
#include <stdlib.h>
#include <string.h>
#include "ompi/runtime/params.h"
#include "orte/runtime/runtime.h"
#include "tools/ompi_info/ompi_info.h"
#include "mca/base/base.h"
#include "mca/allocator/allocator.h"
#include "mca/allocator/base/base.h"
#include "mca/coll/coll.h"
#include "mca/coll/base/base.h"
#include "mca/io/io.h"
#include "mca/io/base/base.h"
#include "mca/mpool/mpool.h"
#include "mca/mpool/base/base.h"
#include "mca/pml/pml.h"
#include "mca/pml/base/base.h"
#include "mca/ptl/ptl.h"
#include "mca/ptl/base/base.h"
#include "mca/topo/topo.h"
#include "mca/topo/base/base.h"
#include "mca/errmgr/errmgr.h"
#include "mca/errmgr/base/base.h"
#include "mca/gpr/gpr.h"
#include "mca/gpr/base/base.h"
#include "mca/iof/iof.h"
#include "mca/iof/base/base.h"
#include "mca/ns/ns.h"
#include "mca/ns/base/base.h"
#include "mca/oob/oob.h"
#include "mca/oob/base/base.h"
#include "mca/ras/ras.h"
#include "mca/ras/base/base.h"
#include "mca/rds/rds.h"
#include "mca/rds/base/base.h"
#include "mca/rmaps/rmaps.h"
#include "mca/rmaps/base/base.h"
#include "mca/rmgr/rmgr.h"
#include "mca/rmgr/base/base.h"
#include "mca/rml/rml.h"
#include "mca/rml/base/base.h"
#include "mca/pls/pls.h"
#include "mca/pls/base/base.h"
#include "mca/soh/soh.h"
#include "mca/soh/base/base.h"
using namespace std;
using namespace ompi_info;
//
// Public variables
//
ompi_info::component_map_t ompi_info::component_map;
//
// Private variables
//
static bool opened_components = false;
//
// Open all MCA components so that they can register their MCA
// parameters. Take a shotgun approach here and indiscriminately open
// all components -- don't be selective. To this end, we need to clear
// out the environment of all OMPI_MCA_<type> variables to ensure
// that the open algorithms don't try to only open one component.
//
void ompi_info::open_components()
{
ompi_info::type_vector_t::size_type i;
string env;
char *target;
if (opened_components)
return;
// Clear out the environment. Use strdup() to orphan the resulting
// strings because items are placed in the environment by reference,
// not by value.
for (i = 0; i < mca_types.size(); ++i) {
env = "OMPI_MCA_" + mca_types[i];
if (NULL != getenv(env.c_str())) {
env += "=";
target = strdup(env.c_str());
putenv(target);
}
}
// Open the DPS
if (ORTE_SUCCESS != orte_dps_open()) {
printf( "Unable to initialize the DPS\n" );
return;
}
- New capability for MCA parameters to be read from files. Order of resolution is now (effectively): - read from MPI keyval (if associated) - read from command line - read from environment - read from file More capabilities will be added shortly for developers to programatically set MCA parameter values - Create [empty but commented] system-wide MCA param file that gets installed at $sysconf/openmpi-mca-params.conf (i.e., $prefix/etc/openmpi-mca-params.conf) - The following files are opened and read (in order): 1. $sysconf/openmpi-mca-params.conf 2. $HOME/.openmpi/mca-params.conf Specifically, the values in 2) will override the values in 1) (so users can override system-wide defaults. - Update MCA string params to allow for "~/" in the middle to be expanded to the user's home directory. - Added to default value of MCA parameter component_path to be: $pkglibdir:$HOME/.openmpi/components $pkglibdir is typically $prefix/lib/openmpi. So now both of these directories will be searched for components at run time (in all Open MPI executables, including ompi_info). Note that this is an MCA parameter, so it, too, can be changed at run-time. - Updated all docs to match this behavior -- some is \internal, so it doesn't show unless you tell doxygen to generate internal docs (which is not the default) - update ompi_info to handle new behavior; ompi_info --param now shows the *current* default value (i.e., it will look in the environment and/or files to find out what the default values are -- so if you change a value in $HOME/.openmpi/mca-params.conf, it should be reflected in "ompi_info --param all all") - updated bunches of doxygen docs to match - this diff is slightly artifically large -- some of the changes are converstions to 4 space tabs (I re-indented my own code that previously used 2 space tabs) This commit was SVN r2408.
2004-08-31 09:49:56 +00:00
// Open up the MCA
mca_base_open();
// Register the MPI layer's MCA parameters
ompi_mpi_register_params();
// Find / open all components
component_map["base"] = NULL;
// ORTE frameworks
mca_oob_base_open();
component_map["oob"] = &mca_oob_base_components;
orte_errmgr_base_open();
component_map["errmgr"] = &orte_errmgr_base_components_available;
orte_gpr_base_open();
component_map["gpr"] = &orte_gpr_base_components_available;
orte_iof_base_open();
component_map["iof"] = &orte_iof_base.iof_components_opened;
orte_ns_base_open();
component_map["ns"] = &mca_ns_base_components_available;
orte_ras_base_open();
component_map["ras"] = &orte_ras_base.ras_opened;
orte_rds_base_open();
component_map["rds"] = &orte_rds_base.rds_components;
orte_rmaps_base_open();
component_map["rmaps"] = &orte_rmaps_base.rmaps_opened;
orte_rmgr_base_open();
component_map["rmgr"] = &orte_rmgr_base.rmgr_components;
orte_rml_base_open();
component_map["rml"] = &orte_rml_base.rml_components;
orte_pls_base_open();
component_map["pls"] = &orte_pls_base.pls_opened;
orte_soh_base_open();
component_map["soh"] = &orte_soh_base.soh_components;
// MPI frameworks
mca_allocator_base_open();
component_map["allocator"] = &mca_allocator_base_components;
mca_coll_base_open();
component_map["coll"] = &mca_coll_base_components_opened;
mca_io_base_open();
component_map["io"] = &mca_io_base_components_opened;
mca_mpool_base_open();
component_map["mpool"] = &mca_mpool_base_components;
mca_pml_base_open();
component_map["pml"] = &mca_pml_base_components_available;
/* mca_ptl_base_open() should not be called directly. This call is performed
* in the PML base open.
*/
component_map["ptl"] = &mca_ptl_base_components_opened;
mca_topo_base_open();
component_map["topo"] = &mca_topo_base_components_opened;
// All done
opened_components = true;
}
void ompi_info::close_components()
{
if (opened_components) {
// Note that the order of shutdown here doesn't matter because
// we aren't *using* any components -- none were selected, so
// there are no dependencies between the frameworks. We list
// them generally "in order", but it doesn't really matter.
mca_topo_base_close();
// the PMl has to call the base PTL close function.
mca_pml_base_close();
mca_mpool_base_close();
mca_io_base_close();
mca_coll_base_close();
mca_allocator_base_close();
orte_iof_base_close();
orte_soh_base_close();
orte_pls_base_close();
orte_rmgr_base_close();
orte_rmaps_base_close();
orte_rds_base_close();
orte_ras_base_close();
orte_ns_base_close();
orte_gpr_base_close();
orte_errmgr_base_close();
orte_rml_base_close();
mca_oob_base_close();
component_map.clear();
}
opened_components = false;
}