Skip to content

Commit

Permalink
ompi/hook: Add the hook/license framework
Browse files Browse the repository at this point in the history
 * Include a 'demo' component that shows some of the features.
 * Currently has hooks for:
   - MPI_Initialized
     - top, bottom
   - MPI_Init_thread
     - top, bottom
   - MPI_Finalized
     - top, bottom
   - MPI_Init
     - top (pre-opal_init), top (post-opal_init), error, bottom
   - MPI_Finalize
     - top, bottom
 * Other places in ompi can 'register' to hook into any one of these places
   by passing back a component structure filled with function pointers.
 * Add a `MCA_BASE_COMPONENT_FLAG_REQUIRED` flag to the MCA structure that
   is checked by the `hook` framework. If a required, static component has
   been excluded then the `hook` framework will fail to initialize.
   - See note in `opal/mca/mca.h` as to why this is checked in the `hook`
     framework and not in `opal/mca/base/mca_base_component_find.c`

Signed-off-by: Joshua Hursey <[email protected]>
  • Loading branch information
jjhursey committed Feb 14, 2017
1 parent 2c1980a commit 48b7b16
Show file tree
Hide file tree
Showing 21 changed files with 988 additions and 3 deletions.
27 changes: 27 additions & 0 deletions ompi/mca/hook/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# Copyright (c) 2016 IBM Corporation. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#

# main library setup
noinst_LTLIBRARIES = libmca_hook.la
libmca_hook_la_SOURCES =

# local files
headers = hook.h
libmca_hook_la_SOURCES += $(headers)

# Conditionally install the header files
if WANT_INSTALL_HEADERS
ompidir = $(ompiincludedir)/$(subdir)
nobase_ompi_HEADERS = $(headers)
endif

include base/Makefile.am

distclean-local:
rm -f base/static-components.h
16 changes: 16 additions & 0 deletions ompi/mca/hook/base/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#

dist_ompidata_DATA = base/help-mca-hook-base.txt

headers += \
base/base.h

libmca_hook_la_SOURCES += \
base/hook_base.c
56 changes: 56 additions & 0 deletions ompi/mca/hook/base/base.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2016 IBM Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/

#ifndef OMPI_HOOK_BASE_H
#define OMPI_HOOK_BASE_H

#include "ompi_config.h"

#include "ompi/mca/mca.h"
#include "opal/mca/base/mca_base_framework.h"

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

BEGIN_C_DECLS

/**
* Framework struct declaration for this framework
*/
OMPI_DECLSPEC extern mca_base_framework_t ompi_hook_base_framework;


/**
* Register another component to be called
*/
OMPI_DECLSPEC int ompi_hook_base_register_callbacks(ompi_hook_base_component_t *comp);
OMPI_DECLSPEC int ompi_hook_base_deregister_callbacks(ompi_hook_base_component_t *comp);

/**
* Wrapper functions matching the interface functions
*/
OMPI_DECLSPEC void ompi_hook_base_mpi_initialized_top(int *flag);
OMPI_DECLSPEC void ompi_hook_base_mpi_initialized_bottom(int *flag);

OMPI_DECLSPEC void ompi_hook_base_mpi_init_thread_top(int *argc, char ***argv, int required, int *provided);
OMPI_DECLSPEC void ompi_hook_base_mpi_init_thread_bottom(int *argc, char ***argv, int required, int *provided);

OMPI_DECLSPEC void ompi_hook_base_mpi_finalized_top(int *flag);
OMPI_DECLSPEC void ompi_hook_base_mpi_finalized_bottom(int *flag);

OMPI_DECLSPEC void ompi_hook_base_mpi_init_top(int argc, char **argv, int requested, int *provided);
OMPI_DECLSPEC void ompi_hook_base_mpi_init_top_post_opal(int argc, char **argv, int requested, int *provided);
OMPI_DECLSPEC void ompi_hook_base_mpi_init_bottom(int argc, char **argv, int requested, int *provided);
OMPI_DECLSPEC void ompi_hook_base_mpi_init_error(int argc, char **argv, int requested, int *provided);

OMPI_DECLSPEC void ompi_hook_base_mpi_finalize_top(void);
OMPI_DECLSPEC void ompi_hook_base_mpi_finalize_bottom(void);

END_C_DECLS

#endif /* OMPI_BASE_HOOK_H */
19 changes: 19 additions & 0 deletions ompi/mca/hook/base/help-mca-hook-base.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- text -*-
#
# Copyright (c) 2017 IBM Corporation. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# This is the US/English help file for Open MPI MCA hook-specific
# error messages.
#
[hook:missing-required-component]
Error: A request was made to exclude a hook component from consideration that
is required to be included. This component (noted below) can -not- be excluded
from consideration. The program will fail at this time.

Framework: %s
Component: %s
Loading

0 comments on commit 48b7b16

Please sign in to comment.