Skip to content

Commit

Permalink
mca/base: Add MCA_BASE_COMPONENT_FLAG_ALLWAYS_CONSIDER flag
Browse files Browse the repository at this point in the history
For a static component, if this flag is set then the user cannot
exclude this component from being loaded by the MCA. If the user
tries to exclude this component then the program will abort with
an error message.

Signed-off-by: Joshua Hursey <[email protected]>
  • Loading branch information
jjhursey committed Jan 20, 2017
1 parent 7acd6d7 commit c2b6cb4
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 7 deletions.
3 changes: 3 additions & 0 deletions ompi/mca/hook/demo/hook_demo_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ const ompi_hook_base_component_2_0_0_t mca_hook_demo_component = {
.mca_open_component = ompi_hook_demo_component_open,
.mca_close_component = ompi_hook_demo_component_close,
.mca_register_component_params = ompi_hook_demo_component_register,

// Force this component to always be considered - component must be static
//.mca_component_flags = MCA_BASE_COMPONENT_FLAG_ALWAYS_CONSIDER,
},
.hookm_data = {
/* The component is checkpoint ready */
Expand Down
8 changes: 8 additions & 0 deletions opal/mca/base/help-mca-base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2008-2014 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2016 IBM Corporation. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
Expand Down Expand Up @@ -59,3 +60,10 @@ all components *except* a and b", while "c,d" specifies the inclusive
behavior and means "use *only* components c and d."

You cannot mix inclusive and exclusive behavior.
[framework-param:exclude-always-component]
Error: A request was made to exclude a component from consideration that
must always be considered. This component (noted below) can -not- be excluded
from consideration. The program will fail at this time.

Framework: %s
Component: %s
36 changes: 32 additions & 4 deletions opal/mca/base/mca_base_component_find.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2014-2015 Los Alamos National Security, LLC. All rights
* Copyright (c) 2014-2016 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2016 IBM Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -115,9 +116,24 @@ int mca_base_component_find (const char *directory, mca_base_framework_t *framew
/* Find all the components that were statically linked in */
if (static_components) {
for (int i = 0 ; NULL != static_components[i]; ++i) {
if ( use_component(include_mode,
(const char**)requested_component_names,
static_components[i]->mca_component_name) ) {
bool can_use;

can_use = use_component(include_mode, (const char **) requested_component_names,
static_components[i]->mca_component_name);

// Make sure the user is not trying to unload a component that must
// always be considered.
if (!can_use && static_components[i]->mca_component_flags & MCA_BASE_COMPONENT_FLAG_ALWAYS_CONSIDER) {
if (!include_mode) {
opal_show_help ("help-mca-base.txt", "framework-param:exclude-always-component", true,
framework->framework_name, static_components[i]->mca_component_name);
return OPAL_ERR_NOT_SUPPORTED;
}

can_use = true;
}

if (can_use) {
cli = OBJ_NEW(mca_base_component_list_item_t);
if (NULL == cli) {
ret = OPAL_ERR_OUT_OF_RESOURCE;
Expand Down Expand Up @@ -192,6 +208,18 @@ int mca_base_components_filter (mca_base_framework_t *framework, uint32_t filter
can_use = use_component (include_mode, (const char **) requested_component_names,
cli->cli_component->mca_component_name);

// Make sure the user is not trying to unload a component that must
// always be considered.
if (!can_use && cli->cli_component->mca_component_flags & MCA_BASE_COMPONENT_FLAG_ALWAYS_CONSIDER) {
if (!include_mode) {
opal_show_help ("help-mca-base.txt", "framework-param:exclude-always-component", true,
framework->framework_name, cli->cli_component->mca_component_name);
return OPAL_ERR_NOT_SUPPORTED;
}

can_use = true;
}

if (!can_use || (filter_flags & dummy->data.param_field) != filter_flags) {
if (can_use && (filter_flags & MCA_BASE_METADATA_PARAM_CHECKPOINT) &&
!(MCA_BASE_METADATA_PARAM_CHECKPOINT & dummy->data.param_field)) {
Expand Down
20 changes: 17 additions & 3 deletions opal/mca/mca.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008-2012 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* Copyright (c) 2015-2016 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2016 IBM Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -256,6 +257,15 @@ typedef int (*mca_base_register_component_params_2_0_0_fn_t)(void);
*/
#define MCA_BASE_MAX_COMPONENT_NAME_LEN 63

/**
* Component flags (mca_component_flags field)
*/
enum {
/** Always consider this component for selection. For this flag to
* work properly the component must always be built statically. */
MCA_BASE_COMPONENT_FLAG_ALWAYS_CONSIDER = 1,
};

/**
* Common type for all MCA components.
*
Expand Down Expand Up @@ -315,9 +325,13 @@ struct mca_base_component_2_1_0_t {
mca_base_register_component_params_2_0_0_fn_t mca_register_component_params;
/**< Method for registering the component's MCA parameters */

int32_t mca_component_flags;
/**< flags for this component */

/** Extra space to allow for expansion in the future without
breaking older components. */
char reserved[32];
breaking older components.
NTH/JJH: reduced by 4 bytes for mca_component_flags */
char reserved[28];
};
/** Unversioned convenience typedef; use this name in
frameworks/components to stay forward source-compatible */
Expand Down

0 comments on commit c2b6cb4

Please sign in to comment.