2004-08-02 00:24:22 +00:00
|
|
|
/*
|
2004-11-22 01:38:40 +00:00
|
|
|
* 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.
|
2004-11-28 20:09:25 +00:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 12:43:37 +00:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 01:38:40 +00:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-08-02 00:24:22 +00:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-10-20 01:03:09 +00:00
|
|
|
#include "ompi_config.h"
|
2004-08-02 00:24:22 +00:00
|
|
|
#include <string.h>
|
2005-07-03 23:31:27 +00:00
|
|
|
#include "opal/util/output.h"
|
2004-08-02 00:24:22 +00:00
|
|
|
#include "mca/mpool/sm/mpool_sm.h"
|
2004-08-06 19:35:57 +00:00
|
|
|
#include "mca/common/sm/common_sm_mmap.h"
|
2004-08-02 00:24:22 +00:00
|
|
|
|
|
|
|
|
2005-05-31 17:06:55 +00:00
|
|
|
/*
|
|
|
|
* Initializes the mpool module.
|
|
|
|
*/
|
|
|
|
void mca_mpool_sm_module_init(mca_mpool_sm_module_t* mpool)
|
|
|
|
{
|
|
|
|
mpool->super.mpool_component = &mca_mpool_sm_component.super;
|
|
|
|
mpool->super.mpool_base = mca_mpool_sm_base;
|
|
|
|
mpool->super.mpool_alloc = mca_mpool_sm_alloc;
|
|
|
|
mpool->super.mpool_realloc = mca_mpool_sm_realloc;
|
|
|
|
mpool->super.mpool_free = mca_mpool_sm_free;
|
|
|
|
mpool->super.mpool_register = NULL;
|
|
|
|
mpool->super.mpool_deregister = NULL;
|
|
|
|
mpool->super.mpool_finalize = NULL;
|
|
|
|
|
|
|
|
}
|
2004-08-02 00:24:22 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* base address of shared memory mapping
|
|
|
|
*/
|
2005-05-31 17:06:55 +00:00
|
|
|
void* mca_mpool_sm_base(mca_mpool_base_module_t* mpool)
|
2004-08-02 00:24:22 +00:00
|
|
|
{
|
2004-08-06 19:35:57 +00:00
|
|
|
return (mca_common_sm_mmap != NULL) ? mca_common_sm_mmap->map_addr : NULL;
|
2004-08-02 00:24:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* allocate function
|
|
|
|
*/
|
2005-06-21 17:10:28 +00:00
|
|
|
void* mca_mpool_sm_alloc(
|
|
|
|
mca_mpool_base_module_t* mpool,
|
|
|
|
size_t size,
|
|
|
|
size_t align,
|
2005-09-12 22:28:23 +00:00
|
|
|
uint32_t flags,
|
2005-06-24 21:12:38 +00:00
|
|
|
mca_mpool_base_registration_t** registration)
|
2004-08-02 00:24:22 +00:00
|
|
|
{
|
2005-06-21 17:10:28 +00:00
|
|
|
mca_mpool_sm_module_t* mpool_sm = (mca_mpool_sm_module_t*)mpool;
|
|
|
|
return mpool_sm->sm_allocator->alc_alloc(mpool_sm->sm_allocator, size, align, registration);
|
2004-08-02 00:24:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* realloc function
|
|
|
|
*/
|
2005-06-21 17:10:28 +00:00
|
|
|
void* mca_mpool_sm_realloc(
|
|
|
|
mca_mpool_base_module_t* mpool,
|
|
|
|
void* addr,
|
|
|
|
size_t size,
|
2005-06-24 21:12:38 +00:00
|
|
|
mca_mpool_base_registration_t** registration)
|
2004-08-02 00:24:22 +00:00
|
|
|
{
|
2005-06-21 17:10:28 +00:00
|
|
|
mca_mpool_sm_module_t* mpool_sm = (mca_mpool_sm_module_t*)mpool;
|
|
|
|
return mpool_sm->sm_allocator->alc_realloc(mpool_sm->sm_allocator, addr, size, registration);
|
2004-08-02 00:24:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* free function
|
|
|
|
*/
|
2005-06-21 21:20:23 +00:00
|
|
|
void mca_mpool_sm_free(mca_mpool_base_module_t* mpool, void * addr,
|
2005-06-24 21:12:38 +00:00
|
|
|
mca_mpool_base_registration_t* registration)
|
2004-08-02 00:24:22 +00:00
|
|
|
{
|
2005-06-21 17:10:28 +00:00
|
|
|
mca_mpool_sm_module_t* mpool_sm = (mca_mpool_sm_module_t*)mpool;
|
|
|
|
mpool_sm->sm_allocator->alc_free(mpool_sm->sm_allocator, addr);
|
2004-08-02 00:24:22 +00:00
|
|
|
}
|