1
1
This commit was SVN r7174.
Этот коммит содержится в:
Galen Shipman 2005-09-04 04:17:00 +00:00
родитель 492aeecd11
Коммит 2314919b73
13 изменённых файлов: 991 добавлений и 0 удалений

33
ompi/mca/rcache/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,33 @@
#
# Copyright (c) 2004-2005 The Trustees of Indiana University.
# All rights reserved.
# Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
# 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$
#
# Additional copyrights may follow
#
# $HEADER$
#
include $(top_srcdir)/config/Makefile.options
SUBDIRS = base $(MCA_rcache_STATIC_SUBDIRS)
DIST_SUBDIRS = base $(MCA_rcache_ALL_SUBDIRS)
# Source code files
headers = rcache.h
# Conditionally install the header files
if WANT_INSTALL_HEADERS
ompidir = $(includedir)/openmpi/opal/mca/rcache
ompi_HEADERS = $(headers)
else
ompidir = $(includedir)
endif

44
ompi/mca/rcache/base/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,44 @@
#
# Copyright (c) 2004-2005 The Trustees of Indiana University.
# All rights reserved.
# Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
# 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$
#
# Additional copyrights may follow
#
# $HEADER$
#
include $(top_srcdir)/config/Makefile.options
noinst_LTLIBRARIES = libmca_rcache_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_rcache_base_la_SOURCES = \
$(headers)
# Conditionally install the header files
if WANT_INSTALL_HEADERS
ompidir = $(includedir)/openmpi/mca/rcache/base
ompi_HEADERS = $(headers)
else
ompidir = $(includedir)
endif
distclean-local:
rm -f static-components.h

125
ompi/mca/rcache/base/base.h Обычный файл
Просмотреть файл

@ -0,0 +1,125 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* 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$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*/
#ifndef MCA_MEM_BASE_H
#define MCA_MEM_BASE_H
#include "ompi_config.h"
#include "opal/class/opal_list.h"
#include "class/ompi_rb_tree.h"
#include "mca/mca.h"
#include "mca/mpool/mpool.h"
#include "opal/threads/mutex.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
struct mca_mpool_base_selected_module_t {
opal_list_item_t super;
mca_mpool_base_component_t *mpool_component;
mca_mpool_base_module_t *mpool_module;
void* user_data;
struct mca_mpool_base_resources_t *mpool_resources;
};
typedef struct mca_mpool_base_selected_module_t mca_mpool_base_selected_module_t;
OBJ_CLASS_DECLARATION(mca_mpool_base_selected_module_t);
/*
* Data structures for the tree of allocated memory
*/
/**
* The maximum number of mpools a chunk of memorry can be registered with
*/
#define MCA_MPOOL_BASE_MAX_REG 8
/**
* Holds the key for the tree
*/
struct mca_mpool_base_key_t
{
void * bottom; /**< the bottom of the memory range */
void * top; /**< the top of the memory range */
};
typedef struct mca_mpool_base_key_t mca_mpool_base_key_t;
/**
* Holds a pointer to the mpool the memory is registered with and
* a user pointer for mpool specific information
*/
struct mca_mpool_base_reg_mpool_t
{
mca_mpool_base_module_t * mpool; /**< the registered memory pool */
void* user_data; /**< user data */
mca_mpool_base_registration_t* mpool_registration; /**< mpool specific info associated w/ registration */
};
typedef struct mca_mpool_base_reg_mpool_t mca_mpool_base_reg_mpool_t;
/**
* Holds all the information about a chunk of registered memory. The whole
* structure serves as a value in the tree
*/
struct mca_mpool_base_chunk_t
{
opal_list_item_t super; /**< the parent class */
mca_mpool_base_key_t key; /**< the key which holds the memory pointers */
mca_mpool_base_reg_mpool_t mpools[MCA_MPOOL_BASE_MAX_REG];
/**< the mpools the memory is registered with */
};
typedef struct mca_mpool_base_chunk_t mca_mpool_base_chunk_t;
OBJ_CLASS_DECLARATION(mca_mpool_base_chunk_t);
/**
* Returns a copy of the chunk.
*/
mca_mpool_base_chunk_t* mca_mpool_base_find(void* base);
/*
* Global functions for MCA: overall mpool open and close
*/
OMPI_DECLSPEC int mca_mpool_base_open(void);
OMPI_DECLSPEC int mca_mpool_base_init(bool enable_progress_threads, bool enable_mpi_threads);
OMPI_DECLSPEC int mca_mpool_base_close(void);
OMPI_DECLSPEC mca_mpool_base_component_t* mca_mpool_base_component_lookup(const char* name);
OMPI_DECLSPEC mca_mpool_base_module_t* mca_mpool_base_module_create(
const char* name,
void* user_data,
struct mca_mpool_base_resources_t* mpool_resources);
OMPI_DECLSPEC mca_mpool_base_module_t* mca_mpool_base_module_lookup(const char* name);
/*
* Globals
*/
OMPI_DECLSPEC extern int mca_mpool_base_output;
OMPI_DECLSPEC extern opal_list_t mca_mpool_base_components;
OMPI_DECLSPEC extern opal_list_t mca_mpool_base_modules;
OMPI_DECLSPEC extern ompi_free_list_t mca_mpool_base_mem_list;
OMPI_DECLSPEC extern ompi_rb_tree_t mca_mpool_base_tree;
OMPI_DECLSPEC extern opal_mutex_t mca_mpool_base_tree_lock;
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif /* MCA_MEM_BASE_H */

