Alignment manipulation¶
Aligned memory allocator¶
- template <class T, size_t Align>
-
class
xsimd::aligned_allocator¶ Allocator for aligned memory.
The aligned_allocator class template is an allocator that performs memory allocation aligned by the specified value.
- Template Parameters
T: type of objects to allocate.Align: alignment in bytes.
Public Functions
-
XSIMD_INLINE
aligned_allocator()¶ Default constructor.
-
XSIMD_INLINE
aligned_allocator(const aligned_allocator &rhs)¶ Copy constructor.
- template <class U>
-
XSIMD_INLINE
aligned_allocator(const aligned_allocator<U, Align> &rhs)¶ Extended copy constructor.
-
XSIMD_INLINE
~aligned_allocator()¶ Destructor.
-
XSIMD_INLINE auto xsimd::aligned_allocator::address(reference r) Returns the actual address of
reven in presence of overloadedoperator&.- Return
the actual address of
r.- Parameters
r: the object to acquire address of.
-
XSIMD_INLINE auto xsimd::aligned_allocator::address(const_reference r) const Returns the actual address of
reven in presence of overloadedoperator&.- Return
the actual address of
r.- Parameters
r: the object to acquire address of.
-
XSIMD_INLINE auto xsimd::aligned_allocator::allocate(size_type n, const void * hint = 0) Allocates
n * sizeof(T)bytes of uninitialized memory, aligned byA.The alignment may require some extra memory allocation.
- Return
a pointer to the first byte of a memory block suitably aligned and sufficient to hold an array of
nobjects of typeT.- Parameters
n: the number of objects to allocate storage for.hint: unused parameter provided for standard compliance.
-
XSIMD_INLINE void xsimd::aligned_allocator::deallocate(pointer p, size_type n) Deallocates the storage referenced by the pointer p, which must be a pointer obtained by an earlier call to allocate().
The argument
nmust be equal to the first argument of the call to allocate() that originally producedp; otherwise, the behavior is undefined.- Parameters
p: pointer obtained from allocate().n: number of objects earlier passed to allocate().
-
XSIMD_INLINE auto xsimd::aligned_allocator::max_size() const Returns the maximum theoretically possible value of
n, for which the call allocate(n, 0) could succeed.- Return
the maximum supported allocated size.
-
XSIMD_INLINE auto xsimd::aligned_allocator::size_max() const This method is deprecated, use max_size() instead.
- template <class U, class… Args>
-
XSIMD_INLINE void xsimd::aligned_allocator::construct(U * p, Args &&... args) Constructs an object of type
Tin allocated uninitialized memory pointed to byp, using placement-new.- Parameters
p: pointer to allocated uninitialized memory.args: the constructor arguments to use.
- template <class U>
-
XSIMD_INLINE void xsimd::aligned_allocator::destroy(U * p) Calls the destructor of the object pointed to by
p.- Parameters
p: pointer to the object that is going to be destroyed.
Alignement checker¶
- template <class Arch = default_arch>
-
XSIMD_INLINE bool xsimd::is_aligned(void const * ptr) Checks whether pointer
ptris aligned according the alignment requirements ofArch.- Return
true if the alignment requirements are met