1
1
This commit was SVN r1263.
Этот коммит содержится в:
Tim Woodall 2004-06-15 16:56:35 +00:00
родитель 8891b47d57
Коммит 422e59593e
7 изменённых файлов: 375 добавлений и 0 удалений

28
src/mca/allocator/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,28 @@
#
# $HEADER$
#
include $(top_srcdir)/config/Makefile.options
SUBDIRS = base $(MCA_allocator_STATIC_SUBDIRS)
DIST_SUBDIRS = base $(MCA_allocator_ALL_SUBDIRS)
# Source code files
headers = allocator.h
noinst_LTLIBRARIES = libmca_allocator.la
libmca_allocator_la_SOURCES =
libmca_allocator_la_LIBADD = \
base/libmca_allocator_base.la \
$(MCA_allocator_STATIC_LTLIBS)
libmca_allocator_la_DEPENDENCIES = $(libmca_allocator_la_LIBADD)
# Conditionally install the header files
if WANT_INSTALL_HEADERS
ompidir = $(includedir)/ompi/mca/allocator
ompi_HEADERS = $(headers)
else
ompidir = $(includedir)
endif

65
src/mca/allocator/allocator.h Обычный файл
Просмотреть файл

@ -0,0 +1,65 @@
/**
* $HEADER$
*/
/**
* @file
*/
#ifndef MCA_ALLOCATOR_H
#define MCA_ALLOCATOR_H
#include "mca/mca.h"
struct mca_allocator_t;
/**
* allocate function typedef
*/
typedef void* (*mca_allocator_alloc_fn_t)(size_t);
/**
* allocate align function typedef
*/
typedef void* (*mca_allocator_alloc_align_fn_t)(size_t, size_t);
/**
* realloc function typedef
*/
typedef void* (*mca_allocator_realloc_fn_t)(void*, size_t);
/**
* free function typedef
*/
typedef void(*mca_allocator_free_fn_t)(void *);
typedef int (*mca_allocator_finalize_fn_t)(
struct mca_allocator_t* allocator
);
struct mca_allocator_t {
mca_allocator_alloc_fn_t alc_alloc;
mca_allocator_alloc_align_fn_t alc_alloc_align;
mca_allocator_realloc_fn_t alc_realloc;
mca_allocator_free_fn_t alc_free;
mca_allocator_finalize_fn_t alc_finalize;
};
typedef struct mca_allocator_t mca_allocator_t;
/**
* module initialization function
*/
typedef struct mca_allocator_t* (*mca_allocator_base_module_init_fn_t)(
bool *allow_multi_user_threads
);
struct mca_allocator_base_module_1_0_0_t {
mca_base_module_t allocator_version;
mca_base_module_data_1_0_0_t allocator_data;
mca_allocator_base_module_init_fn_t allocator_init;
};
typedef struct mca_allocator_base_module_1_0_0_t mca_allocator_base_module_t;
#endif /* MCA_ALLOCATOR_H */

32
src/mca/allocator/base/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,32 @@
#
# $HEADER$
#
include $(top_srcdir)/config/Makefile.options
noinst_LTLIBRARIES = libmca_allocator_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_allocator_base_la_SOURCES = \
$(headers) \
allocator_base_open.c \
allocator_base_close.c \
allocator_base_select.c
# Conditionally install the header files
if WANT_INSTALL_HEADERS
ompidir = $(includedir)/mca/allocator/base
ompi_HEADERS = $(headers)
else
ompidir = $(includedir)
endif

Просмотреть файл

@ -0,0 +1,46 @@
/*
* $HEADER$
*/
#include "ompi_config.h"
#include <stdio.h>
#include "include/constants.h"
#include "mca/mca.h"
#include "mca/base/base.h"
#include "mca/allocator/allocator.h"
#include "mca/allocator/base/base.h"
int mca_allocator_base_close(void)
{
ompi_list_item_t *item;
mca_allocator_base_selected_module_t *sm;
/* Finalize all the allocator modules and free their list items */
for (item = ompi_list_remove_first(&mca_allocator_base_modules_initialized);
NULL != item;
item = ompi_list_remove_first(&mca_allocator_base_modules_initialized)) {
sm = (mca_allocator_base_selected_module_t *) item;
/* Blatently ignore the return code (what would we do to recover,
anyway? This module is going away, so errors don't matter
anymore) */
sm->absm_actions->alc_finalize(sm->absm_actions);
free(sm);
}
/* Close all remaining available modules (may be one if this is a
OMPI RTE program, or [possibly] multiple if this is ompi_info) */
mca_base_modules_close(mca_allocator_base_output,
&mca_allocator_base_modules_available, NULL);
/* All done */
return OMPI_SUCCESS;
}

Просмотреть файл

