ROOT  6.06/09
Reference Guide
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
ROOT::Vc::Memory< V, 0u, 0u > Class Template Reference

template<typename V>
class ROOT::Vc::Memory< V, 0u, 0u >

A helper class that is very similar to Memory<V, Size> but with dynamically allocated memory and thus dynamic size.

Example:

size_t size = 11;
Vc::Memory<int_v> array(size);
// scalar access:
for (size_t i = 0; i < array.entriesCount(); ++i) {
array[i] = i;
}
// vector access:
for (size_t i = 0; i < array.vectorsCount(); ++i) {
array.vector(i) = int_v::IndexesFromZero() + i * int_v::Size;
}

This code allocates a small array with 11 scalar entries and implements two equivalent loops that initialize the memory. The scalar loop writes each individual int. The vectorized loop writes int_v::Size values to memory per iteration. Since the size of 11 is not a multiple of int_v::Size (unless you use the scalar Vc implementation) the last write access of the vector loop would normally be out of bounds. But the Memory class automatically pads the memory such that the whole array can be accessed with correctly aligned memory addresses. (Note: the scalar loop can be auto-vectorized, except for the last three assignments.)

Note
The internal data pointer is not declared with the restrict keyword. Therefore modifying memory of V::EntryType will require the compiler to assume aliasing. If you want to use the restrict keyword you need to use a standard pointer to memory and do the vector address calculation and loads and stores manually.
Parameters
VThe vector type you want to operate on. (e.g. float_v or uint_v)
See also
Memory<V, Size>

Definition at line 420 of file memory.h.

Public Types

typedef V::EntryType EntryType
 
- Public Types inherited from ROOT::Vc::MemoryBase< V, Memory< V, 0u, 0u >, 1, void >
typedef V::EntryType EntryType
 The type of the scalar entries in the array. More...
 

Public Member Functions

Vc_ALWAYS_INLINE Memory (size_t size)
 Allocate enough memory to access size values of type V::EntryType. More...
 
template<typename Parent , typename RM >
Vc_ALWAYS_INLINE Memory (const MemoryBase< V, Parent, 1, RM > &rhs)
 Copy the memory into a new memory area. More...
 
Vc_ALWAYS_INLINE Memory (const Memory &rhs)
 Overload of the above function. More...
 
Vc_ALWAYS_INLINE ~Memory ()
 Frees the memory which was allocated in the constructor. More...
 
void swap (Memory &rhs)
 Swap the contents and size information of two Memory objects. More...
 
Vc_ALWAYS_INLINE Vc_PURE size_t entriesCount () const
 
Vc_ALWAYS_INLINE Vc_PURE size_t vectorsCount () const
 
template<typename Parent , typename RM >
Vc_ALWAYS_INLINE Memoryoperator= (const MemoryBase< V, Parent, 1, RM > &rhs)
 Overwrite all entries with the values stored in rhs. More...
 
Vc_ALWAYS_INLINE Memoryoperator= (const Memory &rhs)
 
Vc_ALWAYS_INLINE Memoryoperator= (const EntryType *rhs)
 Overwrite all entries with the values stored in the memory at rhs. More...
 
- Public Member Functions inherited from ROOT::Vc::MemoryBase< V, Memory< V, 0u, 0u >, 1, void >
Vc_ALWAYS_INLINE Vc_PURE size_t entriesCount () const
 
Vc_ALWAYS_INLINE Vc_PURE size_t vectorsCount () const
 
Vc_ALWAYS_INLINE Vc_PURE VectorPointerHelper< V, AlignedFlagvector (size_t i)
 
Vc_ALWAYS_INLINE Vc_PURE const VectorPointerHelperConst< V, AlignedFlagvector (size_t i) const
 Const overload of the above function. More...
 
Vc_ALWAYS_INLINE Vc_PURE VectorPointerHelper< V, UnalignedFlagvector (size_t i, int shift)
 
Vc_ALWAYS_INLINE Vc_PURE const VectorPointerHelperConst< V, UnalignedFlagvector (size_t i, int shift) const
 Const overload of the above function. More...
 
Vc_ALWAYS_INLINE Vc_PURE VectorPointerHelper< V, A > vectorAt (size_t i, A)
 
Vc_ALWAYS_INLINE Vc_PURE const VectorPointerHelperConst< V, A > vectorAt (size_t i, A) const
 
