Kokkos Core Kernels Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | List of all members
Kokkos::Experimental::MemoryPool< Device > Class Template Reference

Bitset based memory manager for pools of same-sized chunks of memory. More...

#include <Kokkos_MemoryPool.hpp>

Inheritance diagram for Kokkos::Experimental::MemoryPool< Device >:
Inheritance graph
[legend]

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...
 

Detailed Description

template<typename Device>
class Kokkos::Experimental::MemoryPool< Device >

Bitset based memory manager for pools of same-sized chunks of memory.

Template Parameters
DeviceKokkos 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.

Member Typedef Documentation

template<typename Device>
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.

Constructor & Destructor Documentation

template<typename Device>
Kokkos::Experimental::MemoryPool< Device >::MemoryPool ( const backend_memory_space &  memspace,
size_t  total_size,
size_t  log2_superblock_size = 20 
)
inline

Initializes the memory pool.

Parameters
memspaceThe memory space from which the memory pool will allocate memory.
total_sizeThe 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_sizeLog2 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.

Member Function Documentation

template<typename Device>
KOKKOS_INLINE_FUNCTION size_t Kokkos::Experimental::MemoryPool< Device >::allocate_block_size ( const size_t  alloc_size) const
inline

The actual block size allocated given alloc_size.

Definition at line 827 of file Kokkos_MemoryPool.hpp.

template<typename Device>
KOKKOS_FUNCTION void* Kokkos::Experimental::MemoryPool< Device >::allocate ( size_t  alloc_size) const
inline

Allocate a chunk of memory.

Parameters
alloc_sizeSize 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.

template<typename Device>
KOKKOS_FUNCTION void Kokkos::Experimental::MemoryPool< Device >::deallocate ( void *  alloc_ptr,
size_t  alloc_size 
) const
inline

Release allocated memory back to the pool.

Parameters
alloc_ptrPointer to chunk of memory previously allocated by the allocator.
alloc_sizeSize of the allocated memory in number of bytes.

Definition at line 1000 of file Kokkos_MemoryPool.hpp.

template<typename Device>
KOKKOS_INLINE_FUNCTION bool Kokkos::Experimental::MemoryPool< Device >::is_empty ( ) const
inline

Tests if the memory pool has no more memory available to allocate.

Definition at line 1084 of file Kokkos_MemoryPool.hpp.


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