@ -0,0 +1,56 @@
/*
* $HEADER$
*/
#include "ompi_config.h"
#include <stdio.h>
#include "mca/mca.h"
#include "mca/base/base.h"
#include "mca/allocator/allocator.h"
#include "mca/allocator/base/base.h"
/*
* The following file was created by configure. It contains extern
* statements and the definition of an array of pointers to each
* module's public mca_base_module_t struct.
*/
#include "mca/allocator/base/static-modules.h"
/*
* Global variables
*/
int mca_allocator_base_output = -1;
ompi_list_t mca_allocator_base_modules_available;
ompi_list_t mca_allocator_base_modules_initialized;
/**
* Function for finding and opening either all MCA modules, or the one
* that was specifically requested via a MCA parameter.
*/
int mca_allocator_base_open(void)
{
/* Open up all available modules */
if (OMPI_SUCCESS !=
mca_base_modules_open("allocator", 0, mca_allocator_base_static_modules,
&mca_allocator_base_modules_available)) {
return OMPI_ERROR;
}
/* Initialize the list so that in mca_allocator_base_close(), we can
iterate over it (even if it's empty, as in the case of
ompi_info) */
OBJ_CONSTRUCT(&mca_allocator_base_modules_initialized, ompi_list_t);
/* All done */
return OMPI_SUCCESS;
}

Просмотреть файл

@ -0,0 +1,99 @@
/*
* $HEADER$
*/
#include "ompi_config.h"
#include "mca/mca.h"
#include "mca/base/base.h"
#include "mca/allocator/base/base.h"
/**
* Function for weeding out allocator modules that don't want to run.
*
* Call the init function on all available modules to find out if they
* want to run. Select all modules 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_allocator_base_select(bool *allow_multi_user_threads)
{
#if 0
int i, num_allocators;
ompi_list_item_t *item;
mca_base_module_list_item_t *mli;
mca_allocator_base_module_t *module;
mca_allocator_t **actions;
mca_allocator_base_selected_module_t *sm;
/* Traverse the list of available modules; call their init
functions. */
for (item = ompi_list_get_first(&mca_allocator_base_modules_available);
ompi_list_get_end(&mca_allocator_base_modules_available) != item;
item = ompi_list_get_next(item)) {
mli = (mca_base_module_list_item_t *) item;
module = (mca_allocator_base_module_t *) mli->mli_module;
ompi_output_verbose(10, mca_allocator_base_output,
"select: initializing %s module %s",
module->allocatorm_version.mca_type_name,
module->allocatorm_version.mca_module_name);
if (NULL == module->allocatorm_init) {
ompi_output_verbose(10, mca_allocator_base_output,
"select: no init function; ignoring module");
} else {
actions = module->allocatorm_init(&num_allocators, &user_threads,
&hidden_threads);
/* If the module didn't initialize, unload it */
if (NULL == actions) {
ompi_output_verbose(10, mca_allocator_base_output,
"select: init returned failure");
mca_base_module_repository_release((mca_base_module_t *) module);
ompi_output_verbose(10, mca_allocator_base_output,
"select: module %s unloaded",
module->allocatorm_version.mca_module_name);
}
/* Otherwise, it initialized properly. Save it. */
else {
*allow_multi_user_threads |= user_threads;
*have_hidden_threads |= hidden_threads;
ompi_output_verbose(10, mca_allocator_base_output,
"select: init returned success");
for (i = 0; i < num_allocators; ++i) {
sm = malloc(sizeof(mca_allocator_base_selected_module_t));
if (NULL == sm) {
return OMPI_ERR_OUT_OF_RESOURCE;
}
OBJ_CONSTRUCT(sm, ompi_list_item_t);
sm->pbsm_module = module;
sm->pbsm_actions = actions[i];
ompi_list_append(&mca_allocator_base_modules_initialized,
(ompi_list_item_t*) sm);
}
free(actions);
}
}
}
/* Finished querying all modules. Check for the bozo case. */
if (0 == ompi_list_get_size(&mca_allocator_base_modules_initialized)) {
/* JMS Replace with show_help */
ompi_abort(1, "No allocator module available. This shouldn't happen.");
}
/* All done */
#endif
return OMPI_SUCCESS;
}

49
src/mca/allocator/base/base.h Обычный файл
Просмотреть файл

@ -0,0 +1,49 @@
/*
* $HEADER$
*/
/**
* @file
*/
#ifndef MCA_ALLOCATOR_BASE_H
#define MCA_ALLOCATOR_BASE_H
#include "ompi_config.h"
#include "class/ompi_list.h"
#include "mca/mca.h"
#include "mca/allocator/allocator.h"
struct mca_allocator_base_selected_module_t {
ompi_list_item_t super;
mca_allocator_base_module_t *apsm_module;
mca_allocator_t *absm_actions;
};
typedef struct mca_allocator_base_selected_module_t mca_allocator_base_selected_module_t;
/*
* Global functions for MCA: overall PTL open and close
*/
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
int mca_allocator_base_open(void);
int mca_allocator_base_select(bool *allow_multi_user_threads);
int mca_allocator_base_close(void);
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
/*
* Globals
*/
extern int mca_allocator_base_output;
extern ompi_list_t mca_allocator_base_modules_available;
extern ompi_list_t mca_allocator_base_modules_initialized;
#endif /* MCA_ALLOCATOR_BASE_H */