1
1
openmpi/orte/mca/grpcomm/pmi/grpcomm_pmi_component.c
Ralph Castain 3e72fccacf Cray's PMI implementation is quite different from slurm's - they extended PMI-1 by adding some, but not all, of the PMI-2 APIs. So you can't just switch to using PMI-2 functions as it isn't a complete implementation. Instead, you have to selectively figure out which ones they have in PMI-2, and use any missing ones from PMI-1. What fun.
Modify the configure logic and the PMI components to accommodate Cray's approach. Refactor the PMI error reporting code so it resides in only one place. Cray actually decided -not- to define the PMI-2 error codes, so we have to use the PMI-1 codes instead. More fun.

This commit was SVN r25348.
2011-10-21 04:54:38 +00:00

122 строки
2.7 KiB
C

/* -*- C -*-
*
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2011 Los Alamos National Security, LLC. All
* rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include "orte/constants.h"
#include <pmi.h>
#if WANT_CRAY_PMI2_EXT
#include <pmi2.h>
#endif
#include "opal/mca/mca.h"
#include "opal/mca/base/mca_base_param.h"
#include "orte/util/proc_info.h"
#include "grpcomm_pmi.h"
/*
* Struct of function pointers that need to be initialized
*/
orte_grpcomm_base_component_t mca_grpcomm_pmi_component = {
{
ORTE_GRPCOMM_BASE_VERSION_2_0_0,
"pmi", /* MCA module name */
ORTE_MAJOR_VERSION, /* MCA module major version */
ORTE_MINOR_VERSION, /* MCA module minor version */
ORTE_RELEASE_VERSION, /* MCA module release version */
orte_grpcomm_pmi_open, /* module open */
orte_grpcomm_pmi_close, /* module close */
orte_grpcomm_pmi_component_query /* module query */
},
{
/* The component is checkpoint ready */
MCA_BASE_METADATA_PARAM_CHECKPOINT
}
};
/* Open the component */
int orte_grpcomm_pmi_open(void)
{
return ORTE_SUCCESS;
}
int orte_grpcomm_pmi_close(void)
{
#if WANT_CRAY_PMI2_EXT
if (PMI2_Initialized()) {
PMI2_Finalize();
}
#else
PMI_BOOL initialized;
/* if we weren't selected, cleanup */
if (PMI_SUCCESS == PMI_Initialized(&initialized) &&
PMI_TRUE == initialized) {
PMI_Finalize();
}
#endif
return ORTE_SUCCESS;
}
static bool pmi_startup(void)
{
#if WANT_CRAY_PMI2_EXT
int spawned, size, rank, appnum;
if (PMI2_Initialized()) {
/* already initialized */
return true;
}
/* if we can't startup PMI, we can't be used */
if (PMI_SUCCESS != PMI2_Init(&spawned, &size, &rank, &appnum)) {
return false;
}
/* ignore the info - we'll pick it up elsewhere */
return true;
#else
PMI_BOOL initialized;
if (PMI_SUCCESS != PMI_Init(&initialized)) {
return false;
}
if (PMI_TRUE != initialized) {
if (PMI_SUCCESS != PMI_Init(&initialized)) {
return false;
}
}
return true;
#endif
}
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_HNP &&
NULL == orte_process_info.my_hnp_uri &&
pmi_startup()) {
/* if PMI is available, use it */
*priority = 100;
*module = (mca_base_module_t *)&orte_grpcomm_pmi_module;
return ORTE_SUCCESS;
}
/* we can't run */
*priority = -1;
*module = NULL;
return ORTE_ERROR;
}