diff --git a/ompi/mca/rcache/rb/.ompi_ignore b/ompi/mca/rcache/rb/.ompi_ignore deleted file mode 100644 index 60bf58b271..0000000000 --- a/ompi/mca/rcache/rb/.ompi_ignore +++ /dev/null @@ -1 +0,0 @@ -quilt diff --git a/ompi/mca/rcache/rb/Makefile.am b/ompi/mca/rcache/rb/Makefile.am deleted file mode 100644 index b1ab7f0e77..0000000000 --- a/ompi/mca/rcache/rb/Makefile.am +++ /dev/null @@ -1,54 +0,0 @@ -# -# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana -# University Research and Technology -# Corporation. All rights reserved. -# Copyright (c) 2004-2005 The University of Tennessee and The University -# of Tennessee Research Foundation. 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 (c) 2010 Cisco Systems, Inc. All rights reserved. -# $COPYRIGHT$ -# -# Additional copyrights may follow -# -# $HEADER$ -# - -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__.la (for DSO builds) or libmca__.la -# (for static builds). - -if MCA_BUILD_ompi_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 = $(pkglibdir) -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) diff --git a/ompi/mca/rcache/rb/rcache_rb.c b/ompi/mca/rcache/rb/rcache_rb.c deleted file mode 100644 index 535decad3a..0000000000 --- a/ompi/mca/rcache/rb/rcache_rb.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana - * University Research and Technology - * Corporation. All rights reserved. - * Copyright (c) 2004-2007 The University of Tennessee and The University - * of Tennessee Research Foundation. 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 (c) 2009 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2011-2012 Los Alamos National Security, LLC. - * All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -#include "ompi_config.h" - -#include MCA_memory_IMPLEMENTATION_HEADER -#include "opal/mca/memory/memory.h" -#include "ompi/mca/rcache/rcache.h" -#include "rcache_rb.h" -#include "rcache_rb_tree.h" -#include "rcache_rb_mru.h" -#include "ompi/mca/mpool/base/base.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; - OBJ_CONSTRUCT(&rcache->base.lock, opal_mutex_t); - mca_rcache_rb_tree_init(rcache); - mca_rcache_rb_mru_init(rcache); -} - -int mca_rcache_rb_find( struct mca_rcache_base_module_t* rcache, - void* addr, - size_t size, - opal_pointer_array_t* regs, - uint32_t *cnt ) -{ - int rc = OMPI_SUCCESS; - mca_rcache_rb_tree_item_t* tree_item = NULL; - void* base_addr; - void* bound_addr; - if(size == 0) { - return OMPI_ERROR; - } - OPAL_THREAD_LOCK(&rcache->lock); - *cnt = 0; - - /* Check to ensure that the cache is valid */ - if (OPAL_UNLIKELY(opal_memory_changed() && - NULL != opal_memory->memoryc_process && - OPAL_SUCCESS != (rc = opal_memory->memoryc_process()))) { - return rc; - } - - if(ompi_rb_tree_size(&((mca_rcache_rb_module_t*)rcache)->rb_tree) == 0) { - OPAL_THREAD_UNLOCK(&rcache->lock); - return OMPI_SUCCESS; - } - - base_addr = down_align_addr(addr, mca_mpool_base_page_size_log); - bound_addr = up_align_addr((void*) ((unsigned long) addr + size - 1), mca_mpool_base_page_size_log); - - while(base_addr <= bound_addr) { - tree_item = mca_rcache_rb_tree_find( (mca_rcache_rb_module_t*) rcache, base_addr ); - if(NULL != tree_item) { - opal_pointer_array_add(regs, (void*) tree_item->reg); - if( tree_item->reg->flags & MCA_MPOOL_FLAGS_CACHE ) { - rc = mca_rcache_rb_mru_touch((mca_rcache_rb_module_t*)rcache, - tree_item->reg); - if(OMPI_SUCCESS != rc) { - OPAL_THREAD_UNLOCK(&rcache->lock); - return OMPI_ERROR; - } - } - OPAL_THREAD_ADD32((int32_t*) &tree_item->reg->ref_count, 1); - (*cnt)++; - assert(tree_item->reg->bound - tree_item->reg->base >= 0); - assert(((void*) tree_item->reg->bound) >= addr); - base_addr = tree_item->reg->bound + 1; - } - else { - base_addr =(void*) ((unsigned long) base_addr + mca_mpool_base_page_size); - } - } - - OPAL_THREAD_UNLOCK(&rcache->lock); - return OMPI_SUCCESS; -} - -int mca_rcache_rb_insert ( - struct mca_rcache_base_module_t* rcache, - mca_mpool_base_registration_t* reg, - uint32_t flags - ) -{ - int rc; - - OPAL_THREAD_LOCK(&rcache->lock); - reg->flags = flags; - - /* Check to ensure that the cache is valid */ - if (OPAL_UNLIKELY(opal_memory_changed() && - NULL != opal_memory->memoryc_process && - OPAL_SUCCESS != (rc = opal_memory->memoryc_process()))) { - return rc; - } - - if(flags & MCA_MPOOL_FLAGS_CACHE) { - rc = mca_rcache_rb_mru_insert( (mca_rcache_rb_module_t*) rcache, reg); - if(OMPI_SUCCESS != rc) { - if(OMPI_ERR_TEMP_OUT_OF_RESOURCE == rc) { - /* - * If the registration is too big for the rcache, - * don't cache it and reset the flags so the upper level - * handles things appropriately - */ - reg->flags = 0; - rc = OMPI_SUCCESS; - } - OPAL_THREAD_UNLOCK(&rcache->lock); - return rc; - } - OPAL_THREAD_ADD32((int32_t*)®->ref_count, 1); - } - rc = mca_rcache_rb_tree_insert((mca_rcache_rb_module_t*)rcache, reg); - OPAL_THREAD_ADD32((int32_t*) ®->ref_count, 1); - - if (OPAL_LIKELY(OMPI_SUCCESS == rc)) { - /* If we successfully registered, then tell the memory manager - to start monitoring this region */ - opal_memory->memoryc_register(reg->base, - (uint64_t) reg->bound - reg->base + 1, - (uint64_t) reg); - } - - OPAL_THREAD_UNLOCK(&rcache->lock); - return rc; -} - -int mca_rcache_rb_delete ( - struct mca_rcache_base_module_t* rcache, - mca_mpool_base_registration_t* reg, - uint32_t flags - ) -{ - int rc; - - assert(reg->ref_count >= 1); - OPAL_THREAD_LOCK(&rcache->lock); - /* Tell the memory manager that we no longer care about this - region */ - opal_memory->memoryc_deregister(reg->base, - (uint64_t) (reg->bound - reg->base), - (uint64_t) reg); - if(flags & MCA_MPOOL_FLAGS_CACHE) { - assert(reg->ref_count >= 2); - OPAL_THREAD_ADD32((int32_t*)®->ref_count, -1); - rc = mca_rcache_rb_mru_delete( (mca_rcache_rb_module_t*) rcache, reg); - if(OMPI_SUCCESS != rc) { - OPAL_THREAD_UNLOCK(&rcache->lock); - return rc; - } - } - reg->flags = 0; - OPAL_THREAD_ADD32((int32_t*)®->ref_count, -1); - rc = mca_rcache_rb_tree_delete((mca_rcache_rb_module_t*)rcache, reg ); - OPAL_THREAD_UNLOCK(&rcache->lock); - return rc; -} - - - -/** - * finalize - */ -void mca_rcache_rb_finalize( - struct mca_rcache_base_module_t* rcache - ) -{ -} - diff --git a/ompi/mca/rcache/rb/rcache_rb.h b/ompi/mca/rcache/rb/rcache_rb.h deleted file mode 100644 index 7a1d7883ac..0000000000 --- a/ompi/mca/rcache/rb/rcache_rb.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C; c-basic-offset:4 ; -*- */ -/** - * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana - * University Research and Technology - * Corporation. All rights reserved. - * Copyright (c) 2004-2007 The University of Tennessee and The University - * of Tennessee Research Foundation. 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 "ompi_config.h" -#include "opal/mca/mca.h" -#include "opal/class/opal_list.h" -#include "ompi/class/ompi_rb_tree.h" -#include "ompi/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_list_t mru_list; - size_t reg_mru_len; - size_t reg_max_mru_size; - size_t reg_cur_mru_size; - -}; -typedef struct mca_rcache_rb_module_t mca_rcache_rb_module_t; - - -struct mca_rcache_rb_component_t { - mca_rcache_base_component_t super; -}; -typedef struct mca_rcache_rb_component_t mca_rcache_rb_component_t; - -OMPI_MODULE_DECLSPEC extern mca_rcache_rb_component_t mca_rcache_rb_component; - -void mca_rcache_rb_module_init( mca_rcache_rb_module_t* rcache ); - -int mca_rcache_rb_find( mca_rcache_base_module_t* rcache, - void* addr, - size_t size, - opal_pointer_array_t* regs, - uint32_t *cnt ); - -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 ); - - -/** - * init/finalize - */ - -void mca_rcache_rb_module_init( mca_rcache_rb_module_t* rcache ); - -void mca_rcache_rb_finalize( struct mca_rcache_base_module_t* ); - -#endif /* MCA_RCACHE_RB_H */ - diff --git a/ompi/mca/rcache/rb/rcache_rb_component.c b/ompi/mca/rcache/rb/rcache_rb_component.c deleted file mode 100644 index d3035d76a5..0000000000 --- a/ompi/mca/rcache/rb/rcache_rb_component.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana - * University Research and Technology - * Corporation. All rights reserved. - * Copyright (c) 2004-2006 The University of Tennessee and The University - * of Tennessee Research Foundation. 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 "ompi_config.h" - -#include "ompi/mca/rcache/rcache.h" -#include "rcache_rb.h" - -static int mca_rcache_rb_component_register(void); -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 = { - { - { - MCA_RCACHE_BASE_VERSION_2_0_0, - - "rb", /* 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, /* component close */ - NULL, /* component query */ - mca_rcache_rb_component_register - }, - { - /* The component is checkpoint ready */ - MCA_BASE_METADATA_PARAM_CHECKPOINT - }, - mca_rcache_rb_component_init - } -}; - -static int ompi_rcache_rb_reg_mru_len; -static int ompi_rcache_rb_mru_size; - -static int mca_rcache_rb_component_register(void) -{ - ompi_rcache_rb_reg_mru_len = 256; - (void) mca_base_component_var_register(&mca_rcache_rb_component.super.rcache_version, - "mru_len", - "The maximum size IN ENTRIES of the MRU (most recently used) rcache list", - MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, - OPAL_INFO_LVL_9, - MCA_BASE_VAR_SCOPE_READONLY, - &ompi_rcache_rb_reg_mru_len); - - ompi_rcache_rb_mru_size = 1*1024*1024*1024; /* default to 1GB? */ - (void) mca_base_component_var_register(&mca_rcache_rb_component.super.rcache_version, - "mru_size", - "The maximum size IN BYTES of the MRU (most recently used) rcache list", - MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, - OPAL_INFO_LVL_9, - MCA_BASE_VAR_SCOPE_READONLY, - &ompi_rcache_rb_mru_size); - - return OMPI_SUCCESS; -} - -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); - - rcache->reg_mru_len = (size_t) ompi_rcache_rb_reg_mru_len; - rcache->reg_max_mru_size = (size_t) ompi_rcache_rb_mru_size; - - return &rcache->base; -} - - diff --git a/ompi/mca/rcache/rb/rcache_rb_mru.c b/ompi/mca/rcache/rb/rcache_rb_mru.c deleted file mode 100644 index 98d9ae5358..0000000000 --- a/ompi/mca/rcache/rb/rcache_rb_mru.c +++ /dev/null @@ -1,128 +0,0 @@ -/** - * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana - * University Research and Technology - * Corporation. All rights reserved. - * Copyright (c) 2004-2006 The University of Tennessee and The University - * of Tennessee Research Foundation. 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 "ompi_config.h" - -#include "opal/mca/mca.h" -#include "rcache_rb_mru.h" -#include "ompi/mca/mpool/mpool.h" - -/* - * initialize the rb mru - */ -int mca_rcache_rb_mru_init(mca_rcache_rb_module_t* rcache){ - OBJ_CONSTRUCT(&rcache->mru_list, opal_list_t); - rcache->reg_cur_mru_size = 0; - return OMPI_SUCCESS; -} - -/* - * 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 - - ) { - mca_mpool_base_registration_t* old_reg; - size_t reg_size = reg->bound - reg->base + 1; - - if(reg_size > rcache->reg_max_mru_size) { - return OMPI_ERR_TEMP_OUT_OF_RESOURCE; - } - - rcache->reg_cur_mru_size += reg_size; - - if(rcache->reg_mru_len <= rcache->mru_list.opal_list_length) { - /* call deregister - which removes the registration from - * the tree and mru list. memory will be deregistered when - * the reference count goes to zero. - */ - old_reg = (mca_mpool_base_registration_t*) - opal_list_get_first(&rcache->mru_list); - /* we need to retain first, because we only want the registration - removed from the tree and the mru */ - old_reg->mpool->mpool_retain(old_reg->mpool, old_reg); - old_reg->mpool->mpool_deregister(old_reg->mpool, old_reg); - - } - - while(rcache->reg_max_mru_size <= rcache->reg_cur_mru_size) { - old_reg = (mca_mpool_base_registration_t*) - opal_list_get_first(&rcache->mru_list); - /* we need to retain first, because we only want the registration - removed from the tree and the mru we didn't get this registration - using mpool_find so the refernce count wasn't bumped up.*/ - old_reg->mpool->mpool_retain(old_reg->mpool, old_reg); - old_reg->mpool->mpool_deregister(old_reg->mpool, old_reg); - - } - - opal_list_append(&rcache->mru_list,(opal_list_item_t*) reg); - - return OMPI_SUCCESS; -} - -/* - * 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 - ){ - int rc; - if(NULL == opal_list_remove_item( - &rcache->mru_list, - (opal_list_item_t*) reg - )) { - rc = OMPI_ERROR; - } else { - rcache->reg_cur_mru_size -= (reg->bound - reg->base + 1); - rc = OMPI_SUCCESS; - } - return rc; -} - -/* - * touch an item in the mru list - */ -int mca_rcache_rb_mru_touch( - mca_rcache_rb_module_t* rcache, - mca_mpool_base_registration_t* reg - ){ - int rc; - 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; - } - return rc; -} - - - - diff --git a/ompi/mca/rcache/rb/rcache_rb_mru.h b/ompi/mca/rcache/rb/rcache_rb_mru.h deleted file mode 100644 index 0dffd3592b..0000000000 --- a/ompi/mca/rcache/rb/rcache_rb_mru.h +++ /dev/null @@ -1,57 +0,0 @@ - -/** - * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana - * University Research and Technology - * Corporation. All rights reserved. - * Copyright (c) 2004-2005 The University of Tennessee and The University - * of Tennessee Research Foundation. 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 "opal/mca/mca.h" -#include "rcache_rb.h" - - - -/* - * initialize the rb mru - */ -int mca_rcache_rb_mru_init(mca_rcache_rb_module_t* rcache); - -/* - * 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 - ); - -int mca_rcache_rb_mru_touch( - mca_rcache_rb_module_t* rcache, - mca_mpool_base_registration_t* reg - ); - -#endif /* MCA_RCACHE_RB_MRU_H */ - diff --git a/ompi/mca/rcache/rb/rcache_rb_tree.c b/ompi/mca/rcache/rb/rcache_rb_tree.c deleted file mode 100644 index 0cdbcdfc45..0000000000 --- a/ompi/mca/rcache/rb/rcache_rb_tree.c +++ /dev/null @@ -1,166 +0,0 @@ -/** - * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana - * University Research and Technology - * Corporation. All rights reserved. - * Copyright (c) 2004-2013 The University of Tennessee and The University - * of Tennessee Research Foundation. 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.5A - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ -/** - * @file - * Description of the Registration Cache framework - */ - -#include "ompi_config.h" - -#include "opal/mca/mca.h" -#include "rcache_rb_tree.h" - - -OBJ_CLASS_INSTANCE(mca_rcache_rb_tree_item_t, ompi_free_list_item_t, NULL, NULL); - - -int mca_rcache_rb_tree_node_compare(void * key1, void * key2); - -int mca_rcache_rb_tree_init(mca_rcache_rb_module_t* rcache) { - OBJ_CONSTRUCT(&rcache->rb_tree, ompi_rb_tree_t); - OBJ_CONSTRUCT(&rcache->rb_tree_item_list, ompi_free_list_t); - ompi_free_list_init_new(&rcache->rb_tree_item_list, - sizeof(mca_rcache_rb_tree_item_t), - opal_cache_line_size, - OBJ_CLASS(mca_rcache_rb_tree_item_t), - 0,opal_cache_line_size, - 0, -1, 32, NULL); - - return ompi_rb_tree_init(&rcache->rb_tree, - mca_rcache_rb_tree_node_compare); -} - -/** - * 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* rcache, - void * base - ) -{ - mca_rcache_rb_tree_item_t* found = NULL; - mca_rcache_rb_tree_key_t key; - - - key.base = base; - key.bound = base; - found = (mca_rcache_rb_tree_item_t *) - ompi_rb_tree_find(&rcache->rb_tree, &key); - if(found) { - assert((void*)found->reg->bound >= base); - } - return found; -} - -/** - * 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 - ) -{ - ompi_free_list_item_t *item; - int rc; - mca_rcache_rb_tree_item_t* rb_tree_item; - - OMPI_FREE_LIST_GET_MT(&rb_module->rb_tree_item_list, item); - if(NULL == item) { - return OMPI_ERR_OUT_OF_RESOURCE; - } - 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; - - rc = ompi_rb_tree_insert(&rb_module->rb_tree, - (void*) &rb_tree_item->key, item); - - if(OMPI_SUCCESS != rc) { - OMPI_FREE_LIST_RETURN_MT(&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; - } - assert(reg == tree_item->reg); - rc = ompi_rb_tree_delete(&rb_module->rb_tree, &tree_item->key); - - OMPI_FREE_LIST_RETURN_MT(&rb_module->rb_tree_item_list, - (ompi_free_list_item_t*) tree_item); - - return rc; -} - - diff --git a/ompi/mca/rcache/rb/rcache_rb_tree.h b/ompi/mca/rcache/rb/rcache_rb_tree.h deleted file mode 100644 index 039346911b..0000000000 --- a/ompi/mca/rcache/rb/rcache_rb_tree.h +++ /dev/null @@ -1,88 +0,0 @@ - -/** - * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana - * University Research and Technology - * Corporation. All rights reserved. - * Copyright (c) 2004-2006 The University of Tennessee and The University - * of Tennessee Research Foundation. 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 "ompi_config.h" -#include "opal/mca/mca.h" -#include "ompi/class/ompi_free_list.h" -#include "ompi/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 -{ - ompi_free_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; - -OMPI_DECLSPEC OBJ_CLASS_DECLARATION(mca_rcache_rb_tree_item_t); - -/* - * initialize the rb tree - */ -int mca_rcache_rb_tree_init(mca_rcache_rb_module_t* rcache); - -/** - * 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 */ -