move pmi init/finalize into a common component
This commit was SVN r26470.
Этот коммит содержится в:
родитель
78b8b3cf76
Коммит
cdc3c87ba6
@ -1,7 +1,8 @@
|
||||
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2011 Los Alamos National Security, LLC.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2011-2012 Los Alamos National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -19,6 +20,7 @@
|
||||
|
||||
#include "orte/util/proc_info.h"
|
||||
#include "orte/util/name_fns.h"
|
||||
#include "orte/mca/common/pmi/common_pmi.h"
|
||||
|
||||
#include "pubsub_pmi.h"
|
||||
|
||||
@ -27,7 +29,6 @@ static int pubsub_pmi_component_close(void);
|
||||
static int pubsub_pmi_component_query(mca_base_module_t **module, int *priority);
|
||||
|
||||
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,63 +62,17 @@ static int pubsub_pmi_component_open(void)
|
||||
|
||||
static int pubsub_pmi_component_close(void)
|
||||
{
|
||||
#if WANT_CRAY_PMI2_EXT
|
||||
if (started_by_me && PMI2_Initialized()) {
|
||||
PMI2_Finalize();
|
||||
}
|
||||
#else
|
||||
PMI_BOOL initialized;
|
||||
mca_common_pmi_finalize ();
|
||||
|
||||
/* if we weren't selected, cleanup */
|
||||
if (started_by_me && PMI_SUCCESS == PMI_Initialized(&initialized) &&
|
||||
PMI_TRUE == initialized) {
|
||||
PMI_Finalize();
|
||||
}
|
||||
#endif
|
||||
return OMPI_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;
|
||||
}
|
||||
/* flag that we started PMI */
|
||||
started_by_me = true;
|
||||
/* ignore the info - we'll pick it up elsewhere */
|
||||
return true;
|
||||
#else
|
||||
PMI_BOOL initialized;
|
||||
|
||||
if (PMI_SUCCESS != PMI_Initialized(&initialized)) {
|
||||
return false;
|
||||
}
|
||||
if (PMI_TRUE != initialized) {
|
||||
if (PMI_SUCCESS != PMI_Init(&initialized)) {
|
||||
return false;
|
||||
}
|
||||
/* flag that we started PMI */
|
||||
started_by_me = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int pubsub_pmi_component_query(mca_base_module_t **module, int *priority)
|
||||
{
|
||||
/* for now, only use PMI when direct launched */
|
||||
if (NULL == orte_process_info.my_hnp_uri &&
|
||||
ORTE_PROC_IS_MPI &&
|
||||
pmi_startup()) {
|
||||
mca_common_pmi_init ()) {
|
||||
/* if PMI is available, use it */
|
||||
*priority = my_priority;
|
||||
*module = (mca_base_module_t *)&ompi_pubsub_pmi_module;
|
||||
|
25
orte/mca/common/Makefile.am
Обычный файл
25
orte/mca/common/Makefile.am
Обычный файл
@ -0,0 +1,25 @@
|
||||
#
|
||||
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
||||
# University Research and Technology
|
||||
# Corporation. All rights reserved.
|
||||
# Copyright (c) 2004-2005 The University of Tennessee and The University
|
||||
# of Tennessee Research Foundation. All rights
|
||||
# reserved.
|
||||
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
||||
# University of Stuttgart. All rights reserved.
|
||||
# Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
# All rights reserved.
|
||||
# Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
|
||||
# $COPYRIGHT$
|
||||
#
|
||||
# Additional copyrights may follow
|
||||
#
|
||||
# $HEADER$
|
||||
#
|
||||
|
||||
# Note that this file must exist, even though it is empty (there is no
|
||||
# "base" directory for the common framework). autogen.pl and
|
||||
# ompi_mca.m4 assume that every framework has a top-level Makefile.am.
|
||||
# We *could* adjust the framework glue code to exclude "common" from
|
||||
# this requirement, but it's just a lot easier to have an empty
|
||||
# Makefile.am here.
|
35
orte/mca/common/pmi/Makefile.am
Обычный файл
35
orte/mca/common/pmi/Makefile.am
Обычный файл
@ -0,0 +1,35 @@
|
||||
#
|
||||
# Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
|
||||
# $COPYRIGHT$
|
||||
#
|
||||
# Additional copyrights may follow
|
||||
#
|
||||
# $HEADER$
|
||||
#
|
||||
|
||||
AM_CPPFLAGS = $(common_pmi_CPPFLAGS)
|
||||
|
||||
sources = common_pmi.h common_pmi.c
|
||||
|
||||
# Make the output library in this directory, and name it either
|
||||
# mca_<type>_<name>.la (for DSO builds) or libmca_<type>_<name>.la
|
||||
# (for static builds).
|
||||
|
||||
if MCA_BUILD_orte_common_pmi_DSO
|
||||
component_noinst =
|
||||
component_install = mca_common_pmi.la
|
||||
else
|
||||
component_noinst = libmca_common_pmi.la
|
||||
component_install =
|
||||
endif
|
||||
|
||||
mcacomponentdir = $(pkglibdir)
|
||||
mcacomponent_LTLIBRARIES = $(component_install)
|
||||
mca_common_pmi_la_SOURCES = $(sources)
|
||||
mca_common_pmi_la_LDFLAGS = -module -avoid-version $(common_pmi_LDFLAGS)
|
||||
mca_common_pmi_la_LIBADD = $(common_pmi_LIBS)
|
||||
|
||||
noinst_LTLIBRARIES = $(component_noinst)
|
||||
libmca_common_pmi_la_SOURCES =$(sources)
|
||||
libmca_common_pmi_la_LDFLAGS = -module -avoid-version $(common_pmi_LDFLAGS)
|
||||
libmca_common_pmi_la_LIBADD = $(common_pmi_LIBS)
|
75
orte/mca/common/pmi/common_pmi.c
Обычный файл
75
orte/mca/common/pmi/common_pmi.c
Обычный файл
@ -0,0 +1,75 @@
|
||||
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 The Trustees of Indiana University.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2011-2012 Los Alamos National Security, LLC. All
|
||||
* rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "orte_config.h"
|
||||
#include "orte/constants.h"
|
||||
#include "orte/types.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <pmi.h>
|
||||
#if WANT_CRAY_PMI2_EXT
|
||||
#include <pmi2.h>
|
||||
#endif
|
||||
|
||||
#include "common_pmi.h"
|
||||
|
||||
static int mca_common_pmi_init_count = 0;
|
||||
|
||||
bool mca_common_pmi_init (void) {
|
||||
if (0 < mca_common_pmi_init_count++) {
|
||||
return true;
|
||||
}
|
||||
|
||||
#if WANT_CRAY_PMI2_EXT
|
||||
int spawned, size, rank, appnum;
|
||||
|
||||
/* if we can't startup PMI, we can't be used */
|
||||
if (PMI2_Initialized ()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PMI_SUCCESS != PMI2_Init(&spawned, &size, &rank, &appnum)) {
|
||||
mca_common_pmi_init_count--;
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
PMI_BOOL initialized;
|
||||
|
||||
if (PMI_SUCCESS != PMI_Initialized(&initialized)) {
|
||||
mca_common_pmi_init_count--;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (PMI_TRUE != initialized && PMI_SUCCESS != PMI_Init(&initialized)) {
|
||||
mca_common_pmi_init_count--;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void mca_common_pmi_finalize (void) {
|
||||
if (0 == mca_common_pmi_init_count) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (0 == --mca_common_pmi_init_count) {
|
||||
#if WANT_CRAY_PMI2_EXT
|
||||
PMI2_Finalize ();
|
||||
#else
|
||||
PMI_Finalize ();
|
||||
#endif
|
||||
}
|
||||
}
|
36
orte/mca/common/pmi/common_pmi.h
Обычный файл
36
orte/mca/common/pmi/common_pmi.h
Обычный файл
@ -0,0 +1,36 @@
|
||||
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 The Trustees of Indiana University.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2011-2012 Los Alamos National Security, LLC. All
|
||||
* rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#if !defined(ORTE_MCA_COMMON_PMI)
|
||||
#define ORTE_MCA_COMMON_PMI
|
||||
|
||||
/**
|
||||
* mca_common_pmi_init:
|
||||
*
|
||||
* Attempt to initialize PMI
|
||||
*
|
||||
* @retval true PMI successfully initialized
|
||||
* @retval false PMI could not be initialized
|
||||
*/
|
||||
bool mca_common_pmi_init (void);
|
||||
|
||||
/**
|
||||
* mca_common_pmi_finalize:
|
||||
*
|
||||
* Finalize PMI. PMI initialization is reference counted. The last
|
||||
* caller to mca_common_pmi_finalize will cause PMI to be finalized.
|
||||
*/
|
||||
void mca_common_pmi_finalize (void);
|
||||
|
||||
#endif
|
30
orte/mca/common/pmi/configure.m4
Обычный файл
30
orte/mca/common/pmi/configure.m4
Обычный файл
@ -0,0 +1,30 @@
|
||||
# -*- shell-script -*-
|
||||
#
|
||||
# Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
|
||||
# Copyright (c) 2011-2012 Los Alamos National Security, LLC.
|
||||
# All rights reserved.
|
||||
# $COPYRIGHT$
|
||||
#
|
||||
# Additional copyrights may follow
|
||||
#
|
||||
# $HEADER$
|
||||
#
|
||||
|
||||
# MCA_common_pmi_CONFIG([action-if-found], [action-if-not-found])
|
||||
# -----------------------------------------------------------
|
||||
AC_DEFUN([MCA_orte_common_pmi_CONFIG], [
|
||||
AC_CONFIG_FILES([orte/mca/common/pmi/Makefile])
|
||||
|
||||
ORTE_CHECK_PMI([common_pmi], [common_pmi_good=1], [common_pmi_good=0])
|
||||
|
||||
# Evaluate succeed / fail
|
||||
AS_IF([test "$common_pmi_good" = 1 -a "$orte_without_full_support" = 0],
|
||||
[$1],
|
||||
[$2])
|
||||
|
||||
# set build flags to use in makefile
|
||||
AC_SUBST([common_pmi_CPPFLAGS])
|
||||
AC_SUBST([common_pmi_LDFLAGS])
|
||||
AC_SUBST([common_pmi_LIBS])
|
||||
|
||||
])
|
@ -34,8 +34,6 @@ 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
|
||||
@ -67,44 +65,10 @@ static int pmi_component_open(void)
|
||||
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;
|
||||
}
|
||||
/* flag that we started PMI */
|
||||
started_by_me = true;
|
||||
/* ignore the info - we'll pick it up elsewhere */
|
||||
return true;
|
||||
#else
|
||||
PMI_BOOL initialized;
|
||||
|
||||
if (PMI_SUCCESS != PMI_Initialized(&initialized)) {
|
||||
return false;
|
||||
}
|
||||
if (PMI_TRUE != initialized) {
|
||||
if (PMI_SUCCESS != PMI_Init(&initialized)) {
|
||||
return false;
|
||||
}
|
||||
/* flag that we started PMI */
|
||||
started_by_me = true;
|
||||
}
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int pmi_component_query(mca_base_module_t **module, int *priority)
|
||||
{
|
||||
/* we are available anywhere PMI is available, but not for HNP itself */
|
||||
if (!ORTE_PROC_IS_HNP && pmi_startup()) {
|
||||
if (!ORTE_PROC_IS_HNP && mca_common_pmi_init ()) {
|
||||
/* if PMI is available, use it */
|
||||
*priority = 35;
|
||||
*module = (mca_base_module_t *)&orte_ess_pmi_module;
|
||||
@ -120,20 +84,7 @@ static int pmi_component_query(mca_base_module_t **module, int *priority)
|
||||
|
||||
static int pmi_component_close(void)
|
||||
{
|
||||
#if WANT_CRAY_PMI2_EXT
|
||||
if (started_by_me && PMI2_Initialized()) {
|
||||
PMI2_Finalize();
|
||||
}
|
||||
#else
|
||||
PMI_BOOL initialized;
|
||||
|
||||
/* if we weren't selected, cleanup */
|
||||
if (started_by_me &&
|
||||
PMI_SUCCESS == PMI_Initialized(&initialized) &&
|
||||
PMI_TRUE == initialized) {
|
||||
PMI_Finalize();
|
||||
}
|
||||
#endif
|
||||
mca_common_pmi_finalize ();
|
||||
|
||||
return ORTE_SUCCESS;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* -*- C -*-
|
||||
*
|
||||
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2011 Los Alamos National Security, LLC. All
|
||||
* Copyright (c) 2011-2012 Los Alamos National Security, LLC. All
|
||||
* rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
@ -26,7 +26,6 @@
|
||||
#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,64 +67,17 @@ int orte_grpcomm_pmi_open(void)
|
||||
|
||||
int orte_grpcomm_pmi_close(void)
|
||||
{
|
||||
#if WANT_CRAY_PMI2_EXT
|
||||
if (started_by_me && PMI2_Initialized()) {
|
||||
PMI2_Finalize();
|
||||
}
|
||||
#else
|
||||
PMI_BOOL initialized;
|
||||
|
||||
/* if we weren't selected, cleanup */
|
||||
if (started_by_me &&
|
||||
PMI_SUCCESS == PMI_Initialized(&initialized) &&
|
||||
PMI_TRUE == initialized) {
|
||||
PMI_Finalize();
|
||||
}
|
||||
#endif
|
||||
mca_common_pmi_finalize ();
|
||||
|
||||
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;
|
||||
}
|
||||
/* flag that we started PMI */
|
||||
started_by_me = true;
|
||||
/* ignore the info - we'll pick it up elsewhere */
|
||||
return true;
|
||||
#else
|
||||
PMI_BOOL initialized;
|
||||
|
||||
if (PMI_SUCCESS != PMI_Initialized(&initialized)) {
|
||||
return false;
|
||||
}
|
||||
if (PMI_TRUE != initialized) {
|
||||
if (PMI_SUCCESS != PMI_Init(&initialized)) {
|
||||
return false;
|
||||
}
|
||||
/* flag that we started PMI */
|
||||
started_by_me = true;
|
||||
}
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
int orte_grpcomm_pmi_component_query(mca_base_module_t **module, int *priority)
|
||||
{
|
||||
/* only use PMI when direct launched */
|
||||
if (NULL == orte_process_info.my_hnp_uri &&
|
||||
ORTE_PROC_IS_MPI &&
|
||||
pmi_startup()) {
|
||||
mca_common_pmi_init ()) {
|
||||
/* if PMI is available, make it available for use by MPI procs */
|
||||
*priority = my_priority;
|
||||
*module = (mca_base_module_t *)&orte_grpcomm_pmi_module;
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user