2007-12-21 09:02:00 +03:00
|
|
|
/* -*- Mode: C; c-basic-offset:4 ; -*- */
|
2006-08-15 22:40:08 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2007-12-21 09:02:00 +03:00
|
|
|
* Copyright (c) 2004-2007 The University of Tennessee and The University
|
2006-08-15 22:40:08 +04:00
|
|
|
* 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) 2006 Voltaire. All rights reserved.
|
|
|
|
*
|
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2007-01-09 01:03:16 +03:00
|
|
|
#include "ompi_config.h"
|
|
|
|
|
2006-08-15 22:40:08 +04:00
|
|
|
#include "ompi/mca/rcache/rcache.h"
|
|
|
|
#include "rcache_vma.h"
|
|
|
|
#include "rcache_vma_tree.h"
|
2008-06-09 18:53:58 +04:00
|
|
|
#include "orte/util/show_help.h"
|
2006-08-15 22:40:08 +04:00
|
|
|
#include "ompi/mca/mpool/base/base.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the rcache
|
|
|
|
*/
|
|
|
|
|
|
|
|
void mca_rcache_vma_module_init( mca_rcache_vma_module_t* rcache ) {
|
|
|
|
rcache->base.rcache_find = mca_rcache_vma_find;
|
2006-12-17 15:26:41 +03:00
|
|
|
rcache->base.rcache_find_all = mca_rcache_vma_find_all;
|
2006-08-15 22:40:08 +04:00
|
|
|
rcache->base.rcache_insert = mca_rcache_vma_insert;
|
|
|
|
rcache->base.rcache_delete = mca_rcache_vma_delete;
|
|
|
|
rcache->base.rcache_finalize = mca_rcache_vma_finalize;
|
|
|
|
OBJ_CONSTRUCT(&rcache->base.lock, opal_mutex_t);
|
|
|
|
mca_rcache_vma_tree_init(rcache);
|
|
|
|
}
|
|
|
|
|
2006-12-17 15:26:41 +03:00
|
|
|
int mca_rcache_vma_find(struct mca_rcache_base_module_t* rcache,
|
|
|
|
void* addr, size_t size, mca_mpool_base_registration_t **reg)
|
|
|
|
{
|
2006-08-15 22:40:08 +04:00
|
|
|
void* base_addr;
|
|
|
|
void* bound_addr;
|
|
|
|
|
|
|
|
if(size == 0) {
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2007-01-24 03:49:08 +03:00
|
|
|
*reg = mca_rcache_vma_tree_find((mca_rcache_vma_module_t*)rcache, (unsigned char*)base_addr,
|
|
|
|
(unsigned char*)bound_addr);
|
2006-08-15 22:40:08 +04:00
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-12-17 15:26:41 +03:00
|
|
|
int mca_rcache_vma_find_all(struct mca_rcache_base_module_t* rcache,
|
2008-01-08 11:55:42 +03:00
|
|
|
void* addr, size_t size, mca_mpool_base_registration_t **regs,
|
|
|
|
int reg_cnt)
|
2006-12-17 15:26:41 +03:00
|
|
|
{
|
|
|
|
void *base_addr, *bound_addr;
|
2006-08-15 22:40:08 +04:00
|
|
|
|
2006-12-17 15:26:41 +03:00
|
|
|
if(size == 0) {
|
|
|
|
return OMPI_ERROR;
|
2006-08-15 22:40:08 +04:00
|
|
|
}
|
|
|
|
|
2006-12-17 15:26:41 +03:00
|
|
|
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);
|
2006-08-15 22:40:08 +04:00
|
|
|
|
2006-12-17 15:26:41 +03:00
|
|
|
return mca_rcache_vma_tree_find_all((mca_rcache_vma_module_t*)rcache,
|
2008-01-08 11:55:42 +03:00
|
|
|
(unsigned char*)base_addr, (unsigned char*)bound_addr, regs,
|
|
|
|
reg_cnt);
|
2006-08-15 22:40:08 +04:00
|
|
|
}
|
|
|
|
|
2006-12-17 15:26:41 +03:00
|
|
|
int mca_rcache_vma_insert(struct mca_rcache_base_module_t* rcache,
|
|
|
|
mca_mpool_base_registration_t* reg, size_t limit)
|
|
|
|
{
|
|
|
|
size_t reg_size = reg->bound - reg->base + 1;
|
|
|
|
mca_rcache_vma_module_t *vma_rcache = (mca_rcache_vma_module_t*)rcache;
|
|
|
|
|
|
|
|
if(limit != 0 && reg_size > limit) {
|
|
|
|
/* return out of resources if request is bigger than cache size
|
|
|
|
* return temp out of resources otherwise */
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
2006-08-15 22:40:08 +04:00
|
|
|
}
|
2006-12-17 15:26:41 +03:00
|
|
|
|
|
|
|
return mca_rcache_vma_tree_insert(vma_rcache, reg, limit);
|
|
|
|
}
|
|
|
|
|
|
|
|
int mca_rcache_vma_delete(struct mca_rcache_base_module_t* rcache,
|
|
|
|
mca_mpool_base_registration_t* reg)
|
|
|
|
{
|
|
|
|
mca_rcache_vma_module_t *vma_rcache = (mca_rcache_vma_module_t*)rcache;
|
|
|
|
return mca_rcache_vma_tree_delete(vma_rcache, reg);
|
2006-08-15 22:40:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* finalize
|
|
|
|
*/
|
2006-12-17 15:26:41 +03:00
|
|
|
void mca_rcache_vma_finalize(struct mca_rcache_base_module_t* rcache)
|
|
|
|
{
|
2006-08-15 22:40:08 +04:00
|
|
|
}
|