ROOT  6.06/09
Reference Guide
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ROOT::Vc::Common::InterleavedMemoryWrapper< S, V > Class Template Reference

template<typename S, typename V>
class ROOT::Vc::Common::InterleavedMemoryWrapper< S, V >

Wraps a pointer to memory with convenience functions to access it via vectors.

Parameters
SThe type of the struct.
VThe type of the vector to be returned when read. This should reflect the type of the members inside the struct.
See also
operator[]

Definition at line 155 of file interleavedmemory.h.

Public Member Functions

Vc_ALWAYS_INLINE InterleavedMemoryWrapper (S *s)
 Constructs the wrapper object. More...
 
template<typename U >
Vc_ALWAYS_INLINE Internal::EnableInterleaves< S, U, Access >::Type operator[] (VC_ALIGNED_PARAMETER(U) indexes)
 Interleaved scatter/gather access. More...
 
Vc_ALWAYS_INLINE ReadAccess operator[] (VC_ALIGNED_PARAMETER(IndexType) indexes) const
 const overload (gathers only) of the above function More...
 
Vc_ALWAYS_INLINE ReadAccess gather (VC_ALIGNED_PARAMETER(IndexType) indexes) const
 alias of the above function More...
 

Private Types

typedef V::EntryType T
 
typedef V::IndexType I
 
typedef V::AsArg VArg
 
typedef I::AsArg IndexType
 
typedef InterleavedMemoryAccess< sizeof(S)/sizeof(T), V > Access
 
typedef InterleavedMemoryReadAccess< sizeof(S)/sizeof(T), V > ReadAccess
 
typedef Internal::CopyConst< S, T >::Type Ta Vc_MAY_ALIAS
 

Private Member Functions

 VC_STATIC_ASSERT ((sizeof(S)/sizeof(T))*sizeof(T)==sizeof(S), InterleavedMemoryAccess_does_not_support_packed_structs)
 

Private Attributes

Ta *const m_data
 

#include <Vc/Memory>

Member Typedef Documentation

template<typename S , typename V >
typedef InterleavedMemoryAccess<sizeof(S) / sizeof(T), V> ROOT::Vc::Common::InterleavedMemoryWrapper< S, V >::Access
private

Definition at line 161 of file interleavedmemory.h.

template<typename S , typename V >
typedef V::IndexType ROOT::Vc::Common::InterleavedMemoryWrapper< S, V >::I
private

Definition at line 158 of file interleavedmemory.h.

template<typename S , typename V >
typedef I::AsArg ROOT::Vc::Common::InterleavedMemoryWrapper< S, V >::IndexType
private

Definition at line 160 of file interleavedmemory.h.

template<typename S , typename V >
typedef InterleavedMemoryReadAccess<sizeof(S) / sizeof(T), V> ROOT::Vc::Common::InterleavedMemoryWrapper< S, V >::ReadAccess
private

Definition at line 162 of file interleavedmemory.h.

template<typename S , typename V >
typedef V::EntryType ROOT::Vc::Common::InterleavedMemoryWrapper< S, V >::T
private

Definition at line 157 of file interleavedmemory.h.

template<typename S , typename V >
typedef V::AsArg ROOT::Vc::Common::InterleavedMemoryWrapper< S, V >::VArg
private

Definition at line 159 of file interleavedmemory.h.

template<typename S , typename V >
typedef Internal::CopyConst<S, T>::Type Ta ROOT::Vc::Common::InterleavedMemoryWrapper< S, V >::Vc_MAY_ALIAS
private

Definition at line 163 of file interleavedmemory.h.

Constructor & Destructor Documentation

template<typename S , typename V >
Vc_ALWAYS_INLINE ROOT::Vc::Common::InterleavedMemoryWrapper< S, V >::InterleavedMemoryWrapper ( S s)
inline

Constructs the wrapper object.

Parameters
sA pointer to a C-array.

Definition at line 174 of file interleavedmemory.h.

Member Function Documentation

template<typename S , typename V >
Vc_ALWAYS_INLINE ReadAccess ROOT::Vc::Common::InterleavedMemoryWrapper< S, V >::gather ( VC_ALIGNED_PARAMETER(IndexType indexes) const
inline

alias of the above function

Definition at line 250 of file interleavedmemory.h.

template<typename S , typename V >
template<typename U >
Vc_ALWAYS_INLINE Internal::EnableInterleaves<S, U, Access>::Type ROOT::Vc::Common::InterleavedMemoryWrapper< S, V >::operator[] ( VC_ALIGNED_PARAMETER(U)  indexes)
inline

Interleaved scatter/gather access.

Assuming you have a struct of floats and a vector of indexes into the array, this function can be used to access the struct entries as vectors using the minimal number of store or load instructions.

Parameters
indexesVector of indexes that determine the gather locations.
Returns
A special (magic) object that executes the loads and deinterleave on assignment to a vector tuple.

Example:

struct Foo {
float x, y, z;
};
void fillWithBar(Foo *_data, uint_v indexes)
{
Vc::InterleavedMemoryWrapper<Foo, float_v> data(_data);
const float_v x = bar(1);
const float_v y = bar(2);
const float_v z = bar(3);
data[indexes] = (x, y, z);
// it's also possible to just store a subset at the front of the struct:
data[indexes] = (x, y);
// if you want to store a single entry, use scatter:
z.scatter(_data, &Foo::x, indexes);
}
float_v normalizeStuff(Foo *_data, uint_v indexes)
{
Vc::InterleavedMemoryWrapper<Foo, float_v> data(_data);
float_v x, y, z;
(x, y, z) = data[indexes];
// it is also possible to just load a subset from the front of the struct:
// (x, y) = data[indexes];
return Vc::sqrt(x * x + y * y + z * z);
}

You may think of the gather operation (or scatter as the inverse) like this:

             Memory: {x0 y0 z0 x1 y1 z1 x2 y2 z2 x3 y3 z3 x4 y4 z4 x5 y5 z5 x6 y6 z6 x7 y7 z7 x8 y8 z8}
            indexes: [5, 0, 1, 7]
Result in (x, y, z): ({x5 x0 x1 x7}, {y5 y0 y1 y7}, {z5 z0 z1 z7})
   \warning If \p indexes contains non-unique entries on scatter, the result is undefined. If
   \c NDEBUG is not defined the implementation will assert that the \p indexes entries are unique.

Definition at line 236 of file interleavedmemory.h.

template<typename S , typename V >
Vc_ALWAYS_INLINE ReadAccess ROOT::Vc::Common::InterleavedMemoryWrapper< S, V >::operator[] ( VC_ALIGNED_PARAMETER(IndexType indexes) const
inline

const overload (gathers only) of the above function

Definition at line 244 of file interleavedmemory.h.

template<typename S , typename V >
ROOT::Vc::Common::InterleavedMemoryWrapper< S, V >::VC_STATIC_ASSERT ( (sizeof(S)/sizeof(T))*sizeof(T = =sizeof(S),
InterleavedMemoryAccess_does_not_support_packed_structs   
)
private

Member Data Documentation

template<typename S , typename V >
Ta* const ROOT::Vc::Common::InterleavedMemoryWrapper< S, V >::m_data
private

Definition at line 164 of file interleavedmemory.h.


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