Skip to content

hook/prot: Connectivity Map #2825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions ompi/mca/hook/prot/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Copyright (c) 2016 IBM Corporation. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#

sources = \
hook_prot.h \
hook_prot_component.c \
hook_prot_fns.c

# This component will only ever be built statically -- never as a DSO.

noinst_LTLIBRARIES = libmca_hook_prot.la

libmca_hook_prot_la_SOURCES = $(sources)
libmca_hook_prot_la_LDFLAGS = -module -avoid-version
25 changes: 25 additions & 0 deletions ompi/mca/hook/prot/configure.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# Copyright (c) 2016 IBM Corporation. All rights reserved.
#
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#

# Make this a static component
AC_DEFUN([MCA_ompi_hook_prot_COMPILE_MODE], [
AC_MSG_CHECKING([for MCA component $2:$3 compile mode])
$4="static"
AC_MSG_RESULT([$$4])
])

# MCA_hook_prot_CONFIG([action-if-can-compile],
# [action-if-cant-compile])
# ------------------------------------------------
AC_DEFUN([MCA_ompi_hook_prot_CONFIG],[
AC_CONFIG_FILES([ompi/mca/hook/prot/Makefile])

$1
])
34 changes: 34 additions & 0 deletions ompi/mca/hook/prot/hook_prot.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2016 IBM Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef MCA_HOOK_PROT_H
#define MCA_HOOK_PROT_H

#include "ompi_config.h"

#include "ompi/constants.h"

#include "ompi/mca/hook/hook.h"
#include "ompi/mca/hook/base/base.h"

BEGIN_C_DECLS

OMPI_MODULE_DECLSPEC extern const ompi_hook_base_component_2_0_0_t mca_hook_prot_component;

extern int mca_hook_prot_verbose;
extern int mca_hook_prot_output;
extern bool hook_prot_enable_mpi_init;
extern bool hook_prot_enable_mpi_finalize;

void ompi_hook_prot_mpi_init_bottom(int argc, char **argv, int requested, int *provided);

void ompi_hook_prot_mpi_finalize_top(void);

END_C_DECLS

#endif /* MCA_HOOK_PROT_H */
155 changes: 155 additions & 0 deletions ompi/mca/hook/prot/hook_prot_component.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
/*
* Copyright (c) 2016 IBM Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/

#include "ompi_config.h"

#include "hook_prot.h"

static int ompi_hook_prot_component_open(void);
static int ompi_hook_prot_component_close(void);
static int ompi_hook_prot_component_register(void);

/*
* Public string showing the component version number
*/
const char *mca_hook_prot_component_version_string =
"Open MPI 'prot' hook MCA component version " OMPI_VERSION;

/*
* Instantiate the public struct with all of our public information
* and pointers to our public functions in it
*/
const ompi_hook_base_component_2_0_0_t mca_hook_prot_component = {

/* First, the mca_component_t struct containing meta information
* about the component itself */
.hookm_version = {
OMPI_HOOK_BASE_VERSION_2_0_0,

/* Component name and version */
.mca_component_name = "prot",
MCA_BASE_MAKE_VERSION(component, OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION,
OMPI_RELEASE_VERSION),

/* Component open and close functions */
.mca_open_component = ompi_hook_prot_component_open,
.mca_close_component = ompi_hook_prot_component_close,
.mca_register_component_params = ompi_hook_prot_component_register,
},
.hookm_data = {
/* The component is checkpoint ready */
MCA_BASE_METADATA_PARAM_CHECKPOINT
},

/* Component functions */
.hookm_mpi_initialized_top = NULL,
.hookm_mpi_initialized_bottom = NULL,

.hookm_mpi_finalized_top = NULL,
.hookm_mpi_finalized_bottom = NULL,

.hookm_mpi_init_top = NULL,
.hookm_mpi_init_top_post_opal = NULL,
.hookm_mpi_init_bottom = ompi_hook_prot_mpi_init_bottom,
.hookm_mpi_init_error = NULL,

.hookm_mpi_finalize_top = ompi_hook_prot_mpi_finalize_top,
.hookm_mpi_finalize_bottom = NULL,
};

int mca_hook_prot_verbose = 0;
int mca_hook_prot_output = -1;
bool hook_prot_enable_mpi_init = false;
bool hook_prot_enable_mpi_finalize = false;

static int ompi_hook_prot_component_open(void)
{
// Nothing to do
return OMPI_SUCCESS;
}

static int ompi_hook_prot_component_close(void)
{
// Nothing to do
return OMPI_SUCCESS;
}

static int ompi_hook_prot_component_register(void)
{

/*
* Component verbosity level
*/
// Inherit the verbosity of the base framework, but also allow this to be overridden
if( ompi_hook_base_framework.framework_verbose > MCA_BASE_VERBOSE_NONE ) {
mca_hook_prot_verbose = ompi_hook_base_framework.framework_verbose;
}
else {
mca_hook_prot_verbose = MCA_BASE_VERBOSE_NONE;
}
(void) mca_base_component_var_register(&mca_hook_prot_component.hookm_version, "verbose",
NULL,
MCA_BASE_VAR_TYPE_INT, NULL,
0, 0,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&mca_hook_prot_verbose);

mca_hook_prot_output = opal_output_open(NULL);
opal_output_set_verbosity(mca_hook_prot_output, mca_hook_prot_verbose);

/*
* If the component is active for mpi_init / mpi_finalize
*/
hook_prot_enable_mpi_init = false;
(void) mca_base_component_var_register(&mca_hook_prot_component.hookm_version, "enable_mpi_init",
"Enable prot behavior on mpi_init",
MCA_BASE_VAR_TYPE_BOOL, NULL,
0, 0,
OPAL_INFO_LVL_3,
MCA_BASE_VAR_SCOPE_READONLY,
&hook_prot_enable_mpi_init);

hook_prot_enable_mpi_finalize = false;
(void) mca_base_component_var_register(&mca_hook_prot_component.hookm_version, "enable_mpi_finalize",
"Enable prot behavior on mpi_finalize",
MCA_BASE_VAR_TYPE_BOOL, NULL,
0, 0,
OPAL_INFO_LVL_3,
MCA_BASE_VAR_SCOPE_READONLY,
&hook_prot_enable_mpi_finalize);

// User can set the ompi_platform_prot variable too
int hook_prot_platform_prot = -1;
(void) mca_base_var_register("ompi", NULL, NULL, "platform_prot",
"Enable prot behavior (1) mpi_init or (2) mpi_finalize",
MCA_BASE_VAR_TYPE_INT, NULL,
0, 0,
OPAL_INFO_LVL_3,
MCA_BASE_VAR_SCOPE_READONLY,
&hook_prot_platform_prot);

// User can set the MPI_PROT variable
// MPI_PROT which can also be 1 or 2, saying where we want to
// activate from.
char *p = getenv("MPI_PROT");
int mode = 0;
if( NULL != p ) {
mode = atoi(p);
}
if( 1 == mode || 1 == hook_prot_platform_prot ) {
hook_prot_enable_mpi_init = true;
}
else if( 2 == mode || 2 == hook_prot_platform_prot ) {
hook_prot_enable_mpi_finalize = true;
}

return OMPI_SUCCESS;
}

Loading