Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
|
A generic caching allocator implementation. More...
#include <cheetah/data/CachingAllocator.h>
Public Types | |
typedef T | value_type |
Public Member Functions | |
CachingAllocator () | |
Create a new instance. | |
CachingAllocator (CachingAllocator const &)=delete | |
CachingAllocator (CachingAllocator &&)=default | |
T * | allocate (std::size_t num_elements) |
Allocate memory. More... | |
void | deallocate (T *ptr, std::size_t) |
Deallocate memory. More... | |
A generic caching allocator implementation.
Mainly used by thrust to provide memory required by certain transforms (e.g. copy_if). This class provides a map between allocated memory of a given size and type and pointers to that memory. It is best used for systems that regularly allocate and deallocate the same amount of memory (again e.g. copy_if and other stream compaction systems). Should not be used for systems the require allocation and deallocation of many different random memory sizes.
This class uses CRTP to support implementation on multiple architectures.
DerivedType | The derived type that is inheriting from this class |
T | The value type of the allocator |
Definition at line 55 of file CachingAllocator.h.
T * ska::cheetah::data::CachingAllocator< Arch, T >::allocate | ( | std::size_t | num_elements | ) |
Allocate memory.
[in] | num_elements | The number elements to be allocate of type T |
Definition at line 43 of file CachingAllocator.cpp.
void ska::cheetah::data::CachingAllocator< Arch, T >::deallocate | ( | T * | ptr, |
std::size_t | n | ||
) |
Deallocate memory.
[in] | ptr | Pointer to the memory to be deallocated |
[in] | n | The number of elements of type T to be deallocated |
Definition at line 49 of file CachingAllocator.cpp.