Classes | Public Types | List of all members
blaze::AlignedAllocator< Type > Class Template Reference

Allocator for type-specific aligned memory.The AlignedAllocator class template represents an implementation of the allocator concept of the standard library for the allocation of type-specific, aligned, uninitialized memory. The allocator performs its allocation via the blaze::allocate() and blaze::deallocate() functions to guarantee properly aligned memory based on the alignment restrictions of the specified type Type. For instance, in case the given type is a fundamental, built-in data type and in case SSE vectorization is possible, the returned memory is guaranteed to be at least 16-byte aligned. In case AVX is active, the memory is even guaranteed to be at least 32-byte aligned. More...

#include <AlignedAllocator.h>

Classes

struct  rebind
 Implementation of the AlignedAllocator rebind mechanism. More...
 

Public Types

using ValueType = Type
 Type of the allocated values.
 
using Pointer = Type *
 Type of a pointer to the allocated values.
 
using ConstPointer = const Type *
 Type of a pointer-to-const to the allocated values.
 
using Reference = Type &
 Type of a reference to the allocated values.
 
using ConstReference = const Type &
 Type of a reference-to-const to the allocated values.
 
using SizeType = std::size_t
 Size type of the aligned allocator.
 
using DifferenceType = std::ptrdiff_t
 Difference type of the aligned allocator.
 
using value_type = ValueType
 Type of the allocated values.
 
using pointer = Pointer
 Type of a pointer to the allocated values.
 
using const_pointer = ConstPointer
 Type of a pointer-to-const to the allocated values.
 
using reference = Reference
 Type of a reference to the allocated values.
 
using const_reference = ConstReference
 Type of a reference-to-const to the allocated values.
 
using size_type = SizeType
 Size type of the aligned allocator.
 
using difference_type = DifferenceType
 Difference type of the aligned allocator.
 

Public Member Functions

Constructors
 AlignedAllocator ()
 The default constructor for AlignedAllocator.
 
template<typename Type2 >
 AlignedAllocator (const AlignedAllocator< Type2 > &)
 Conversion constructor from different AlignedAllocator instances. More...
 
Utility functions
constexpr size_t max_size () const noexcept
 Returns the maximum possible number of elements that can be allocated together. More...
 
Pointer address (Reference x) const noexcept
 Returns the address of the given element. More...
 
ConstPointer address (ConstReference x) const noexcept
 
Allocation functions
Pointer allocate (size_t numObjects, const void *localityHint=nullptr)
 Allocates aligned memory for the specified number of objects. More...
 
void deallocate (Pointer ptr, size_t numObjects) noexcept
 Deallocation of memory. More...
 
Construction functions
template<typename... Args>
void construct (Pointer ptr, Args &&... args)
 Constructs an object of type Type at the specified memory location. More...
 
void destroy (Pointer ptr) noexcept
 Destroys the object of type Type at the specified memory location. More...
 

Detailed Description

template<typename Type>
class blaze::AlignedAllocator< Type >

Allocator for type-specific aligned memory.

The AlignedAllocator class template represents an implementation of the allocator concept of the standard library for the allocation of type-specific, aligned, uninitialized memory. The allocator performs its allocation via the blaze::allocate() and blaze::deallocate() functions to guarantee properly aligned memory based on the alignment restrictions of the specified type Type. For instance, in case the given type is a fundamental, built-in data type and in case SSE vectorization is possible, the returned memory is guaranteed to be at least 16-byte aligned. In case AVX is active, the memory is even guaranteed to be at least 32-byte aligned.

Constructor & Destructor Documentation

◆ AlignedAllocator()

template<typename Type >
template<typename Type2 >
blaze::AlignedAllocator< Type >::AlignedAllocator ( const AlignedAllocator< Type2 > &  allocator)
inline

Conversion constructor from different AlignedAllocator instances.

Parameters
allocatorThe foreign aligned allocator to be copied.

Member Function Documentation

◆ address()

template<typename Type >
AlignedAllocator< Type >::ConstPointer blaze::AlignedAllocator< Type >::address ( Reference  x) const
inlinenoexcept

Returns the address of the given element.

Returns
The address of the given element.

◆ allocate()

template<typename Type >
AlignedAllocator< Type >::Pointer blaze::AlignedAllocator< Type >::allocate ( size_t  numObjects,
const void *  localityHint = nullptr 
)
inline

Allocates aligned memory for the specified number of objects.

Parameters
numObjectsThe number of objects to be allocated.
localityHintHint for improved locality.
Returns
Pointer to the newly allocated memory.

This function allocates a junk of memory for the specified number of objects of type Type. The returned pointer is guaranteed to be aligned according to the alignment restrictions of the data type Type. For instance, in case the type is a fundamental, built-in data type and in case SSE vectorization is possible, the returned memory is guaranteed to be at least 16-byte aligned. In case AVX is active, the memory is even guaranteed to be 32-byte aligned.

◆ construct()

template<typename Type >
template<typename... Args>
void blaze::AlignedAllocator< Type >::construct ( Pointer  ptr,
Args &&...  args 
)
inline

Constructs an object of type Type at the specified memory location.

Parameters
ptrPointer to the allocated, uninitialized storage.
argsThe constructor arguments.
Returns
void

This function constructs an object of type Type in the allocated, uninitialized storage pointed to by ptr. This construction is performed via placement-new.

◆ deallocate()

template<typename Type >
void blaze::AlignedAllocator< Type >::deallocate ( Pointer  ptr,
size_t  numObjects 
)
inlinenoexcept

Deallocation of memory.

Parameters
ptrThe address of the first element of the array to be deallocated.
numObjectsThe number of objects to be deallocated.
Returns
void

This function deallocates a junk of memory that was previously allocated via the allocate() function. Note that the argument numObjects must be equal ot the first argument of the call to allocate() that origianlly produced ptr.

◆ destroy()

template<typename Type >
void blaze::AlignedAllocator< Type >::destroy ( Pointer  ptr)
inlinenoexcept

Destroys the object of type Type at the specified memory location.

Parameters
ptrPointer to the object to be destroyed.
Returns
void

This function destroys the object at the specified memory location via a direct call to its destructor.

◆ max_size()

template<typename Type >
constexpr size_t blaze::AlignedAllocator< Type >::max_size ( ) const
inlinenoexcept

Returns the maximum possible number of elements that can be allocated together.

Returns
The maximum number of elements that can be allocated together.

The documentation for this class was generated from the following file: