Kokkos Core Kernels Package
Version of the Day
|
Bitset based memory manager for pools of same-sized chunks of memory. More...
#include <Kokkos_MemoryPool.hpp>
Public Types | |
typedef MemoryPool | memory_space |
Tag this class as a kokkos memory space. More... | |
Public Member Functions | |
MemoryPool (const backend_memory_space &memspace, size_t total_size, size_t log2_superblock_size=20) | |
Initializes the memory pool. More... | |
KOKKOS_INLINE_FUNCTION size_t | allocate_block_size (const size_t alloc_size) const |
The actual block size allocated given alloc_size. More... | |
KOKKOS_FUNCTION void * | allocate (size_t alloc_size) const |
Allocate a chunk of memory. More... | |
KOKKOS_FUNCTION void | deallocate (void *alloc_ptr, size_t alloc_size) const |
Release allocated memory back to the pool. More... | |
KOKKOS_INLINE_FUNCTION bool | is_empty () const |
Tests if the memory pool has no more memory available to allocate. More... | |
Bitset based memory manager for pools of same-sized chunks of memory.
Device | Kokkos device that gives the execution and memory space the allocator will be used in. |
MemoryPool is a memory space that can be on host or device. It provides a pool memory allocator for fast allocation of same-sized chunks of memory. The memory is only accessible on the host / device this allocator is associated with.
This allocator is based on ideas from the following GPU allocators: Halloc (https://github.com/canonizer/halloc). ScatterAlloc (https://github.com/ComputationalRadiationPhysics/scatteralloc)
Definition at line 515 of file Kokkos_MemoryPool.hpp.
typedef MemoryPool Kokkos::Experimental::MemoryPool< Device >::memory_space |
Tag this class as a kokkos memory space.
Definition at line 655 of file Kokkos_MemoryPool.hpp.
|
inline |
Initializes the memory pool.
memspace | The memory space from which the memory pool will allocate memory. |
total_size | The requested memory amount controlled by the allocator. The actual amount is rounded up to the smallest multiple of the superblock size >= the requested size. |
log2_superblock_size | Log2 of the size of superblocks used by the allocator. In most use cases, the default value should work. |
Definition at line 672 of file Kokkos_MemoryPool.hpp.
|
inline |
The actual block size allocated given alloc_size.
Definition at line 827 of file Kokkos_MemoryPool.hpp.
|
inline |
Allocate a chunk of memory.
alloc_size | Size of the requested allocated in number of bytes. |
The function returns a void pointer to a memory location on success and NULL on failure.
Definition at line 836 of file Kokkos_MemoryPool.hpp.
|
inline |
Release allocated memory back to the pool.
alloc_ptr | Pointer to chunk of memory previously allocated by the allocator. |
alloc_size | Size of the allocated memory in number of bytes. |
Definition at line 1000 of file Kokkos_MemoryPool.hpp.
|
inline |
Tests if the memory pool has no more memory available to allocate.
Definition at line 1084 of file Kokkos_MemoryPool.hpp.