RAJA
RAJA provides a collection of platform portability abstractions for C++ HPC applications.
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
RAJA::basic_mempool::MemPool< allocator_t > Class Template Reference

MemPool pre-allocates a large chunk of memory and provides generic malloc/free for the user to allocate aligned data within the pool. More...

#include <basic_mempool.hpp>

Public Types

using allocator_type = allocator_t
 

Public Member Functions

 MemPool ()
 
 ~MemPool ()
 
void free_chunks ()
 Free all backing allocations, even if they are currently in use. More...
 
size_t arena_size ()
 
size_t arena_size (size_t new_size)
 
template<typename T >
T * malloc (size_t nTs, size_t alignment=alignof(T))
 
void free (const void *cptr)
 

Static Public Member Functions

static MemPool< allocator_t > & getInstance ()
 

Static Public Attributes

static const size_t default_default_arena_size = 32ull * 1024ull * 1024ull
 

Detailed Description

template<typename allocator_t>
class RAJA::basic_mempool::MemPool< allocator_t >

MemPool pre-allocates a large chunk of memory and provides generic malloc/free for the user to allocate aligned data within the pool.

MemPool uses MemoryArena to do the heavy lifting of maintaining access to the used/free space.

MemPool provides an example generic_allocator which can guide more specialized allocators. The following are some examples

using device_mempool_type = basic_mempool::MemPool<cuda::DeviceAllocator>; using device_zeroed_mempool_type = basic_mempool::MemPool<cuda::DeviceZeroedAllocator>; using pinned_mempool_type = basic_mempool::MemPool<cuda::PinnedAllocator>;

The user provides the specialized allocator, for example : struct DeviceAllocator {

// returns a valid pointer on success, nullptr on failure void* malloc(size_t nbytes) { void* ptr; CAMP_CUDA_API_INVOKE_AND_CHECK(cudaMalloc, &ptr, nbytes); return ptr; }

// returns true on success, false on failure bool free(void* ptr) { CAMP_CUDA_API_INVOKE_AND_CHECK(cudaFree, ptr); return true; } };

Member Typedef Documentation

◆ allocator_type

template<typename allocator_t >
using RAJA::basic_mempool::MemPool< allocator_t >::allocator_type = allocator_t

Constructor & Destructor Documentation

◆ MemPool()

template<typename allocator_t >
RAJA::basic_mempool::MemPool< allocator_t >::MemPool ( )
inline

◆ ~MemPool()

template<typename allocator_t >
RAJA::basic_mempool::MemPool< allocator_t >::~MemPool ( )
inline

Member Function Documentation

◆ getInstance()

template<typename allocator_t >
static MemPool<allocator_t>& RAJA::basic_mempool::MemPool< allocator_t >::getInstance ( )
inlinestatic

◆ free_chunks()

template<typename allocator_t >
void RAJA::basic_mempool::MemPool< allocator_t >::free_chunks ( )
inline

Free all backing allocations, even if they are currently in use.

◆ arena_size() [1/2]

template<typename allocator_t >
size_t RAJA::basic_mempool::MemPool< allocator_t >::arena_size ( )
inline

◆ arena_size() [2/2]

template<typename allocator_t >
size_t RAJA::basic_mempool::MemPool< allocator_t >::arena_size ( size_t  new_size)
inline

◆ malloc()

template<typename allocator_t >
template<typename T >
T* RAJA::basic_mempool::MemPool< allocator_t >::malloc ( size_t  nTs,
size_t  alignment = alignof(T) 
)
inline

◆ free()

template<typename allocator_t >
void RAJA::basic_mempool::MemPool< allocator_t >::free ( const void *  cptr)
inline

Member Data Documentation

◆ default_default_arena_size

template<typename allocator_t >
const size_t RAJA::basic_mempool::MemPool< allocator_t >::default_default_arena_size = 32ull * 1024ull * 1024ull
static

The documentation for this class was generated from the following file: