TRIQS/nda 1.3.0
Multi-dimensional array library for C++
|
#include <nda/mem/allocators.hpp>
Custom allocator that uses multiple nda::mem::bucket allocators.
It uses a std::vector of bucket allocators. When all buckets in the vector are full, it simply adds a new one at the end.
Host
nda::mem::AddressSpace.ChunkSize | Size of the chunks in bytes. |
Definition at line 264 of file allocators.hpp.
Public Member Functions | |
multi_bucket () | |
Default constructor. | |
multi_bucket (multi_bucket &&)=default | |
Default move constructor. | |
multi_bucket (multi_bucket const &)=delete | |
Deleted copy constructor. | |
blk_t | allocate (size_t s) noexcept |
Allocate a chunk of memory in the current bucket or find a new one if the current one is full. | |
blk_t | allocate_zero (size_t s) noexcept |
Allocate a chunk of memory in the current bucket or find a new one if the current one is full and set it to zero. | |
auto const & | buckets () const noexcept |
Get the bucket vector. | |
void | deallocate (blk_t b) noexcept |
Deallocate a chunk of memory from the bucket to which it belongs. | |
bool | empty () const noexcept |
Check if the current allocator is empty. | |
multi_bucket & | operator= (multi_bucket &&)=default |
Default move assignment operator. | |
multi_bucket & | operator= (multi_bucket const &)=delete |
Deleted copy assignment operator. | |
bool | owns (blk_t b) const noexcept |
Check if a given nda::mem::blk_t memory block is owned by allocator. | |
Static Public Attributes | |
static constexpr auto | address_space = Host |
Only Host nda::mem::AddressSpace is supported for this allocator. | |
|
inlinenoexcept |
Allocate a chunk of memory in the current bucket or find a new one if the current one is full.
s | Size in bytes of the returned memory block (has to be < ChunkSize ). |
Definition at line 308 of file allocators.hpp.
|
inlinenoexcept |
Allocate a chunk of memory in the current bucket or find a new one if the current one is full and set it to zero.
s | Size in bytes of the returned memory block (has to be < ChunkSize ). |
Definition at line 320 of file allocators.hpp.
|
inlinenodiscardnoexcept |
Get the bucket vector.
Definition at line 365 of file allocators.hpp.
|
inlinenoexcept |
Deallocate a chunk of memory from the bucket to which it belongs.
If the bucket is empty after deallocation and it is not the only one, it is removed from the vector of buckets.
b | nda::mem::blk_t memory block to deallocate. |
Definition at line 334 of file allocators.hpp.
|
inlinenodiscardnoexcept |
Check if the current allocator is empty.
Definition at line 359 of file allocators.hpp.
|
inlinenodiscardnoexcept |
Check if a given nda::mem::blk_t memory block is owned by allocator.
b | nda::mem::blk_t memory block. |
Definition at line 373 of file allocators.hpp.