1
1

mca/base: provide functions to determine if a framework is registered/open

This commit also fixes a problem with the lazy opening of topo
components. The topo framework incorrectly: 1) checked if the topo
framework was open by checking the length of the components list, and
2) called the framework open directly instead of using
mca_base_framework_open.

fixes #544

Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Этот коммит содержится в:
Nathan Hjelm 2015-04-21 13:49:51 -06:00
родитель 5ea1f1c12b
Коммит 7c95ecf859
3 изменённых файлов: 32 добавлений и 10 удалений

Просмотреть файл

@ -35,12 +35,11 @@ int mca_topo_base_lazy_init(void)
{ {
int err; int err;
if (0 == opal_list_get_size(&ompi_topo_base_framework.framework_components)) { if (!mca_base_framework_is_open (&ompi_topo_base_framework)) {
ompi_topo_base_framework.framework_open(MCA_BASE_OPEN_FIND_COMPONENTS);
/** /**
* Register all available components, giving them a chance to access the MCA parameters. * Register and open all available components, giving them a chance to access the MCA parameters.
*/ */
mca_base_framework_register(&ompi_topo_base_framework, MCA_BASE_REGISTER_DEFAULT); mca_base_framework_open (&ompi_topo_base_framework, MCA_BASE_REGISTER_DEFAULT);
if (OMPI_SUCCESS != if (OMPI_SUCCESS !=
(err = mca_topo_base_find_available(OPAL_ENABLE_PROGRESS_THREADS, (err = mca_topo_base_find_available(OPAL_ENABLE_PROGRESS_THREADS,
OMPI_ENABLE_THREAD_MULTIPLE))) { OMPI_ENABLE_THREAD_MULTIPLE))) {

Просмотреть файл

@ -19,12 +19,12 @@
#include "mca_base_var.h" #include "mca_base_var.h"
#include "opal/mca/base/base.h" #include "opal/mca/base/base.h"
static bool framework_is_registered (struct mca_base_framework_t *framework) bool mca_base_framework_is_registered (struct mca_base_framework_t *framework)
{ {
return !!(framework->framework_flags & MCA_BASE_FRAMEWORK_FLAG_REGISTERED); return !!(framework->framework_flags & MCA_BASE_FRAMEWORK_FLAG_REGISTERED);
} }
static bool framework_is_open (struct mca_base_framework_t *framework) bool mca_base_framework_is_open (struct mca_base_framework_t *framework)
{ {
return !!(framework->framework_flags & MCA_BASE_FRAMEWORK_FLAG_OPEN); return !!(framework->framework_flags & MCA_BASE_FRAMEWORK_FLAG_OPEN);
} }
@ -61,7 +61,7 @@ int mca_base_framework_register (struct mca_base_framework_t *framework,
framework->framework_refcnt++; framework->framework_refcnt++;
if (framework_is_registered (framework)) { if (mca_base_framework_is_registered (framework)) {
return OPAL_SUCCESS; return OPAL_SUCCESS;
} }
@ -143,7 +143,7 @@ int mca_base_framework_open (struct mca_base_framework_t *framework,
} }
/* check if this framework is already open */ /* check if this framework is already open */
if (framework_is_open (framework)) { if (mca_base_framework_is_open (framework)) {
return OPAL_SUCCESS; return OPAL_SUCCESS;
} }
@ -180,8 +180,8 @@ int mca_base_framework_open (struct mca_base_framework_t *framework,
} }
int mca_base_framework_close (struct mca_base_framework_t *framework) { int mca_base_framework_close (struct mca_base_framework_t *framework) {
bool is_open = framework_is_open (framework); bool is_open = mca_base_framework_is_open (framework);
bool is_registered = framework_is_registered (framework); bool is_registered = mca_base_framework_is_registered (framework);
int ret, group_id; int ret, group_id;
assert (NULL != framework); assert (NULL != framework);

Просмотреть файл

@ -195,6 +195,29 @@ OPAL_DECLSPEC int mca_base_framework_open (mca_base_framework_t *framework,
*/ */
OPAL_DECLSPEC int mca_base_framework_close (mca_base_framework_t *framework); OPAL_DECLSPEC int mca_base_framework_close (mca_base_framework_t *framework);
/**
* Check if a framework is already registered
*
* @param[in] framework framework to query
*
* @retval true if the framework's mca variables are registered
* @retval false if not
*/
OPAL_DECLSPEC bool mca_base_framework_is_registered (struct mca_base_framework_t *framework);
/**
* Check if a framework is already open
*
* @param[in] framework framework to query
*
* @retval true if the framework is open
* @retval false if not
*/
OPAL_DECLSPEC bool mca_base_framework_is_open (struct mca_base_framework_t *framework);
/** /**
* Macro to declare an MCA framework * Macro to declare an MCA framework
* *