From 6294ed991bdc43e7648c09b25c489cb9553b0774 Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Tue, 2 Dec 2014 14:12:24 -0800 Subject: [PATCH] Fix singletons - still working on singleton comm_spawn --- orte/mca/ess/pmi/ess_pmi_component.c | 28 +++++++++++++++++ orte/mca/ess/pmi/ess_pmi_module.c | 12 -------- .../ess/singleton/ess_singleton_component.c | 30 +++++++++++++++++++ orte/mca/ess/singleton/ess_singleton_module.c | 6 ++++ 4 files changed, 64 insertions(+), 12 deletions(-) diff --git a/orte/mca/ess/pmi/ess_pmi_component.c b/orte/mca/ess/pmi/ess_pmi_component.c index 5b229e4432..b4838b1e7b 100644 --- a/orte/mca/ess/pmi/ess_pmi_component.c +++ b/orte/mca/ess/pmi/ess_pmi_component.c @@ -24,6 +24,7 @@ #include "opal/mca/pmix/base/base.h" #include "orte/util/proc_info.h" +#include "orte/mca/errmgr/errmgr.h" #include "orte/mca/ess/ess.h" #include "orte/mca/ess/pmi/ess_pmi.h" @@ -66,8 +67,35 @@ static int pmi_component_open(void) static int pmi_component_query(mca_base_module_t **module, int *priority) { + int ret; + /* all APPS must use pmix */ if (ORTE_PROC_IS_APP) { + /* open and setup pmix */ + if (NULL == opal_pmix.initialized) { + if (OPAL_SUCCESS != (ret = mca_base_framework_open(&opal_pmix_base_framework, 0))) { + ORTE_ERROR_LOG(ret); + *priority = -1; + *module = NULL; + return ret; + } + if (OPAL_SUCCESS != (ret = opal_pmix_base_select())) { + ORTE_ERROR_LOG(ret); + *priority = -1; + *module = NULL; + (void) mca_base_framework_close(&opal_pmix_base_framework); + return ret; + } + } + if (!opal_pmix.initialized()) { + /* we may have everything setup, but we are not + * in a PMI environment and so we need to disqualify + * ourselves - we are likely a singleton and will + * pick things up from there */ + *priority = -1; + *module = NULL; + return ORTE_ERROR; + } *priority = 35; *module = (mca_base_module_t *)&orte_ess_pmi_module; return ORTE_SUCCESS; diff --git a/orte/mca/ess/pmi/ess_pmi_module.c b/orte/mca/ess/pmi/ess_pmi_module.c index 81a9258629..04e2006607 100644 --- a/orte/mca/ess/pmi/ess_pmi_module.c +++ b/orte/mca/ess/pmi/ess_pmi_module.c @@ -106,18 +106,6 @@ static int rte_init(void) } #endif - /* open and setup pmix */ - if (OPAL_SUCCESS != (ret = mca_base_framework_open(&opal_pmix_base_framework, 0))) { - ORTE_ERROR_LOG(ret); - error = "opal_pmix_base_open"; - goto error; - } - if (OPAL_SUCCESS != (ret = opal_pmix_base_select())) { - ORTE_ERROR_LOG(ret); - error = "opal_pmix_base_select"; - goto error; - } - /* we don't have to call pmix.init because the pmix select did it */ /**** THE FOLLOWING ARE REQUIRED VALUES ***/ diff --git a/orte/mca/ess/singleton/ess_singleton_component.c b/orte/mca/ess/singleton/ess_singleton_component.c index 514ecf212f..9c76a564cd 100644 --- a/orte/mca/ess/singleton/ess_singleton_component.c +++ b/orte/mca/ess/singleton/ess_singleton_component.c @@ -25,7 +25,11 @@ #include "orte_config.h" #include "orte/constants.h" +#include "opal/mca/pmix/pmix.h" +#include "opal/mca/pmix/base/base.h" + #include "orte/util/proc_info.h" +#include "orte/mca/errmgr/errmgr.h" #include "orte/mca/ess/ess.h" #include "orte/mca/ess/singleton/ess_singleton.h" @@ -91,6 +95,8 @@ orte_ess_singleton_component_open(void) int orte_ess_singleton_component_query(mca_base_module_t **module, int *priority) { + int ret; + /* if we are an HNP, daemon, or tool, then we * are definitely not a singleton! */ @@ -111,6 +117,30 @@ int orte_ess_singleton_component_query(mca_base_module_t **module, int *priority return ORTE_ERROR; } + /* open and setup pmix */ + if (NULL == opal_pmix.initialized) { + if (OPAL_SUCCESS != (ret = mca_base_framework_open(&opal_pmix_base_framework, 0))) { + ORTE_ERROR_LOG(ret); + *priority = -1; + *module = NULL; + return ret; + } + if (OPAL_SUCCESS != (ret = opal_pmix_base_select())) { + ORTE_ERROR_LOG(ret); + *priority = -1; + *module = NULL; + (void) mca_base_framework_close(&opal_pmix_base_framework); + return ret; + } + } + if (opal_pmix.initialized()) { + /* we are in a PMI environment and are therefore + * not a singleton */ + *priority = -1; + *module = NULL; + return ORTE_ERROR; + } + /* okay, we could still be an application process, * but launched in "standalone" mode - i.e., directly * launched by an environment instead of via mpirun. diff --git a/orte/mca/ess/singleton/ess_singleton_module.c b/orte/mca/ess/singleton/ess_singleton_module.c index 0469fef569..247129d323 100644 --- a/orte/mca/ess/singleton/ess_singleton_module.c +++ b/orte/mca/ess/singleton/ess_singleton_module.c @@ -262,6 +262,12 @@ static int rte_finalize(void) { int ret; + /* mark us as finalized */ + if (NULL != opal_pmix.finalize) { + opal_pmix.finalize(); + (void) mca_base_framework_close(&opal_pmix_base_framework); + } + /* use the default procedure to finish */ if (ORTE_SUCCESS != (ret = orte_ess_base_app_finalize())) { ORTE_ERROR_LOG(ret);