b8cb6e1c64
be used in MPI_Alloc_mem operations. Note that we found an interesting bug in which if memory was allocated by the sm mpool (via mmap) and then registered via the mvapi mpool, the registration would fail on certain systems. Added mca param mpool_base_use_mem_hooks, set to 1 to enable the memory hooks so that memory is deregistered if the user frees it behind our back. This is only useful if the mca param mpi_leave_pinned is also set to 1. Otherwise all registrations are deregistered within the MPI library or via MPI_Free_buf. After testing we should probably set both mpi_leave_pinned and mpool_base_use_mem_hooks to default to 1. This commit was SVN r7415.
84 строки
2.4 KiB
C
84 строки
2.4 KiB
C
/*
|
|
* 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 "ompi_config.h"
|
|
#include <string.h>
|
|
#include "opal/util/output.h"
|
|
#include "mca/mpool/sm/mpool_sm.h"
|
|
#include "mca/common/sm/common_sm_mmap.h"
|
|
|
|
|
|
/*
|
|
* 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;
|
|
mpool->super.flags = 0;
|
|
}
|
|
|
|
/*
|
|
* base address of shared memory mapping
|
|
*/
|
|
void* mca_mpool_sm_base(mca_mpool_base_module_t* mpool)
|
|
{
|
|
return (mca_common_sm_mmap != NULL) ? mca_common_sm_mmap->map_addr : NULL;
|
|
}
|
|
|
|
/**
|
|
* allocate function
|
|
*/
|
|
void* mca_mpool_sm_alloc(
|
|
mca_mpool_base_module_t* mpool,
|
|
size_t size,
|
|
size_t align,
|
|
uint32_t flags,
|
|
mca_mpool_base_registration_t** registration)
|
|
{
|
|
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);
|
|
}
|
|
|
|
/**
|
|
* realloc function
|
|
*/
|
|
void* mca_mpool_sm_realloc(
|
|
mca_mpool_base_module_t* mpool,
|
|
void* addr,
|
|
size_t size,
|
|
mca_mpool_base_registration_t** registration)
|
|
{
|
|
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);
|
|
}
|
|
|
|
/**
|
|
* free function
|
|
*/
|
|
void mca_mpool_sm_free(mca_mpool_base_module_t* mpool, void * addr,
|
|
mca_mpool_base_registration_t* registration)
|
|
{
|
|
mca_mpool_sm_module_t* mpool_sm = (mca_mpool_sm_module_t*)mpool;
|
|
mpool_sm->sm_allocator->alc_free(mpool_sm->sm_allocator, addr);
|
|
}
|