strata::AlignedAllocator¶
Part of Memory.
A stateless allocator like std::allocator, but aligned to Alignment bytes.
In constant evaluation it is std::allocator, so that dynamic tensors work in constexpr code; at run time it is std::malloc with room to round up, as Eigen does, the offset back to the start of the block kept in the byte just before the aligned one: the aligned operator new takes a slower path in common allocators, which costs small tensors up to twice their time. One byte holds offsets up to 256, hence the bound. Both allocate and deallocate pick the same branch, since memory allocated in constant evaluation cannot outlive it.
Template parameters
| Name | Description |
|---|---|
T | The element type. |
Alignment | A power of two, at least alignof(T) and at most 256. |
Members¶
alignment¶
The alignment of the memory, in bytes.
AlignedAllocator¶
Converts from the allocator of another element type.
Implicit, as that of std::allocator: containers convert rebound allocators without asking.
allocate¶
Memory for count elements, aligned to Alignment.
Exceptions
| Name | Description |
|---|---|
std::bad_array_new_length | when the size overflows. |
std::bad_alloc | when there is no memory. |
deallocate¶
Returns memory from allocate.
operator==¶
All allocators of one type are equal.