58
ompi/mca/rcache/rb/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,58 @@
#
# Copyright (c) 2004-2005 The Trustees of Indiana University.
# All rights reserved.
# Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
# 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$
#
# Additional copyrights may follow
#
# $HEADER$
#
# Use the top-level Makefile.options
include $(top_ompi_srcdir)/config/Makefile.options
CFLAGS = $(rcache_rb_CFLAGS)
AM_CPPFLAGS = $(rcache_rb_CPPFLAGS)
sources = \
rcache_rb.c \
rcache_rb.h \
rcache_rb_component.c \
rcache_rb_tree.c \
rcache_rb_tree.h \
rcache_rb_mru.c \
rcache_rb_mru.h
# 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 OMPI_BUILD_rcache_rb_DSO
lib =
lib_sources =
component = mca_rcache_rb.la
component_sources = $(sources)
else
lib = libmca_rcache_rb.la
lib_sources = $(sources)
component =
component_sources =
endif
mcacomponentdir = $(libdir)/openmpi
mcacomponent_LTLIBRARIES = $(component)
mca_rcache_rb_la_SOURCES = $(component_sources)
mca_rcache_rb_la_LDFLAGS = -module -avoid-version $(rcache_rb_LDFLAGS)
mca_rcache_rb_la_LIBADD = $(rcache_rb_LIBS)
noinst_LTLIBRARIES = $(lib)
libmca_rcache_rb_la_SOURCES = $(lib_sources)
libmca_rcache_rb_la_LDFLAGS = -module -avoid-version$ $(rcache_rb_LDFLAGS)
libmca_rcache_rb_la_LIBADD = $(rcache_rb_LIBS)

20
ompi/mca/rcache/rb/configure.params Обычный файл
Просмотреть файл

@ -0,0 +1,20 @@
# -*- shell-script -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University.
# All rights reserved.
# Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
# 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$
#
# Additional copyrights may follow
#
# $HEADER$
#
# Specific to this module
PARAM_CONFIG_FILES="Makefile"

106
ompi/mca/rcache/rb/rcache_rb.c Обычный файл
Просмотреть файл

@ -0,0 +1,106 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* 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$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "mca/rcache/rcache.h"
#include "rcache_rb.h"
#include "rcache_rb_tree.h"
#include "rcache_rb_mru.h"
/**
* Initialize the rcache
*/
void mca_rcache_rb_module_init( mca_rcache_rb_module_t* rcache ) {
rcache->base.rcache_find = mca_rcache_rb_find;
rcache->base.rcache_insert = mca_rcache_rb_insert;
rcache->base.rcache_delete = mca_rcache_rb_delete;
rcache->base.rcache_finalize = mca_rcache_rb_finalize;
}
int mca_rcache_rb_find (
struct mca_rcache_base_module_t* rcache,
void* addr,
size_t size,
ompi_pointer_array_t* regs
){
int rc;
mca_rcache_rb_tree_item_t* tree_item;
tree_item = mca_rcache_rb_tree_find( (mca_rcache_rb_module_t*) rcache, addr );
if(NULL == tree_item) {
return OMPI_ERROR;
}
rc = ompi_pointer_array_add(regs, (void*) tree_item->reg);
if(OMPI_SUCCESS != rc) {
return rc;
}
if( !(tree_item->reg->flags & MCA_MPOOL_FLAGS_PERSIST) ) {
rc = mca_rcache_base_mru_touch(rcache, tree_item->reg);
}
OPAL_THREAD_ADD32(&tree_item->reg->ref_count, 1);
return rc;
}
int mca_rcache_rb_insert (
struct mca_rcache_base_module_t* rcache,
mca_mpool_base_registration_t* reg,
uint32_t flags
) {
int rc;
if(!(flags & MCA_MPOOL_FLAGS_PERSIST)) {
rc = mca_rcache_rb_mru_insert( (mca_rcache_rb_module_t*) rcache, reg);
}
if(OMPI_SUCCESS != rc) {
return rc;
}
mca_rcache_rb_tree_insert((mca_rcache_rb_module_t*)rcache, reg );
OPAL_THREAD_ADD32(&reg->ref_count, 1);
}
int mca_rcache_rb_delete (
struct mca_rcache_base_module_t* rcache,
mca_mpool_base_registration_t* reg,
uint32_t flags
) {
int rc;
if(!(flags & MCA_MPOOL_FLAGS_PERSIST)) {
rc = mca_rcache_rb_mru_delete( (mca_rcache_rb_module_t*) rcache, reg);
}
if(OMPI_SUCCESS != rc) {
return rc;
}
return mca_rcache_rb_tree_delete((mca_rcache_rb_module_t*)rcache, reg );
}
/**
* finalize
*/
void mca_rcache_rb_finalize(
struct mca_rcache_base_module_t* rcache
) {
}

78
ompi/mca/rcache/rb/rcache_rb.h Обычный файл
Просмотреть файл

@ -0,0 +1,78 @@
/**
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* 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$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
* Description of the Registration Cache framework
*/
#ifndef MCA_RCACHE_RB_H
#define MCA_RCACHE_RB_H
#include "mca/mca.h"
#include "info/info.h"
#include "opal/class/opal_list.h"
#include "class/ompi_rb_tree.h"
#include "opal/threads/mutex.h"
#include "mca/rcache/rcache.h"
struct mca_rcache_rb_module_t {
mca_rcache_base_module_t base;
ompi_rb_tree_t rb_tree;
ompi_free_list_t rb_tree_item_list;
opal_mutex_t rb_lock;
opal_list_t mru_list;
size_t reg_mru_len;
};
typedef struct mca_rcache_rb_module_t mca_rcache_rb_module_t;
typedef mca_rcache_base_component_t mca_rcache_rb_component_t;
int mca_rcache_rb_find (
mca_rcache_base_module_t* rcache,
void* addr,
size_t size,
ompi_pointer_array_t* regs
);
int mca_rcache_rb_insert (
struct mca_rcache_base_module_t* rcache,
mca_mpool_base_registration_t* registration,
uint32_t flags
);
int mca_rcache_rb_delete (
struct mca_rcache_base_module_t* rcache,
mca_mpool_base_registration_t* registration,
uint32_t flags
);
/**
* finalize
*/
void mca_rcache_rb_finalize(
struct mca_rcache_base_module_t*
);
#endif /* MCA_RCACHE_H */

44
ompi/mca/rcache/rb/rcache_rb_component.c Обычный файл
Просмотреть файл

@ -0,0 +1,44 @@
#include "mca/rcache/rcache.h"
#include "rcache_rb.h"
static int mca_rcache_rb_component_open(void);
static mca_rcache_base_module_t* mca_rcache_rb_component_init( void );
mca_rcache_rb_component_t mca_rcache_rb_component = {
{
/* Indicate that we are a rcache v1.0.0 component (which also
implies a specific MCA version) */
MCA_RCACHE_BASE_VERSION_1_0_0,
"rcache", /* MCA component name */
OMPI_MAJOR_VERSION, /* MCA component major version */
OMPI_MINOR_VERSION, /* MCA component minor version */
OMPI_RELEASE_VERSION, /* MCA component release version */
mca_rcache_rb_component_open, /* component open */
NULL
},
/* Next the MCA v1.0.0 component meta data */
{
/* Whether the component is checkpointable or not */
false
},
mca_rcache_rb_component_init
};
static int mca_rcache_rb_component_open(void)
{
return OMPI_SUCCESS;
}
mca_rcache_base_module_t* mca_rcache_rb_component_init(void) {
mca_rcache_rb_module_t* rcache;
rcache = (mca_rcache_rb_module_t*) malloc(sizeof(mca_rcache_rb_module_t));
mca_rcache_rb_module_init(rcache);
return &rcache->base;
}