Vc_ALWAYS_INLINE Vc_PURE VectorPointerHelper< V, AlignedFlagvectorAt (size_t i)
 
Vc_ALWAYS_INLINE Vc_PURE const VectorPointerHelperConst< V, AlignedFlagvectorAt (size_t i) const
 
Vc_ALWAYS_INLINE Vc_PURE VectorPointerHelper< V, AlignedFlagfirstVector ()
 
Vc_ALWAYS_INLINE Vc_PURE const VectorPointerHelperConst< V, AlignedFlagfirstVector () const
 Const overload of the above function. More...
 
Vc_ALWAYS_INLINE Vc_PURE VectorPointerHelper< V, AlignedFlaglastVector ()
 
Vc_ALWAYS_INLINE Vc_PURE const VectorPointerHelperConst< V, AlignedFlaglastVector () const
 Const overload of the above function. More...
 
Vc_ALWAYS_INLINE Vc_PUREgather (const unsigned char *indexes) const
 
Vc_ALWAYS_INLINE Vc_PUREgather (const unsigned short *indexes) const
 
Vc_ALWAYS_INLINE Vc_PUREgather (const unsigned int *indexes) const
 
Vc_ALWAYS_INLINE Vc_PUREgather (const unsigned long *indexes) const
 
Vc_ALWAYS_INLINE void setZero ()
 
Memory< V, 0u, 0u > & operator+= (const MemoryBase< V, P2, Dimension, RM > &rhs)
 
Memory< V, 0u, 0u > & operator+= (EntryType rhs)
 
Memory< V, 0u, 0u > & operator-= (const MemoryBase< V, P2, Dimension, RM > &rhs)
 
Memory< V, 0u, 0u > & operator-= (EntryType rhs)
 
Memory< V, 0u, 0u > & operator*= (const MemoryBase< V, P2, Dimension, RM > &rhs)
 
Memory< V, 0u, 0u > & operator*= (EntryType rhs)
 
Memory< V, 0u, 0u > & operator/= (const MemoryBase< V, P2, Dimension, RM > &rhs)
 
Memory< V, 0u, 0u > & operator/= (EntryType rhs)
 
bool operator== (const MemoryBase< V, P2, Dimension, RM > &rhs) const
 
bool operator!= (const MemoryBase< V, P2, Dimension, RM > &rhs) const
 
bool operator< (const MemoryBase< V, P2, Dimension, RM > &rhs) const
 
bool operator<= (const MemoryBase< V, P2, Dimension, RM > &rhs) const
 
bool operator> (const MemoryBase< V, P2, Dimension, RM > &rhs) const
 
bool operator>= (const MemoryBase< V, P2, Dimension, RM > &rhs) const
 

Private Types

enum  InternalConstants { Alignment = V::Size, AlignmentMask = Alignment - 1 }
 
typedef MemoryBase< V, Memory< V >, 1, voidBase
 

Private Member Functions

size_t calcPaddedEntriesCount (size_t x)
 

Private Attributes

size_t m_entriesCount
 
size_t m_vectorsCount
 
EntryTypem_mem
 

Friends

class MemoryBase< V, Memory< V >, 1, void >
 
class MemoryDimensionBase< V, Memory< V >, 1, void >
 

#include <Vc/Memory>

+ Inheritance diagram for ROOT::Vc::Memory< V, 0u, 0u >:
+ Collaboration diagram for ROOT::Vc::Memory< V, 0u, 0u >:

Member Typedef Documentation

template<typename V >
typedef MemoryBase<V, Memory<V>, 1, void> ROOT::Vc::Memory< V, 0u, 0u >::Base
private

Definition at line 425 of file memory.h.

template<typename V >
typedef V::EntryType ROOT::Vc::Memory< V, 0u, 0u >::EntryType

Definition at line 423 of file memory.h.

Member Enumeration Documentation

template<typename V >
enum ROOT::Vc::Memory< V, 0u, 0u >::InternalConstants
private
Enumerator
Alignment 
AlignmentMask 

Definition at line 428 of file memory.h.

Constructor & Destructor Documentation

template<typename V >
Vc_ALWAYS_INLINE ROOT::Vc::Memory< V, 0u, 0u >::Memory ( size_t  size)
inline

