2005-09-04 08:17:00 +04:00
|
|
|
/**
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2006-08-24 20:38:08 +04:00
|
|
|
* Copyright (c) 2004-2006 The University of Tennessee and The University
|
2005-11-05 22:57:48 +03:00
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2005-09-04 08:17:00 +04:00
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2006-08-24 20:38:08 +04:00
|
|
|
#include "ompi_config.h"
|
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "opal/mca/mca.h"
|
2005-09-04 08:17:00 +04:00
|
|
|
#include "rcache_rb_mru.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/mca/mpool/mpool.h"
|
2005-09-04 08:17:00 +04:00
|
|
|
|
2005-09-13 02:28:23 +04:00
|
|
|
/*
|
|
|
|
* initialize the rb mru
|
|
|
|
*/
|
|
|
|
int mca_rcache_rb_mru_init(mca_rcache_rb_module_t* rcache){
|
|
|
|
OBJ_CONSTRUCT(&rcache->mru_list, opal_list_t);
|
2006-02-22 17:35:47 +03:00
|
|
|
rcache->reg_cur_mru_size = 0;
|
2005-09-13 02:28:23 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-09-04 08:17:00 +04:00
|
|
|
/*
|
|
|
|
* insert an item in the rb mru
|
|
|
|
*/
|
2005-09-09 01:34:26 +04:00
|
|
|
int mca_rcache_rb_mru_insert(
|
2005-09-04 08:17:00 +04:00
|
|
|
mca_rcache_rb_module_t* rcache,
|
|
|
|
mca_mpool_base_registration_t* reg
|
2005-09-13 02:28:23 +04:00
|
|
|
|
2005-09-04 08:17:00 +04:00
|
|
|
) {
|
2005-09-13 02:28:23 +04:00
|
|
|
mca_mpool_base_registration_t* old_reg;
|
2006-02-22 17:35:47 +03:00
|
|
|
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;
|
|
|
|
|
2005-09-24 04:24:49 +04:00
|
|
|
if(rcache->reg_mru_len <= rcache->mru_list.opal_list_length) {
|
2005-09-22 03:25:16 +04:00
|
|
|
/* call deregister - which removes the registration from
|
|
|
|
* the tree and mru list. memory will be deregistered when
|
|
|
|
* the reference count goes to zero.
|
|
|
|
*/
|
2005-10-01 02:58:09 +04:00
|
|
|
old_reg = (mca_mpool_base_registration_t*)
|
|
|
|
opal_list_get_first(&rcache->mru_list);
|
2005-10-03 20:35:12 +04:00
|
|
|
/* we need to retain first, because we only want the registration
|
|
|
|
removed from the tree and the mru */
|
2005-10-01 02:58:09 +04:00
|
|
|
old_reg->mpool->mpool_retain(old_reg->mpool, old_reg);
|
|
|
|
old_reg->mpool->mpool_deregister(old_reg->mpool, old_reg);
|
|
|
|
|
2005-09-04 08:17:00 +04:00
|
|
|
}
|
2006-02-22 17:35:47 +03:00
|
|
|
|
2006-05-07 05:15:33 +04:00
|
|
|
while(rcache->reg_max_mru_size <= rcache->reg_cur_mru_size) {
|
2006-02-22 17:35:47 +03:00
|
|
|
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
|
2006-05-08 21:42:34 +04:00
|
|
|
removed from the tree and the mru we didn't get this registration
|
|
|
|
using mpool_find so the refernce count wasn't bumped up.*/
|
2006-02-22 17:35:47 +03:00
|
|
|
old_reg->mpool->mpool_retain(old_reg->mpool, old_reg);
|
|
|
|
old_reg->mpool->mpool_deregister(old_reg->mpool, old_reg);
|
2006-05-08 21:42:34 +04:00
|
|
|
|
2006-02-22 17:35:47 +03:00
|
|
|
}
|
|
|
|
|
2005-09-04 08:17:00 +04:00
|
|
|
opal_list_append(&rcache->mru_list,(opal_list_item_t*) reg);
|
2006-02-22 17:35:47 +03:00
|
|
|
|
2005-09-04 08:17:00 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* remove an item from
|
|
|
|
the rb mru
|
|
|
|
*/
|
2005-09-09 01:34:26 +04:00
|
|
|
int mca_rcache_rb_mru_delete(
|
2005-09-04 08:17:00 +04:00
|
|
|
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 {
|
2006-05-07 05:15:33 +04:00
|
|
|
rcache->reg_cur_mru_size -= (reg->bound - reg->base + 1);
|
2005-09-04 08:17:00 +04:00
|
|
|
rc = OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* touch an item in the mru list
|
|
|
|
*/
|
2005-09-09 01:34:26 +04:00
|
|
|
int mca_rcache_rb_mru_touch(
|
2005-09-04 08:17:00 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|