91
ompi/mca/rcache/rb/rcache_rb_mru.c Обычный файл
Просмотреть файл

@ -0,0 +1,91 @@
/**
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* 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$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
* Description of the Registration Cache framework
*/
#include "mca/mca.h"
#include "rcache_rb_mru.h"
#include "mca/mpool/mpool.h"
/*
* insert an item in the rb mru
*/
int mca_rcache_base_mru_insert(
mca_rcache_rb_module_t* rcache,
mca_mpool_base_registration_t* reg
) {
OPAL_THREAD_LOCK(&rcache->rb_lock);
if(rcache->reg_mru_len <= rcache->mru_list.opal_list_length) {
mca_mpool_base_registration_t* old_reg =
(mca_mpool_base_registration_t*)
opal_list_remove_last(&rcache->mru_list);
/* need to pull out of rb tree here */
}
opal_list_append(&rcache->mru_list,(opal_list_item_t*) reg);
OPAL_THREAD_UNLOCK(&rcache->rb_lock);
return OMPI_SUCCESS;
}
/*
* remove an item from
the rb mru
*/
int mca_rcache_base_mru_delete(
mca_rcache_rb_module_t* rcache,
mca_mpool_base_registration_t *reg
){
int rc;
OPAL_THREAD_LOCK(&rcache->rb_lock);
if(NULL == opal_list_remove_item(
&rcache->mru_list,
(opal_list_item_t*) reg
)) {
rc = OMPI_ERROR;
} else {
rc = OMPI_SUCCESS;
}
OPAL_THREAD_UNLOCK(&rcache->rb_lock);
return rc;
}
/*
* touch an item in the mru list
*/
int mca_rcache_base_mru_touch(
mca_rcache_rb_module_t* rcache,
mca_mpool_base_registration_t* reg
){
int rc;
OPAL_THREAD_LOCK(rcache->rb_lock);
if(NULL == opal_list_remove_item(
&rcache->mru_list,
(opal_list_item_t*) reg
)) {
rc = OMPI_ERROR;
} else {
opal_list_append(&rcache->mru_list, (opal_list_item_t*) reg);
rc = OMPI_SUCCESS;
}
OPAL_THREAD_UNLOCK(rcache->rb_lock);
return rc;
}

45
ompi/mca/rcache/rb/rcache_rb_mru.h Обычный файл
Просмотреть файл

@ -0,0 +1,45 @@
/**
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* 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$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
* Description of the Registration Cache framework
*/
#ifndef MCA_RCACHE_RB_MRU_H
#define MCA_RCACHE_RB_MRU_H
#include "mca/mca.h"
#include "info/info.h"
#include "opal/class/opal_list.h"
#include "rcache_rb.h"
/*
* insert an item in the rb mru
*/
int mca_rcache_rb_mru_insert(
mca_rcache_rb_module_t* rcache,
mca_mpool_base_registration_t* reg
);
/*
* remove an item from the rb mru
*/
int mca_rcache_rb_mru_delete(
mca_rcache_rb_module_t* rcache,
mca_mpool_base_registration_t* reg
);
#endif /* MCA_RCACHE_RB_MRU_H */

163
ompi/mca/rcache/rb/rcache_rb_tree.c Обычный файл
Просмотреть файл

