Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
Public Types | Public Member Functions | List of all members
ska::cheetah::data::CachingAllocator< Arch, T > Class Template Reference

A generic caching allocator implementation. More...

#include <cheetah/data/CachingAllocator.h>

Inheritance diagram for ska::cheetah::data::CachingAllocator< Arch, T >:
Inheritance graph
Collaboration diagram for ska::cheetah::data::CachingAllocator< Arch, T >:
Collaboration graph

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

Detailed Description

template<typename Arch, typename T>
class ska::cheetah::data::CachingAllocator< Arch, T >

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.

Template Parameters
DerivedTypeThe derived type that is inheriting from this class
TThe value type of the allocator

Definition at line 55 of file CachingAllocator.h.

Member Function Documentation

◆ allocate()

template<typename Arch , typename T >
T * ska::cheetah::data::CachingAllocator< Arch, T >::allocate ( std::size_t  num_elements)

Allocate memory.

Parameters
[in]num_elementsThe number elements to be allocate of type T
Returns
A pointer to the allocated memory

Definition at line 43 of file CachingAllocator.cpp.

44 {
45  return _pimpl->allocate(num_elements);
46 }

◆ deallocate()

template<typename Arch , typename T>
void ska::cheetah::data::CachingAllocator< Arch, T >::deallocate ( T *  ptr,
std::size_t  n 
)

Deallocate memory.

Parameters
[in]ptrPointer to the memory to be deallocated
[in]nThe number of elements of type T to be deallocated

Definition at line 49 of file CachingAllocator.cpp.

50 {
51  return _pimpl->deallocate(ptr,n);
52 }

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