1
1
openmpi/opal/mca/if/base/if_base_components.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

146 строки
4.4 KiB
C

/*
* Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
*/
#include "opal_config.h"
#include "opal/constants.h"
#include "opal/util/output.h"
#include "opal/mca/mca.h"
#include "opal/mca/if/if.h"
#include "opal/mca/if/base/base.h"
#include "opal/mca/if/base/static-components.h"
int opal_if_base_output=-1;
opal_list_t opal_if_components;
static bool already_done = false;
/* instantiate the global list of interfaces */
opal_list_t opal_if_list;
bool opal_if_do_not_resolve;
bool opal_if_retain_loopback;
static int opal_if_base_verbose = -1;
/* instance the opal_if_t object */
OBJ_CLASS_INSTANCE(opal_if_t, opal_list_item_t, NULL, NULL);
static int opal_if_base_register(int flags)
{
int var_id;
opal_if_base_verbose = -1;
(void) mca_base_var_register("opal", "if", "base", "verbose",
"Provide verbose output if greater than 0",
MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&opal_if_base_verbose);
opal_if_do_not_resolve = false;
var_id = mca_base_var_register("opal", "if", "base", "do_not_resolve",
"If nonzero, do not attempt to resolve interfaces",
MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&opal_if_do_not_resolve);
(void) mca_base_var_register_synonym(var_id, "opal", "if", NULL, "do_not_resolve", 0);
opal_if_retain_loopback = false;
var_id = mca_base_var_register("opal", "if", "base", "retain_loopback",
"If nonzero, retain loopback interfaces",
MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&opal_if_retain_loopback);
(void) mca_base_var_register_synonym(var_id, "opal", "if", NULL, "retain_loopback", 0);
return OPAL_SUCCESS;
}
int opal_if_base_open(void)
{
int i, ret;
mca_base_component_list_item_t *cli;
if (already_done) {
return OPAL_SUCCESS;
}
already_done = true;
(void) opal_if_base_register(0);
/* setup the global list */
OBJ_CONSTRUCT(&opal_if_list, opal_list_t);
if (0 < opal_if_base_verbose) {
opal_if_base_output = opal_output_open(NULL);
opal_output_set_verbosity(opal_if_base_output, opal_if_base_verbose);
}
OBJ_CONSTRUCT(&opal_if_components, opal_list_t);
for (i = 0 ; mca_if_base_static_components[i] != NULL ; ++i) {
opal_if_base_component_t *component =
(opal_if_base_component_t*)
mca_if_base_static_components[i];
/* Save it in a global list for ompi_info */
cli = OBJ_NEW(mca_base_component_list_item_t);
cli->cli_component = mca_if_base_static_components[i];
opal_list_append(&opal_if_components, &cli->super);
opal_output_verbose(5, opal_if_base_output,
"if:base: opening component %s",
component->component.mca_component_name);
if (NULL != component->component.mca_open_component) {
ret = component->component.mca_open_component();
if (OPAL_SUCCESS != ret) continue;
}
if (NULL != mca_if_base_static_components[i]->mca_close_component) {
mca_if_base_static_components[i]->mca_close_component();
}
}
return OPAL_SUCCESS;
}
int opal_if_base_close(void)
{
opal_list_item_t *item;
if (!already_done) {
return OPAL_SUCCESS;
}
already_done = false;
for (item = opal_list_remove_first(&opal_if_list);
NULL != item;
item = opal_list_remove_first(&opal_if_list)) {
OBJ_RELEASE(item);
}
OBJ_DESTRUCT(&opal_if_list);
for (item = opal_list_remove_first(&opal_if_components);
NULL != item;
item = opal_list_remove_first(&opal_if_components)) {
OBJ_RELEASE(item);
}
OBJ_DESTRUCT(&opal_if_components);
/* Close the framework output */
opal_output_close (opal_if_base_output);
opal_if_base_output = -1;
return OPAL_SUCCESS;
}