All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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

typedef Type ValueType
 Type of the allocated values.
 
typedef Type * Pointer
 Type of a pointer to the allocated values.
 
typedef const Type * ConstPointer
 Type of a pointer-to-const to the allocated values.
 
typedef Type & Reference
 Type of a reference to the allocated values.
 
typedef const Type & ConstReference
 Type of a reference-to-const to the allocated values.
 
typedef std::size_t SizeType
 Size type of the aligned allocator.
 
typedef std::ptrdiff_t DifferenceType
 Difference type of the aligned allocator.
 
typedef ValueType value_type
 Type of the allocated values.
 
typedef Pointer pointer
 Type of a pointer to the allocated values.
 
typedef ConstPointer const_pointer
 Type of a pointer-to-const to the allocated values.
 
typedef Reference reference
 Type of a reference to the allocated values.
 
typedef ConstReference const_reference
 Type of a reference-to-const to the allocated values.
 
typedef SizeType size_type
 Size type of the aligned allocator.
 
typedef DifferenceType difference_type
 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
size_t maxSize () const
 Returns the maximum possible number of elements that can be allocated together. More...
 
Pointer address (Reference x) const
 Returns the address of the given element. More...
 
ConstPointer address (ConstReference x) const
 
Allocation functions
Pointer allocate (size_t numObjects, const void *localityHint=NULL)
 Allocates aligned memory for the specified number of objects. More...
 
void deallocate (Pointer ptr, size_t numObjects)
 Deallocation of memory. More...
 
Construction functions
void construct (Pointer ptr, const Type &value)
 Constructs an object of type Type at the specified memory location. More...
 
void destroy (Pointer ptr)
 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

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

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

Returns the address of the given element.

Returns
The address of the given element.
template<typename Type >
AlignedAllocator< Type >::Pointer blaze::AlignedAllocator< Type >::allocate ( size_t  numObjects,
const void *  localityHint = NULL 
)
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.

template<typename Type>
void blaze::AlignedAllocator< Type >::construct ( Pointer  ptr,
const Type &  value 
)
inline

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

Parameters
ptrPointer to the allocated, uninitialized storage.
valueThe initialization value.
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.

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

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.

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

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.

template<typename Type >
size_t blaze::AlignedAllocator< Type >::maxSize ( ) const
inline

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: