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; } };