BlackCat_Tensors
A GPU-supported autograd and linear algebra library, designed for neural network construction
Classes | Public Types | Public Member Functions | Friends | List of all members
bc::allocators::Stack_Allocator< ValueType, SystemTag > Class Template Reference

An unsynced memory pool implemented as a stack. More...

#include <stack_allocator.h>

Classes

struct  rebind
 

Public Types

using system_tag = SystemTag
 
using value_type = ValueType
 
using propagate_on_container_copy_construction = std::false_type
 

Public Member Functions

 Stack_Allocator (int sz=0)
 
template<class T >
 Stack_Allocator (const Stack_Allocator< T, SystemTag > &ws)
 
 Stack_Allocator (const Stack_Allocator &)=default
 
 Stack_Allocator (Stack_Allocator &&)=default
 
void reserve (std::size_t sz)
 Reserve an amount of memory in bytes. More...
 
void free ()
 Delete all reserved memory, if memory is currently allocated an error is thrown. More...
 
void force_deallocate ()
 
size_t available_bytes () const
 
size_t allocated_bytes () const
 
size_t reserved_bytes () const
 
template<class Allocator >
void set_allocator (Allocator alloc)
 
ValueType * allocate (std::size_t sz)
 
void deallocate (ValueType *data, std::size_t sz)
 

Friends

template<class , class >
class Stack_Allocator
 

Detailed Description

template<class ValueType, class SystemTag>
class bc::allocators::Stack_Allocator< ValueType, SystemTag >

An unsynced memory pool implemented as a stack.

Deallocation must happen in reverse order of deallocation. This class is used with bc::Tensor_Base expressions to enable very fast allocations of temporaries.

Member Typedef Documentation

◆ propagate_on_container_copy_construction

template<class ValueType, class SystemTag>
using bc::allocators::Stack_Allocator< ValueType, SystemTag >::propagate_on_container_copy_construction = std::false_type

◆ system_tag

template<class ValueType, class SystemTag>
using bc::allocators::Stack_Allocator< ValueType, SystemTag >::system_tag = SystemTag

◆ value_type

template<class ValueType, class SystemTag>
using bc::allocators::Stack_Allocator< ValueType, SystemTag >::value_type = ValueType

Constructor & Destructor Documentation

◆ Stack_Allocator() [1/4]

template<class ValueType, class SystemTag>
bc::allocators::Stack_Allocator< ValueType, SystemTag >::Stack_Allocator ( int  sz = 0)
inline

◆ Stack_Allocator() [2/4]

template<class ValueType, class SystemTag>
template<class T >
bc::allocators::Stack_Allocator< ValueType, SystemTag >::Stack_Allocator ( const Stack_Allocator< T, SystemTag > &  ws)
inline

◆ Stack_Allocator() [3/4]

template<class ValueType, class SystemTag>
bc::allocators::Stack_Allocator< ValueType, SystemTag >::Stack_Allocator ( const Stack_Allocator< ValueType, SystemTag > &  )
default

◆ Stack_Allocator() [4/4]

template<class ValueType, class SystemTag>
bc::allocators::Stack_Allocator< ValueType, SystemTag >::Stack_Allocator ( Stack_Allocator< ValueType, SystemTag > &&  )
default

Member Function Documentation

◆ allocate()

template<class ValueType, class SystemTag>
ValueType* bc::allocators::Stack_Allocator< ValueType, SystemTag >::allocate ( std::size_t  sz)
inline

◆ allocated_bytes()

template<class ValueType, class SystemTag>
size_t bc::allocators::Stack_Allocator< ValueType, SystemTag >::allocated_bytes ( ) const
inline

◆ available_bytes()

template<class ValueType, class SystemTag>
size_t bc::allocators::Stack_Allocator< ValueType, SystemTag >::available_bytes ( ) const
inline

◆ deallocate()

template<class ValueType, class SystemTag>
void bc::allocators::Stack_Allocator< ValueType, SystemTag >::deallocate ( ValueType *  data,
std::size_t  sz 
)
inline

◆ force_deallocate()

template<class ValueType, class SystemTag>
void bc::allocators::Stack_Allocator< ValueType, SystemTag >::force_deallocate ( )
inline

◆ free()

template<class ValueType, class SystemTag>
void bc::allocators::Stack_Allocator< ValueType, SystemTag >::free ( )
inline

Delete all reserved memory, if memory is currently allocated an error is thrown.

◆ reserve()

template<class ValueType, class SystemTag>
void bc::allocators::Stack_Allocator< ValueType, SystemTag >::reserve ( std::size_t  sz)
inline

Reserve an amount of memory in bytes.

◆ reserved_bytes()

template<class ValueType, class SystemTag>
size_t bc::allocators::Stack_Allocator< ValueType, SystemTag >::reserved_bytes ( ) const
inline

◆ set_allocator()

template<class ValueType, class SystemTag>
template<class Allocator >
void bc::allocators::Stack_Allocator< ValueType, SystemTag >::set_allocator ( Allocator  alloc)
inline

Friends And Related Function Documentation

◆ Stack_Allocator

template<class ValueType, class SystemTag>
template<class , class >
friend class Stack_Allocator
friend

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