rename service framework to svc and started fleshing out
This commit was SVN r2339.
Этот коммит содержится в:
родитель
bdd3ad9d49
Коммит
af01d08bb5
21
src/mca/svc/Makefile.am
Обычный файл
21
src/mca/svc/Makefile.am
Обычный файл
@ -0,0 +1,21 @@
|
||||
#
|
||||
# $HEADER$
|
||||
#
|
||||
|
||||
include $(top_srcdir)/config/Makefile.options
|
||||
|
||||
SUBDIRS = base $(MCA_svc_STATIC_SUBDIRS)
|
||||
DIST_SUBDIRS = base $(MCA_svc_ALL_SUBDIRS)
|
||||
|
||||
# Source code files
|
||||
|
||||
headers = svc.h
|
||||
|
||||
# Conditionally install the header files
|
||||
|
||||
if WANT_INSTALL_HEADERS
|
||||
ompidir = $(includedir)/openmpi/mca/svc
|
||||
ompi_HEADERS = $(headers)
|
||||
else
|
||||
ompidir = $(includedir)
|
||||
endif
|
32
src/mca/svc/base/Makefile.am
Обычный файл
32
src/mca/svc/base/Makefile.am
Обычный файл
@ -0,0 +1,32 @@
|
||||
#
|
||||
# $HEADER$
|
||||
#
|
||||
|
||||
include $(top_srcdir)/config/Makefile.options
|
||||
|
||||
noinst_LTLIBRARIES = libmca_svc_base.la
|
||||
|
||||
# For VPATH builds, have to specify where static-modules.h will be found
|
||||
|
||||
AM_CPPFLAGS = -I$(top_builddir)/src
|
||||
|
||||
# Source code files
|
||||
|
||||
headers = \
|
||||
base.h
|
||||
|
||||
libmca_svc_base_la_SOURCES = \
|
||||
$(headers) \
|
||||
svc_base_open.c \
|
||||
svc_base_close.c \
|
||||
svc_base_init.c
|
||||
|
||||
# Conditionally install the header files
|
||||
|
||||
if WANT_INSTALL_HEADERS
|
||||
ompidir = $(includedir)/mca/svc/base
|
||||
ompi_HEADERS = $(headers)
|
||||
else
|
||||
ompidir = $(includedir)
|
||||
endif
|
||||
|
46
src/mca/svc/base/base.h
Обычный файл
46
src/mca/svc/base/base.h
Обычный файл
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#ifndef MCA_SVC_BASE_H
|
||||
#define MCA_SVC_BASE_H
|
||||
|
||||
#include "ompi_config.h"
|
||||
|
||||
#include "mca/mca.h"
|
||||
#include "mca/svc/svc.h"
|
||||
|
||||
|
||||
struct mca_svc_base_module_item_t {
|
||||
ompi_list_item_t super;
|
||||
mca_svc_base_component_t *svc_component;
|
||||
mca_svc_base_module_t *svc_module;
|
||||
};
|
||||
typedef struct mca_svc_base_module_item_t mca_svc_base_module_item_t;
|
||||
|
||||
OBJ_CLASS_DECLARATION(mca_svc_base_module_item_t);
|
||||
|
||||
|
||||
/*
|
||||
* Global functions for the SVC
|
||||
*/
|
||||
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
int mca_svc_base_open(void);
|
||||
int mca_svc_base_init(void);
|
||||
int mca_svc_base_close(void);
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Globals
|
||||
*/
|
||||
extern int mca_svc_base_output;
|
||||
extern ompi_list_t mca_svc_base_components;
|
||||
extern ompi_list_t mca_svc_base_modules;
|
||||
|
||||
#endif /* MCA_SVC_BASE_H */
|
45
src/mca/svc/base/svc_base_close.c
Обычный файл
45
src/mca/svc/base/svc_base_close.c
Обычный файл
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "ompi_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "include/constants.h"
|
||||
#include "mca/mca.h"
|
||||
#include "mca/base/base.h"
|
||||
#include "mca/svc/svc.h"
|
||||
#include "mca/svc/base/base.h"
|
||||
|
||||
|
||||
int mca_svc_base_close(void)
|
||||
{
|
||||
ompi_list_item_t *item;
|
||||
mca_svc_base_module_item_t *sm;
|
||||
|
||||
/* Finalize all the svc components and free their list items */
|
||||
|
||||
for (item = ompi_list_remove_first(&mca_svc_base_components);
|
||||
NULL != item;
|
||||
item = ompi_list_remove_first(&mca_svc_base_components)) {
|
||||
sm = (mca_svc_base_module_item_t *) item;
|
||||
|
||||
/* Blatently ignore the return code (what would we do to recover,
|
||||
anyway? This component is going away, so errors don't matter
|
||||
anymore) */
|
||||
|
||||
sm->svc_module->svc_fini(sm->svc_module);
|
||||
OBJ_RELEASE(sm);
|
||||
}
|
||||
|
||||
/* Close all remaining available components (may be one if this is a
|
||||
OMPI RTE program, or [possibly] multiple if this is ompi_info) */
|
||||
|
||||
mca_base_components_close(mca_svc_base_output,
|
||||
&mca_svc_base_components, NULL);
|
||||
|
||||
/* All done */
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
83
src/mca/svc/base/svc_base_init.c
Обычный файл
83
src/mca/svc/base/svc_base_init.c
Обычный файл
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "ompi_config.h"
|
||||
|
||||
#include "runtime/runtime.h"
|
||||
#include "util/output.h"
|
||||
#include "mca/mca.h"
|
||||
#include "mca/base/base.h"
|
||||
#include "mca/svc/svc.h"
|
||||
#include "mca/svc/base/base.h"
|
||||
|
||||
|
||||
OBJ_CLASS_INSTANCE(mca_svc_base_selected_module_t, ompi_list_item_t, NULL, NULL);
|
||||
|
||||
|
||||
/**
|
||||
* Function for weeding out svc modules that don't want to run.
|
||||
*
|
||||
* Call the init function on all available components to find out if they
|
||||
* want to run. Select all components that don't fail. Failing modules
|
||||
* will be closed and unloaded. The selected modules will be returned
|
||||
* to the caller in a ompi_list_t.
|
||||
*/
|
||||
int mca_svc_base_init(void)
|
||||
{
|
||||
ompi_list_item_t *item;
|
||||
mca_base_component_list_item_t *cli;
|
||||
mca_svc_base_component_t *component;
|
||||
mca_svc_base_module_t *module;
|
||||
mca_svc_base_module_item_t *sm;
|
||||
|
||||
/* Default to true in case there's no modules selected */
|
||||
|
||||
/* Traverse the list of available modules; call their init
|
||||
functions. */
|
||||
|
||||
for (item = ompi_list_get_first(&mca_svc_base_components);
|
||||
ompi_list_get_end(&mca_svc_base_components) != item;
|
||||
item = ompi_list_get_next(item)) {
|
||||
cli = (mca_base_component_list_item_t *) item;
|
||||
component = (mca_svc_base_component_t *) cli->cli_component;
|
||||
|
||||
ompi_output_verbose(10, mca_svc_base_output,
|
||||
"select: initializing %s module %s",
|
||||
component->svc_version.mca_type_name,
|
||||
component->svc_version.mca_component_name);
|
||||
if (NULL == component->svc_init) {
|
||||
ompi_output_verbose(10, mca_svc_base_output,
|
||||
"select: no init function; ignoring module");
|
||||
} else {
|
||||
module = component->svc_init();
|
||||
|
||||
/* If the module didn't initialize, unload it */
|
||||
|
||||
if (NULL == module) {
|
||||
ompi_output_verbose(10, mca_svc_base_output,
|
||||
"select: init returned failure");
|
||||
|
||||
mca_base_component_repository_release((mca_base_component_t *) component);
|
||||
ompi_output_verbose(10, mca_svc_base_output,
|
||||
"select: component %s unloaded",
|
||||
component->svc_version.mca_component_name);
|
||||
}
|
||||
|
||||
/* Otherwise, it initialized properly. Save it. */
|
||||
|
||||
else {
|
||||
ompi_output_verbose(10, mca_svc_base_output,
|
||||
"select: init returned success");
|
||||
|
||||
sm = OBJ_NEW(mca_svc_base_module_item_t);
|
||||
sm->svc_component = component;
|
||||
sm->svc_module = module;
|
||||
ompi_list_append(&mca_svc_base_modules, (ompi_list_item_t*) sm);
|
||||
}
|
||||
}
|
||||
}
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
|
51
src/mca/svc/base/svc_base_open.c
Обычный файл
51
src/mca/svc/base/svc_base_open.c
Обычный файл
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "ompi_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "mca/mca.h"
|
||||
#include "mca/base/base.h"
|
||||
#include "mca/svc/svc.h"
|
||||
#include "mca/svc/base/base.h"
|
||||
|
||||
|
||||
/*
|
||||
* The following file was created by configure. It contains extern
|
||||
* statements and the definition of an array of pointers to each
|
||||
* component's public mca_base_component_t struct.
|
||||
*/
|
||||
|
||||
#include "mca/svc/base/static-components.h"
|
||||
|
||||
|
||||
/*
|
||||
* Global variables
|
||||
*/
|
||||
int mca_svc_base_output = -1;
|
||||
ompi_list_t mca_svc_base_components;
|
||||
ompi_list_t mca_svc_base_modules;
|
||||
|
||||
|
||||
/**
|
||||
* Function for finding and opening either all MCA components,
|
||||
* or the one that was specifically requested via a MCA parameter.
|
||||
*/
|
||||
int mca_svc_base_open(void)
|
||||
{
|
||||
/* Open up all available components */
|
||||
|
||||
if (OMPI_SUCCESS !=
|
||||
mca_base_components_open("svc", 0, mca_svc_base_static_components,
|
||||
&mca_svc_base_components)) {
|
||||
return OMPI_ERROR;
|
||||
}
|
||||
|
||||
/* Initialize the list so that in mca_mpool_base_close(), we can
|
||||
iterate over it (even if it's empty, as in the case of ompi_info) */
|
||||
OBJ_CONSTRUCT(&mca_svc_base_modules, ompi_list_t);
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
11
src/mca/svc/exec/Makefile.am
Обычный файл
11
src/mca/svc/exec/Makefile.am
Обычный файл
@ -0,0 +1,11 @@
|
||||
# -*- makefile -*-
|
||||
#
|
||||
# $HEADER$
|
||||
#
|
||||
|
||||
include $(top_ompi_srcdir)/config/Makefile.options
|
||||
|
||||
noinst_LTLIBRARIES = libmca_svc_exec.la
|
||||
libmca_svc_exec_la_SOURCES = \
|
||||
svc_exec.c \
|
||||
svc_exec_component.c
|
52
src/mca/svc/exec/svc_exec.c
Обычный файл
52
src/mca/svc/exec/svc_exec.c
Обычный файл
@ -0,0 +1,52 @@
|
||||
#include "ompi_config.h"
|
||||
#include "mca/oob/oob.h"
|
||||
#include "mca/oob/base/base.h"
|
||||
#include "svc_exec.h"
|
||||
|
||||
|
||||
mca_svc_base_module_t mca_svc_exec_module = {
|
||||
mca_svc_exec_module_init,
|
||||
mca_svc_exec_module_fini
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Process an OOB request.
|
||||
*/
|
||||
|
||||
static void mca_svc_exec_recv(
|
||||
int status,
|
||||
ompi_process_name_t* peer,
|
||||
ompi_buffer_t buffer,
|
||||
int tag,
|
||||
void* cbdata)
|
||||
{
|
||||
/* unpack message */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register a callback to receive OOB requests.
|
||||
*/
|
||||
|
||||
int mca_svc_exec_module_init(mca_svc_base_module_t* module)
|
||||
{
|
||||
return mca_oob_recv_packed_nb(
|
||||
MCA_OOB_NAME_ANY,
|
||||
MCA_OOB_TAG_EXEC,
|
||||
MCA_OOB_ALLOC,
|
||||
mca_svc_exec_recv,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cleanup
|
||||
*/
|
||||
|
||||
int mca_svc_exec_module_fini(mca_svc_base_module_t* module)
|
||||
{
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
29
src/mca/svc/exec/svc_exec.h
Обычный файл
29
src/mca/svc/exec/svc_exec.h
Обычный файл
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
#ifndef _MCA_SVC_EXEC_
|
||||
#define _MCA_SVC_EXEC_
|
||||
|
||||
#include "mca/svc/svc.h"
|
||||
|
||||
/**
|
||||
* Component open/close/init
|
||||
*/
|
||||
int mca_svc_exec_component_open(void);
|
||||
int mca_svc_exec_component_close(void);
|
||||
mca_svc_base_module_t* mca_svc_exec_component_init(void);
|
||||
|
||||
/**
|
||||
* Module init/fini
|
||||
*/
|
||||
int mca_svc_exec_module_init(mca_svc_base_module_t*);
|
||||
int mca_svc_exec_module_fini(mca_svc_base_module_t*);
|
||||
|
||||
extern mca_svc_base_module_t mca_svc_exec_module;
|
||||
extern mca_svc_base_component_t mca_svc_exec_component;
|
||||
|
||||
#endif
|
||||
|
61
src/mca/svc/exec/svc_exec_component.c
Обычный файл
61
src/mca/svc/exec/svc_exec_component.c
Обычный файл
@ -0,0 +1,61 @@
|
||||
#include "svc_exec.h"
|
||||
|
||||
|
||||
mca_svc_base_component_t mca_svc_exec_component = {
|
||||
/* First, the mca_base_module_t struct containing meta
|
||||
information about the module itself */
|
||||
{
|
||||
/* Indicate that we are a pml v1.0.0 module (which also
|
||||
implies a specific MCA version) */
|
||||
|
||||
MCA_SVC_BASE_VERSION_1_0_0,
|
||||
|
||||
"exec", /* MCA module name */
|
||||
1, /* MCA module major version */
|
||||
0, /* MCA module minor version */
|
||||
0, /* MCA module release version */
|
||||
mca_svc_exec_component_open, /* component open */
|
||||
mca_svc_exec_component_close /* component close */
|
||||
},
|
||||
|
||||
/* Next the MCA v1.0.0 module meta data */
|
||||
|
||||
{
|
||||
/* Whether the module is checkpointable or not */
|
||||
|
||||
false
|
||||
},
|
||||
|
||||
mca_svc_exec_component_init
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
int mca_svc_exec_component_open(void)
|
||||
{
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
mca_svc_base_module_t* mca_svc_exec_component_init(void)
|
||||
{
|
||||
return &mca_svc_exec_module;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
int mca_svc_exec_component_close(void)
|
||||
{
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#ifndef MCA_SERVICE_H
|
||||
#define MCA_SERVICE_H
|
||||
#ifndef MCA_SVC_H
|
||||
#define MCA_SVC_H
|
||||
|
||||
#include "ompi_config.h"
|
||||
|
||||
@ -16,47 +16,38 @@
|
||||
* Service component
|
||||
**************************************************************************/
|
||||
|
||||
typedef const struct mca_service_module_1_0_0_t *(*mca_service_base_select_fn_t) (bool am_seed);
|
||||
struct mca_svc_base_module_t;
|
||||
typedef struct mca_svc_base_module_t *(*mca_svc_base_component_init_fn_t) (void);
|
||||
|
||||
/*
|
||||
* Structure for service v1.0.0 components
|
||||
* Structure for svc v1.0.0 components
|
||||
* Chained to MCA v1.0.0
|
||||
*/
|
||||
struct mca_service_base_component_1_0_0_t {
|
||||
mca_base_component_t dc_version;
|
||||
mca_base_component_data_1_0_0_t dc_data;
|
||||
struct mca_svc_base_component_t {
|
||||
mca_base_component_t svc_version;
|
||||
mca_base_component_data_1_0_0_t svc_data;
|
||||
|
||||
/* Initialization / querying functions */
|
||||
|
||||
mca_service_base_select_fn_t dc_select;
|
||||
/* Initialization functions */
|
||||
mca_svc_base_component_init_fn_t svc_init;
|
||||
};
|
||||
typedef struct mca_service_base_component_1_0_0_t mca_service_base_component_1_0_0_t;
|
||||
typedef struct mca_svc_base_component_t mca_svc_base_component_t;
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Service module
|
||||
**************************************************************************/
|
||||
|
||||
typedef int (*mca_service_base_init_fn_t) (mca_service_base_module_t *self);
|
||||
typedef int (*mca_service_base_finalize_t) (mca_service_base_module_t *self);
|
||||
typedef int (*mca_svc_base_module_init_fn_t) (struct mca_svc_base_module_t *self);
|
||||
typedef int (*mca_svc_base_module_fini_fn_t) (struct mca_svc_base_module_t *self);
|
||||
|
||||
typedef int (*mca_service_base_poll_t) (mca_service_base_module_t *self);
|
||||
|
||||
struct mca_service_base_module_1_0_0_t {
|
||||
|
||||
/* Init / finalize */
|
||||
|
||||
mca_service_base_init_fn_t dm_init;
|
||||
mca_service_base_finalize_fn_t dm_finalize;
|
||||
|
||||
/* Polling */
|
||||
|
||||
mca_service_base_poll_fn_t dm_poll;
|
||||
struct mca_svc_base_module_t {
|
||||
mca_svc_base_module_init_fn_t svc_init;
|
||||
mca_svc_base_module_fini_fn_t svc_fini;
|
||||
};
|
||||
typedef struct mca_service_module_1_0_0_t mca_service_module_1_0_0_t;
|
||||
typedef struct mca_svc_base_module_t mca_svc_base_module_t;
|
||||
|
||||
/*
|
||||
* service services (i.e., components), and the initial events that
|
||||
* svc svcs (i.e., components), and the initial events that
|
||||
* will trigger scheduling them to run:
|
||||
*
|
||||
* Service FD events incoming OOB timer signals
|
||||
@ -83,10 +74,9 @@ typedef struct mca_service_module_1_0_0_t mca_service_module_1_0_0_t;
|
||||
*
|
||||
* Initialization sequence:
|
||||
*
|
||||
* - find all service components
|
||||
* - call select(); if non-NULL reply, keep, otherwise close/unloads
|
||||
* - find all svc components
|
||||
* - call init() on all component - if non-NULL reply, keep, otherwise close/unloads
|
||||
* - call init() on all modules
|
||||
* - call poll() on all modules once. poll() can do the following:
|
||||
* - post non-blocking oob receive with callback
|
||||
* - setup a fd and register with libevent with callback
|
||||
* - indicate that it wants to run after receiving a specific signal
|
||||
@ -97,7 +87,7 @@ typedef struct mca_service_module_1_0_0_t mca_service_module_1_0_0_t;
|
||||
* --> currently no other mechanisms for progress
|
||||
* - post a non-blocking oob receive on a specific tag for shutdown
|
||||
*
|
||||
* The callback posted by the service for the shutdown message will
|
||||
* The callback posted by the svc for the shutdown message will
|
||||
* simply set a global "time_to_shutdown" flag that will be noticed in
|
||||
* the main event loop.
|
||||
*
|
||||
@ -109,7 +99,6 @@ typedef struct mca_service_module_1_0_0_t mca_service_module_1_0_0_t;
|
||||
* calling the appropriate callbacks, and checking the global shutdown
|
||||
* flag. Something like this:
|
||||
*
|
||||
* do_init_stuff();
|
||||
* while (1) {
|
||||
* // make progress on fd (including OOB) and timer events in here
|
||||
* err = blocking_libevent_progress();
|
||||
@ -122,23 +111,18 @@ typedef struct mca_service_module_1_0_0_t mca_service_module_1_0_0_t;
|
||||
* else if (err == interrupted_by_signal) {
|
||||
* call_handler_for_signal();
|
||||
* }
|
||||
* // see if there's anything on the to-be-run queue
|
||||
* foreach service (@to_be_run) {
|
||||
* service->poll();
|
||||
* }
|
||||
* }
|
||||
* do_finalize_stuff();
|
||||
*
|
||||
* open q: how to do oob sending from within the services?
|
||||
*/
|
||||
|
||||
/*
|
||||
* Macro for use in modules that are of type service v1.0.0
|
||||
* Macro for use in modules that are of type svc v1.0.0
|
||||
*/
|
||||
#define MCA_SERVICE_BASE_VERSION_1_0_0 \
|
||||
/* service v1.0 is chained to MCA v1.0 */ \
|
||||
#define MCA_SVC_BASE_VERSION_1_0_0 \
|
||||
/* svc v1.0 is chained to MCA v1.0 */ \
|
||||
MCA_BASE_VERSION_1_0_0, \
|
||||
/* service v1.0 */ \
|
||||
"service", 1, 0, 0
|
||||
/* svc v1.0 */ \
|
||||
"svc", 1, 0, 0
|
||||
|
||||
#endif /* MCA_SERVICE_H */
|
||||
#endif /* MCA_SVC_H */
|
Загрузка…
x
Ссылка в новой задаче
Block a user