@ -0,0 +1,163 @@
/**
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* 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$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
* Description of the Registration Cache framework
*/
#include "mca/mca.h"
#include "rcache_rb_tree.h"
/**
* Searches the rcache to see if it has allocated the memory that is passed in.
* If so it returns an array of rcaches the memory is registered with.
*
* @param base pointer to the memory to lookup
*
* @retval NULL if the memory is not in any rcache
* @retval pointer to an array of type mca_rcache_base_reg_rcache_t
*/
static inline struct mca_rcache_rb_tree_item_t *
mca_rcache_rb_tree_find_nl(
mca_rcache_rb_module_t* rcache,
void* base
)
{
mca_rcache_rb_tree_key_t key;
key.base = base;
key.bound = base;
return (mca_rcache_rb_tree_item_t *)
ompi_rb_tree_find(&rcache->rb_tree, &key);
}
/**
* Searches the mpool to see if it has allocated the memory that is passed in.
* If so it returns an array of mpools the memory is registered with.
*
* @param base pointer to the memory to lookup
*
* @retval NULL if the memory is not in any mpool
* @retval pointer to an array of type mca_mpool_base_reg_mpool_t
*/
struct mca_rcache_rb_tree_item_t * mca_rcache_rb_tree_find(
mca_rcache_rb_module_t* rb_module,
void * base
)
{
mca_rcache_rb_tree_item_t* found, *copy;
OPAL_THREAD_LOCK(&rb_module->tree_lock);
found = mca_rcache_rb_tree_find_nl(rb_module, base);
if(NULL == found) {
copy = NULL;
} else {
copy = OBJ_NEW(mca_rcache_rb_tree_item_t);
*copy = *found;
}
OPAL_THREAD_UNLOCK(&mca_mpool_base_tree_lock);
return copy;
}
/**
* Memory Pool Registration
*/
/**
* Function for the red black tree to compare 2 keys
*
* @param key1 a pointer to the 1st key
* @param key2 a pointer to the second key
*
* @retval -1 if key1 is below key2
* @retval 1 if key 1 is above key2
* @retval 0 if the keys are the same
*/
int mca_rcache_rb_tree_node_compare(void * key1, void * key2)
{
if(((mca_rcache_rb_tree_key_t *) key1)->base <
((mca_rcache_rb_tree_key_t *) key2)->base)
{
return -1;
}
else if(((mca_rcache_rb_tree_key_t *) key1)->base >
((mca_rcache_rb_tree_key_t *) key2)->bound)
{
return 1;
}
else
{
return 0;
}
}
int mca_rcache_rb_tree_insert(
mca_rcache_rb_module_t* rb_module,
mca_mpool_base_registration_t* reg
)
{
opal_list_item_t *item;
int rc;
mca_rcache_rb_tree_item_t* rb_tree_item;
OMPI_FREE_LIST_GET(&rb_module->rb_tree_item_list, item, rc);
if(rc != OMPI_SUCCESS)
return rc;
rb_tree_item = (mca_rcache_rb_tree_item_t*) item;
rb_tree_item->key.base = reg->base;
rb_tree_item->key.bound = reg->bound;
rb_tree_item->reg = reg;
OPAL_THREAD_LOCK(&rb_module->rb_lock);
rc = ompi_rb_tree_insert(&rb_module->rb_tree,
(void*) &rb_tree_item->key, item);
OPAL_THREAD_UNLOCK(&rb_module->rb_lock);
if(OMPI_SUCCESS != rc) {
OMPI_FREE_LIST_RETURN(&rb_module->rb_tree_item_list, item);
return rc;
}
return OMPI_SUCCESS;
}
/**
* Function to remove previously memory from the tree without freeing it
*
* @param base pointer to the memory to free
*
* @retval OMPI_SUCCESS
* @retval OMPI_ERR_BAD_PARAM if the passed base pointer was invalid
*/
int mca_rcache_rb_tree_delete(mca_rcache_rb_module_t* rb_module,
mca_mpool_base_registration_t* reg)
{
int rc;
mca_rcache_rb_tree_item_t* tree_item;
tree_item = mca_rcache_rb_tree_find(rb_module,
reg->base);
if(NULL == tree_item) {
return OMPI_ERROR;
}
OPAL_THREAD_LOCK(&rb_module->rb_lock);
rc = ompi_rb_tree_delete(&rb_module->rb_tree, &tree_item->key);
OPAL_THREAD_UNLOCK(&rb_module->rb_lock);
return rc;
}

80
ompi/mca/rcache/rb/rcache_rb_tree.h Обычный файл
Просмотреть файл