Allocate enough memory to access size values of type V::EntryType.

The allocated memory is aligned and padded correctly for fully vectorized access.

Parameters
sizeDetermines how many scalar values will fit into the allocated memory.

Definition at line 450 of file memory.h.

template<typename V >
template<typename Parent , typename RM >
Vc_ALWAYS_INLINE ROOT::Vc::Memory< V, 0u, 0u >::Memory ( const MemoryBase< V, Parent, 1, RM > &  rhs)
inline

Copy the memory into a new memory area.

The allocated memory is aligned and padded correctly for fully vectorized access.

Parameters
rhsThe Memory object to copy from.

Definition at line 466 of file memory.h.

template<typename V >
Vc_ALWAYS_INLINE ROOT::Vc::Memory< V, 0u, 0u >::Memory ( const Memory< V, 0u, 0u > &  rhs)
inline

Overload of the above function.

(Because C++ would otherwise not use the templated cctor and use a default-constructed cctor instead.)

Parameters
rhsThe Memory object to copy from.

Definition at line 481 of file memory.h.

template<typename V >
Vc_ALWAYS_INLINE ROOT::Vc::Memory< V, 0u, 0u >::~Memory ( )
inline

Frees the memory which was allocated in the constructor.

Definition at line 492 of file memory.h.

Member Function Documentation

template<typename V >
size_t ROOT::Vc::Memory< V, 0u, 0u >::calcPaddedEntriesCount ( size_t  x)
inlineprivate

Definition at line 435 of file memory.h.

template<typename V >
Vc_ALWAYS_INLINE Vc_PURE size_t ROOT::Vc::Memory< V, 0u, 0u >::entriesCount ( ) const
inline
Returns
the number of scalar entries in the whole array.

Definition at line 511 of file memory.h.

template<typename V >
template<typename Parent , typename RM >
Vc_ALWAYS_INLINE Memory& ROOT::Vc::Memory< V, 0u, 0u >::operator= ( const MemoryBase< V, Parent, 1, RM > &  rhs)
inline

Overwrite all entries with the values stored in rhs.

Parameters
rhsThe object to copy the data from.
Returns
reference to the modified Memory object.
Note
this function requires the vectorsCount() of both Memory objects to be equal.

Definition at line 528 of file memory.h.

template<typename V >
Vc_ALWAYS_INLINE Memory& ROOT::Vc::Memory< V, 0u, 0u >::operator= ( const Memory< V, 0u, 0u > &  rhs)
inline

Definition at line 534 of file memory.h.

template<typename V >
Vc_ALWAYS_INLINE Memory& ROOT::Vc::Memory< V, 0u, 0u >::operator= ( const EntryType rhs)
inline

Overwrite all entries with the values stored in the memory at rhs.

Parameters
rhsThe array to copy the data from.
Returns
reference to the modified Memory object.
Note
this function requires that there are entriesCount() many values accessible from rhs.

Definition at line 549 of file memory.h.

template<typename V >
void ROOT::Vc::Memory< V, 0u, 0u >::swap ( Memory< V, 0u, 0u > &  rhs)
inline

Swap the contents and size information of two Memory objects.

Parameters
rhsThe other Memory object to swap.

Definition at line 502 of file memory.h.

template<typename V >
Vc_ALWAYS_INLINE Vc_PURE size_t ROOT::Vc::Memory< V, 0u, 0u >::vectorsCount ( ) const
inline
Returns
the number of vectors in the whole array.

Definition at line 516 of file memory.h.

Friends And Related Function Documentation

template<typename V >
friend class MemoryBase< V, Memory< V >, 1, void >
friend

Definition at line 426 of file memory.h.

template<typename V >
friend class MemoryDimensionBase< V, Memory< V >, 1, void >
friend

Definition at line 427 of file memory.h.

Member Data Documentation

template<typename V >
size_t ROOT::Vc::Memory< V, 0u, 0u >::m_entriesCount
private

Definition at line 432 of file memory.h.

template<typename V >
EntryType* ROOT::Vc::Memory< V, 0u, 0u >::m_mem
private

Definition at line 434 of file memory.h.

template<typename V >
size_t ROOT::Vc::Memory< V, 0u, 0u >::m_vectorsCount
private

Definition at line 433 of file memory.h.


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