Skip to content

Memory

Aligned memory for tensors: the allocator, the memory policy and the uninitialized marker.

Types

Name Description
Aligned A memory policy for tensors: memory aligned to N bytes, which strata places itself.
AlignedAllocator A stateless allocator like std::allocator, but aligned to Alignment bytes.
from_iterator_t Tags a construction from size elements read from an iterator, one by one.
uninitialized_t The type of uninitialized.

Variables

default_alignment

constexpr std::size_t default_alignment = 64

The alignment strata gives tensor memory by default: a cache line, and the widest SIMD register (AVX-512) in one.

allocation_alignment

template <typename Allocator>
constexpr std::size_t allocation_alignment = alignof(typename std::allocator_traits<Allocator>::value_type)

The alignment memory from Allocator is known to have, which strata assumes and never more.

An allocator's own static constexpr std::size_t alignment where it declares one; for std::allocator, what operator new guarantees; for std::pmr::polymorphic_allocator, at least default_alignment, which strata asks of its memory resource; for any other, its type's alignment.

uninitialized

constexpr uninitialized_t uninitialized {}

Asks for elements left uninitialized, to be written before they are read: Tensor{shape, uninitialized}.

Only for types that need no constructor; in constant evaluation the elements are value-initialized all the same, since constexpr code may not touch an object before it exists.

from_iterator

constexpr from_iterator_t from_iterator {}

Asks DynamicStorage to construct its elements from an iterator, one by one.

Aliases

allocator_for_t

template <typename T, typename Memory>
using strata::allocator_for_t = detail::allocator_for<T, Memory>::type

The allocator a tensor of T with memory Memory, a policy or an allocator, takes its memory from.