@ -0,0 +1,80 @@
/**
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* 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$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
* Description of the Registration Cache framework
*/
#ifndef MCA_RCACHE_RB_TREE_H
#define MCA_RCACHE_RB_TREE_H
#include "mca/mca.h"
#include "info/info.h"
#include "opal/class/opal_list.h"
#include "mca/mpool/mpool.h"
#include "rcache_rb.h"
/*
* Data structures for the tree of allocated memory
*/
/**
* Holds the key for the tree
*/
struct mca_rcache_rb_tree_key_t
{
void * base; /**< the base of the memory range */
void * bound; /**< the bound of the memory range */
};
typedef struct mca_rcache_rb_tree_key_t mca_rcache_rb_tree_key_t;
/**
* The item in the rb_tree itself
*/
struct mca_rcache_rb_tree_item_t
{
opal_list_item_t super; /**< the parent class */
mca_rcache_rb_tree_key_t key; /**< the key which holds the memory pointers */
mca_mpool_base_registration_t* reg; /**< the registration */
};
typedef struct mca_rcache_rb_tree_item_t mca_rcache_rb_tree_item_t;
OBJ_CLASS_DECLARATION(mca_rcache_rb_tree_item_t);
/**
* Returns the item in the rb tree
*/
mca_rcache_rb_tree_item_t* mca_rcache_rb_tree_find(
mca_rcache_rb_module_t* rcache,
void* base
);
/*
* insert an item in the rb tree
*/
int mca_rcache_rb_tree_insert(
mca_rcache_rb_module_t* rcache,
mca_mpool_base_registration_t* reg
);
/*
* remove an item from the rb tree
*/
int mca_rcache_rb_tree_delete(
mca_rcache_rb_module_t* rcache,
mca_mpool_base_registration_t* reg
);
#endif /* MCA_RCACHE_RB_TREE_H */

104
ompi/mca/rcache/rcache.h Обычный файл
Просмотреть файл

@ -0,0 +1,104 @@
/**
* Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* 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$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
* Description of the Registration Cache framework
*/
#ifndef MCA_RCACHE_H
#define MCA_RCACHE_H
#include "mca/mca.h"
#include "info/info.h"
#include "opal/class/opal_list.h"
#include "mca/mpool/mpool.h"
/**
* component initialize
*/
typedef struct mca_rcache_base_module_t* (*mca_rcache_base_component_init_fn_t)(void);
typedef int (*mca_rcache_base_module_find_fn_t) (
struct mca_rcache_base_module_t* rcache,
void* addr,
size_t size,
ompi_pointer_array_t *regs
);
typedef int (*mca_rcache_base_module_insert_fn_t)(
struct mca_rcache_base_module_t* rcache,
mca_mpool_base_registration_t* registration,
uint32_t flags
);
typedef int (*mca_rcache_base_module_delete_fn_t) (
struct mca_rcache_base_module_t* rcache,
mca_mpool_base_registration_t* registration,
uint32_t flags
);
/**
* finalize
*/
typedef void (*mca_rcache_base_module_finalize_fn_t)(
struct mca_rcache_base_module_t*
);
/**
* rcache component descriptor. Contains component version information and
* open/close/init functions
*/
struct mca_rcache_base_component_1_0_0_t{
mca_base_component_t rcache_version; /**< version */
mca_base_component_data_1_0_0_t rcache_data; /**<metadata */
mca_rcache_base_component_init_fn_t rcache_init; /**<init function */
};
typedef struct mca_rcache_base_component_1_0_0_t mca_rcache_base_component_1_0_0_t;
typedef struct mca_rcache_base_component_1_0_0_t mca_rcache_base_component_t;
/**
* rcache module descriptor
*/
struct mca_rcache_base_module_t {
mca_rcache_base_component_t *rcache_component; /**< component struct */
mca_rcache_base_module_find_fn_t rcache_find;
mca_rcache_base_module_insert_fn_t rcache_insert;
mca_rcache_base_module_delete_fn_t rcache_delete;
mca_rcache_base_module_finalize_fn_t rcache_finalize;
};
typedef struct mca_rcache_base_module_t mca_rcache_base_module_t;
/**
* Macro for use in components that are of type rcache v1.0.0
*/
#define MCA_RCACHE_BASE_VERSION_1_0_0 \
/* rcache v1.0 is chained to MCA v1.0 */ \
MCA_BASE_VERSION_1_0_0, \
/* rcache v1.0 */ \
"rcache", 1, 0, 0
#endif /* MCA_RCACHE_H */