1
1
openmpi/ompi/mca/sbgp/basesmuma/sbgp_basesmuma_component.c
Nathan Hjelm cf377db823 MCA/base: Add new MCA variable system
Features:
 - Support for an override parameter file (openmpi-mca-param-override.conf).
   Variable values in this file can not be overridden by any file or environment
   value.
 - Support for boolean, unsigned, and unsigned long long variables.
 - Support for true/false values.
 - Support for enumerations on integer variables.
 - Support for MPIT scope, verbosity, and binding.
 - Support for command line source.
 - Support for setting variable source via the environment using
   OMPI_MCA_SOURCE_<var name>=source (either command or file:filename)
 - Cleaner API.
 - Support for variable groups (equivalent to MPIT categories).

Notes:
 - Variables must be created with a backing store (char **, int *, or bool *)
   that must live at least as long as the variable.
 - Creating a variable with the MCA_BASE_VAR_FLAG_SETTABLE enables the use of
   mca_base_var_set_value() to change the value.
 - String values are duplicated when the variable is registered. It is up to
   the caller to free the original value if necessary. The new value will be
   freed by the mca_base_var system and must not be freed by the user.
 - Variables with constant scope may not be settable.
 - Variable groups (and all associated variables) are deregistered when the
   component is closed or the component repository item is freed. This
   prevents a segmentation fault from accessing a variable after its component
   is unloaded.
 - After some discussion we decided we should remove the automatic registration
   of component priority variables. Few component actually made use of this
   feature.
 - The enumerator interface was updated to be general enough to handle
   future uses of the interface.
 - The code to generate ompi_info output has been moved into the MCA variable
   system. See mca_base_var_dump().

opal: update core and components to mca_base_var system
orte: update core and components to mca_base_var system
ompi: update core and components to mca_base_var system

This commit also modifies the rmaps framework. The following variables were
moved from ppr and lama: rmaps_base_pernode, rmaps_base_n_pernode,
rmaps_base_n_persocket. Both lama and ppr create synonyms for these variables.

This commit was SVN r28236.
2013-03-27 21:09:41 +00:00

228 строки
5.4 KiB
C

/*
* Copyright (c) 2009-2012 Oak Ridge National Laboratory. All rights reserved.
* Copyright (c) 2009-2012 Mellanox Technologies. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
*/
#include "ompi_config.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h>
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
#include <fcntl.h>
#include "ompi/constants.h"
#include "ompi/communicator/communicator.h"
#include "sbgp_basesmuma.h"
/*
* Public string showing the coll ompi_sm V2 component version number
*/
const char *mca_sbgp_basesmuma_component_version_string =
"Open MPI sbgp - basesmuma collective MCA component version " OMPI_VERSION;
/*
* Local functions
*/
static int basesmuma_register(void);
static int basesmuma_open(void);
static int basesmuma_close(void);
static mca_sbgp_base_module_t *mca_sbgp_basesmuma_select_procs(struct ompi_proc_t ** procs,
int n_procs_in, struct ompi_communicator_t *comm, char *key, void *output_data);
static int mca_sbgp_basesmuma_init_query(bool enable_progress_threads,
bool enable_mpi_threads);
/*
* Instantiate the public struct with all of our public information
* and pointers to our public functions in it
*/
mca_sbgp_basesmuma_component_t mca_sbgp_basesmuma_component = {
/* First, fill in the super */
{
/* First, the mca_component_t struct containing meta
information about the component itself */
{
MCA_SBGP_BASE_VERSION_2_0_0,
/* Component name and version */
"basesmuma",
OMPI_MAJOR_VERSION,
OMPI_MINOR_VERSION,
OMPI_RELEASE_VERSION,
/* Component open, close, and register functions */
basesmuma_open,
basesmuma_close,
NULL,
basesmuma_register
},
mca_sbgp_basesmuma_init_query,
mca_sbgp_basesmuma_select_procs,
/* (default) priority */
0
}
};
/*
* Register the component
*/
static int basesmuma_register(void)
{
mca_sbgp_basesmuma_component_t *cs = &mca_sbgp_basesmuma_component;
/* set component priority */
cs->super.priority = 90;
(void) mca_base_component_var_register(&cs->super.sbgp_version,
"priority", "Priority of the sbgp basesmuma",
MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&cs->super.priority);
return OMPI_SUCCESS;
}
/*
* Open the component
*/
static int basesmuma_open(void)
{
return OMPI_SUCCESS;
}
/*
* Close the component
*/
static int basesmuma_close(void)
{
return OMPI_SUCCESS;
}
/* query to see if the component is available for use, and can
* satisfy the thread and progress requirements
*/
int mca_sbgp_basesmuma_init_query(bool enable_progress_threads,
bool enable_mpi_threads)
{
/* at this stage there is no reason to disaulify this component */
/* done */
return OMPI_SUCCESS;
}
/* This routine is used to find the list of procs that run on the
** same host as the calling process.
*/
static mca_sbgp_base_module_t *mca_sbgp_basesmuma_select_procs(struct ompi_proc_t ** procs,
int n_procs_in,
struct ompi_communicator_t *comm,
char *key,
void *output_data
)
{
/* local variables */
int cnt,proc,local;
mca_sbgp_basesmuma_module_t *module;
module=OBJ_NEW(mca_sbgp_basesmuma_module_t);
if (!module ) {
return NULL;
}
module->super.group_size=0;
module->super.group_comm = comm;
module->super.group_list = NULL;
module->super.group_net = OMPI_SBGP_MUMA;
cnt=0;
for( proc=0 ; proc < n_procs_in ; proc++) {
/* debug
if( odd ) {
if( !(1&proc) )
continue;
} else {
if( (1&proc) )
continue;
}
end debug */
local=OPAL_PROC_ON_LOCAL_NODE(procs[proc]->proc_flags);
if( local ) {
cnt++;
}
}
/* if no other local procs found skip to end */
if( 2 > cnt ) {
/* There's always at least one - namely myself */
assert( 1 == cnt);
module->super.group_size=1;
/* let ml handle this case */
goto OneLocalPeer;
}
/* generate list of local ranks */
module->super.group_size=cnt;
if( cnt > 0 ) {
module->super.group_list=(int *)malloc(sizeof(int)*cnt);
if(NULL == module->super.group_list){
goto Error;
}
}
cnt=0;
for( proc=0 ; proc < n_procs_in ; proc++) {
/* debug
if( odd ) {
if( !(1&proc) )
continue;
} else {
if( (1&proc) )
continue;
}
end debug */
local=OPAL_PROC_ON_LOCAL_NODE(procs[proc]->proc_flags);
if( local ) {
module->super.group_list[cnt]=proc;
cnt++;
}
}
OneLocalPeer:
/* successful completion */
return (mca_sbgp_base_module_t *)module;
/* return with error */
Error:
/* clean up */
if( NULL != module->super.group_list ) {
free(module->super.group_list);
module->super.group_list=NULL;
}
OBJ_RELEASE(module);
return NULL;
}