Move the mca_base_is_component_required() functionality to mca/base per suggestion so that it can be reused in other components.
This commit was SVN r22327.
Этот коммит содержится в:
родитель
e8b4507c51
Коммит
313acba4ce
@ -107,6 +107,19 @@ OPAL_DECLSPEC int mca_base_select(const char *type_name, int output_id,
|
|||||||
mca_base_module_t **best_module,
|
mca_base_module_t **best_module,
|
||||||
mca_base_component_t **best_component);
|
mca_base_component_t **best_component);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A function for component query functions to discover if they have
|
||||||
|
* been explicitly required to or requested to be selected.
|
||||||
|
*
|
||||||
|
* exclusive: If the specified component is the only component that is
|
||||||
|
* available for selection.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
OPAL_DECLSPEC int mca_base_is_component_required(opal_list_t *components_available,
|
||||||
|
mca_base_component_t *component,
|
||||||
|
bool exclusive,
|
||||||
|
bool *is_required);
|
||||||
|
|
||||||
/* mca_base_cmd_line.c */
|
/* mca_base_cmd_line.c */
|
||||||
|
|
||||||
OPAL_DECLSPEC int mca_base_cmd_line_setup(opal_cmd_line_t *cmd);
|
OPAL_DECLSPEC int mca_base_cmd_line_setup(opal_cmd_line_t *cmd);
|
||||||
|
@ -229,6 +229,61 @@ int mca_base_components_open(const char *type_name, int output_id,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mca_base_is_component_required(opal_list_t *components_available,
|
||||||
|
mca_base_component_t *component,
|
||||||
|
bool exclusive,
|
||||||
|
bool *is_required)
|
||||||
|
{
|
||||||
|
opal_list_item_t *item = NULL;
|
||||||
|
mca_base_component_list_item_t *cli = NULL;
|
||||||
|
mca_base_component_t *comp = NULL;
|
||||||
|
|
||||||
|
/* Sanity check */
|
||||||
|
if( NULL == components_available ||
|
||||||
|
NULL == component) {
|
||||||
|
return OPAL_ERR_BAD_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
|
*is_required = false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Look through the components available for opening
|
||||||
|
*/
|
||||||
|
if( exclusive ) {
|
||||||
|
/* Must be the -only- component in the list */
|
||||||
|
if( 1 == opal_list_get_size(components_available) ) {
|
||||||
|
item = opal_list_get_first(components_available);
|
||||||
|
cli = (mca_base_component_list_item_t *) item;
|
||||||
|
comp = (mca_base_component_t *) cli->cli_component;
|
||||||
|
|
||||||
|
if( 0 == strncmp(comp->mca_component_name,
|
||||||
|
component->mca_component_name,
|
||||||
|
strlen(component->mca_component_name)) ) {
|
||||||
|
*is_required = true;
|
||||||
|
return OPAL_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* Must be one of the components in the list */
|
||||||
|
for (item = opal_list_get_first(components_available);
|
||||||
|
item != opal_list_get_end(components_available);
|
||||||
|
item = opal_list_get_next(item) ) {
|
||||||
|
cli = (mca_base_component_list_item_t *) item;
|
||||||
|
comp = (mca_base_component_t *) cli->cli_component;
|
||||||
|
|
||||||
|
if( 0 == strncmp(comp->mca_component_name,
|
||||||
|
component->mca_component_name,
|
||||||
|
strlen(component->mca_component_name)) ) {
|
||||||
|
*is_required = true;
|
||||||
|
return OPAL_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return OPAL_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int parse_requested(int mca_param, bool *include_mode,
|
static int parse_requested(int mca_param, bool *include_mode,
|
||||||
char ***requested_component_names)
|
char ***requested_component_names)
|
||||||
|
@ -44,15 +44,16 @@ orte_routed_component_t mca_routed_cm_component = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int is_component_requested(bool *is_req);
|
|
||||||
|
|
||||||
static int orte_routed_cm_component_query(mca_base_module_t **module, int *priority)
|
static int orte_routed_cm_component_query(mca_base_module_t **module, int *priority)
|
||||||
{
|
{
|
||||||
bool is_requested = false;
|
bool is_required = false;
|
||||||
|
|
||||||
is_component_requested(&is_requested);
|
mca_base_is_component_required(&orte_routed_base_components,
|
||||||
|
&mca_routed_cm_component.base_version,
|
||||||
|
true,
|
||||||
|
&is_required);
|
||||||
|
|
||||||
if( !is_requested ) {
|
if( !is_required ) {
|
||||||
*priority = 0;
|
*priority = 0;
|
||||||
*module = NULL;
|
*module = NULL;
|
||||||
return ORTE_ERROR;
|
return ORTE_ERROR;
|
||||||
@ -62,42 +63,3 @@ static int orte_routed_cm_component_query(mca_base_module_t **module, int *prior
|
|||||||
*module = (mca_base_module_t *)&orte_routed_cm_module;
|
*module = (mca_base_module_t *)&orte_routed_cm_module;
|
||||||
return ORTE_SUCCESS;
|
return ORTE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int is_component_requested(bool *is_req)
|
|
||||||
{
|
|
||||||
char *spec = NULL;
|
|
||||||
opal_list_item_t *item = NULL;
|
|
||||||
mca_base_component_list_item_t *cli = NULL;
|
|
||||||
mca_base_component_t *component = NULL;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check the environment variable
|
|
||||||
*/
|
|
||||||
*is_req = false;
|
|
||||||
spec = getenv("OMPI_MCA_routed");
|
|
||||||
if (NULL != spec && 0 == strcmp("cm", spec)) {
|
|
||||||
*is_req = true;
|
|
||||||
return ORTE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Otherwise look through the components available for opening
|
|
||||||
* Must be the -only- component in the list
|
|
||||||
*/
|
|
||||||
*is_req = false;
|
|
||||||
if( 1 == opal_list_get_size(&orte_routed_base_components) ) {
|
|
||||||
item = opal_list_get_first(&orte_routed_base_components);
|
|
||||||
|
|
||||||
cli = (mca_base_component_list_item_t *) item;
|
|
||||||
component = (mca_base_component_t *) cli->cli_component;
|
|
||||||
|
|
||||||
if( 0 == strncmp(component->mca_component_name,
|
|
||||||
mca_routed_cm_component.base_version.mca_component_name,
|
|
||||||
strlen(mca_routed_cm_component.base_version.mca_component_name)) ) {
|
|
||||||
*is_req = true;
|
|
||||||
return ORTE_SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ORTE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user