1
1

Cleanup PMI startup - if a component isn't selected, it should finalize PMI IFF it started it. Otherwise, components that aren't selected can finalize PMI when it is in use by other parts of the system.

This commit was SVN r25407.
Этот коммит содержится в:
Ralph Castain 2011-11-01 16:25:12 +00:00
родитель 3edd77ea25
Коммит 14966e0f8f
4 изменённых файлов: 28 добавлений и 38 удалений

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

@ -26,7 +26,8 @@ static int pubsub_pmi_component_open(void);
static int pubsub_pmi_component_close(void);
static int pubsub_pmi_component_query(mca_base_module_t **module, int *priority);
static int my_priority = 5; /* must be below "orte" component */
static int my_priority = 100; /* must be above "orte" component */
static bool started_by_me=false;
ompi_pubsub_base_component_t mca_pubsub_pmi_component = {
{
@ -61,14 +62,14 @@ static int pubsub_pmi_component_open(void)
static int pubsub_pmi_component_close(void)
{
#if WANT_CRAY_PMI2_EXT
if (PMI2_Initialized()) {
if (started_by_me && PMI2_Initialized()) {
PMI2_Finalize();
}
#else
PMI_BOOL initialized;
/* if we weren't selected, cleanup */
if (PMI_SUCCESS == PMI_Initialized(&initialized) &&
if (started_by_me && PMI_SUCCESS == PMI_Initialized(&initialized) &&
PMI_TRUE == initialized) {
PMI_Finalize();
}
@ -89,6 +90,8 @@ static bool pmi_startup(void)
if (PMI_SUCCESS != PMI2_Init(&spawned, &size, &rank, &appnum)) {
return false;
}
/* flag that we started PMI */
started_by_me = true;
/* ignore the info - we'll pick it up elsewhere */
return true;
#else
@ -101,6 +104,8 @@ static bool pmi_startup(void)
if (PMI_SUCCESS != PMI_Init(&initialized)) {
return false;
}
/* flag that we started PMI */
started_by_me = true;
}
return true;

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

@ -34,6 +34,8 @@ static int pmi_component_open(void);
static int pmi_component_close(void);
static int pmi_component_query(mca_base_module_t **module, int *priority);
static bool started_by_me=false;
/*
* Instantiate the public struct with all of our public information
* and pointers to our public functions in it
@ -78,6 +80,8 @@ static bool pmi_startup(void)
if (PMI_SUCCESS != PMI2_Init(&spawned, &size, &rank, &appnum)) {
return false;
}
/* flag that we started PMI */
started_by_me = true;
/* ignore the info - we'll pick it up elsewhere */
return true;
#else
@ -90,6 +94,8 @@ static bool pmi_startup(void)
if (PMI_SUCCESS != PMI_Init(&initialized)) {
return false;
}
/* flag that we started PMI */
started_by_me = true;
}
return true;
#endif
@ -117,14 +123,14 @@ static int pmi_component_query(mca_base_module_t **module, int *priority)
static int pmi_component_close(void)
{
#if WANT_CRAY_PMI2_EXT
if (PMI2_Initialized()) {
if (started_by_me && PMI2_Initialized()) {
PMI2_Finalize();
}
#else
PMI_BOOL initialized;
/* if we weren't selected, cleanup */
if (PMI_SUCCESS == PMI_Initialized(&initialized) &&
if (started_by_me && PMI_SUCCESS == PMI_Initialized(&initialized) &&
PMI_TRUE == initialized) {
PMI_Finalize();
}

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

@ -26,6 +26,7 @@
#include "grpcomm_pmi.h"
static int my_priority=5; /* must be below "bad" module */
static bool started_by_me=false;
/*
* Struct of function pointers that need to be initialized
@ -68,14 +69,14 @@ int orte_grpcomm_pmi_open(void)
int orte_grpcomm_pmi_close(void)
{
#if WANT_CRAY_PMI2_EXT
if (PMI2_Initialized()) {
if (started_by_me && PMI2_Initialized()) {
PMI2_Finalize();
}
#else
PMI_BOOL initialized;
/* if we weren't selected, cleanup */
if (PMI_SUCCESS == PMI_Initialized(&initialized) &&
if (started_by_me && PMI_SUCCESS == PMI_Initialized(&initialized) &&
PMI_TRUE == initialized) {
PMI_Finalize();
}
@ -97,6 +98,8 @@ static bool pmi_startup(void)
if (PMI_SUCCESS != PMI2_Init(&spawned, &size, &rank, &appnum)) {
return false;
}
/* flag that we started PMI */
started_by_me = true;
/* ignore the info - we'll pick it up elsewhere */
return true;
#else
@ -109,6 +112,8 @@ static bool pmi_startup(void)
if (PMI_SUCCESS != PMI_Init(&initialized)) {
return false;
}
/* flag that we started PMI */
started_by_me = true;
}
return true;
#endif
@ -116,10 +121,9 @@ static bool pmi_startup(void)
int orte_grpcomm_pmi_component_query(mca_base_module_t **module, int *priority)
{
/* for now, only use PMI when direct launched */
if (ORTE_PROC_IS_MPI &&
pmi_startup()) {
/* if PMI is available, use it */
/* if PMI is available, make it available for use by MPI procs */
*priority = my_priority;
*module = (mca_base_module_t *)&orte_grpcomm_pmi_module;
return ORTE_SUCCESS;

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

@ -124,11 +124,9 @@ static int init(void)
{
int rc;
if (NULL == pmi_kvs_name) {
if (ORTE_SUCCESS != (rc = setup_pmi())) {
ORTE_ERROR_LOG(rc);
return rc;
}
if (ORTE_SUCCESS != (rc = setup_pmi())) {
ORTE_ERROR_LOG(rc);
return rc;
}
return ORTE_SUCCESS;
}
@ -224,13 +222,6 @@ static int pmi_set_proc_attr(const char* attr_name,
{
int rc;
if (NULL == pmi_kvs_name) {
if (ORTE_SUCCESS != (rc = setup_pmi())) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
if (ORTE_SUCCESS != (rc = setup_key(ORTE_PROC_MY_NAME, attr_name))) {
ORTE_ERROR_LOG(rc);
return rc;
@ -265,13 +256,6 @@ static int pmi_get_proc_attr(const orte_process_name_t name,
*size = 0;
*buffer = NULL;
if (NULL == pmi_kvs_name) {
if (ORTE_SUCCESS != (rc = setup_pmi())) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
OPAL_OUTPUT_VERBOSE((1, orte_grpcomm_base.output,
"%s grpcomm:pmi: get attr %s for proc %s in KVS %s",
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), attr_name,
@ -316,13 +300,6 @@ static int modex(opal_list_t *procs)
"%s grpcomm:pmi: modex entered",
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)));
if (NULL == pmi_kvs_name) {
if (ORTE_SUCCESS != (rc = setup_pmi())) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
/* provide our hostname so others can know our location */
if (strlen(orte_process_info.nodename) > (size_t)pmi_vallen_max) {
ORTE_ERROR_LOG(ORTE_ERR_VALUE_OUT_OF_BOUNDS);
@ -614,8 +591,6 @@ static int modex(opal_list_t *procs)
#endif
}
/* cycle thru the array of our peers and assign local and node ranks */
OPAL_OUTPUT_VERBOSE((1, orte_grpcomm_base.output,
"%s grpcomm:pmi: modex completed",
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)));
@ -703,7 +678,7 @@ static int setup_pmi(void)
return ORTE_ERROR;
}
#endif
pmi_kvs_name = malloc(max_length);
pmi_kvs_name = (char*)malloc(max_length);
if (NULL == pmi_kvs_name) {
return ORTE_ERR_OUT_OF_RESOURCE;
}