TRIQS/nda 1.3.0
Multi-dimensional array library for C++
|
#include <nda/mem/allocators.hpp>
Custom allocator that allocates a bucket of memory on the heap consisting of 64 chunks.
The allocator keeps track of which chunks are free using a bitmask. Once all chunks have been allocated, it will call std::abort on any further allocation requests.
Host
nda::mem::AddressSpace.ChunkSize | Size of the chunks in bytes. |
Definition at line 137 of file allocators.hpp.
Public Member Functions | |
bucket ()=default | |
Default constructor. | |
bucket (bucket &&)=default | |
Default move constructor. | |
bucket (bucket const &)=delete | |
Deleted copy constructor. | |
blk_t | allocate (size_t s) noexcept |
Allocate a chunk of memory in the bucket and update the bitmask. | |
blk_t | allocate_zero (size_t s) noexcept |
Allocate a chunk of memory in the bucket, set it to zero and update the bitmask. | |
const char * | data () const noexcept |
Get a pointer to the start of the bucket. | |
void | deallocate (blk_t b) noexcept |
Deallocate a chunk of memory from the bucket by simply resetting the bitmask. | |
bool | empty () const noexcept |
Check if the bucket is empty. | |
bool | is_full () const noexcept |
Check if the bucket is full. | |
auto | mask () const noexcept |
Get the bitmask of the bucket. | |
bucket & | operator= (bucket &&)=default |
Default move assignment operator. | |
bucket & | operator= (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 the bucket. | |
Static Public Attributes | |
static constexpr auto | address_space = Host |
Only Host nda::mem::AddressSpace is supported for this allocator. | |
static constexpr int | TotalChunkSize = 64 * ChunkSize |
Total size of the bucket in bytes. | |
|
inlinenoexcept |
Allocate a chunk of memory in the bucket and update the bitmask.
s | Size in bytes of the returned memory block (has to be < ChunkSize ). |
Definition at line 179 of file allocators.hpp.
|
inlinenoexcept |
Allocate a chunk of memory in the bucket, set it to zero and update the bitmask.
s | Size in bytes of the returned memory block (has to be < ChunkSize ). |
Definition at line 202 of file allocators.hpp.
|
inlinenodiscardnoexcept |
Get a pointer to the start of the bucket.
Definition at line 236 of file allocators.hpp.
|
inlinenoexcept |
Deallocate a chunk of memory from the bucket by simply resetting the bitmask.
b | nda::mem::blk_t memory block to deallocate. |
Definition at line 212 of file allocators.hpp.
|
inlinenodiscardnoexcept |
Check if the bucket is empty.
Definition at line 230 of file allocators.hpp.
|
inlinenodiscardnoexcept |
Check if the bucket is full.
Definition at line 224 of file allocators.hpp.
|
inlinenodiscardnoexcept |
Get the bitmask of the bucket.
uint64_t
. Definition at line 242 of file allocators.hpp.
|
inlinenodiscardnoexcept |
Check if a given nda::mem::blk_t memory block is owned by the bucket.
b | nda::mem::blk_t memory block. |
Definition at line 250 of file allocators.hpp.