Viskores  1.0
Public Types | Public Member Functions | Private Types | Static Private Attributes | List of all members
viskores::cont::ArrayHandleSOA< T > Class Template Reference

An ArrayHandle that for Vecs stores each component in a separate physical array. More...

#include <ArrayHandleSOA.h>

Inheritance diagram for viskores::cont::ArrayHandleSOA< T >:
viskores::cont::ArrayHandle< T, viskores::cont::StorageTagSOA >

Public Types

using Thisclass = typename viskores::cont::detail::GetTypeInParentheses< void(ArrayHandleSOA< T >) >::type
 
using Superclass = typename viskores::cont::detail::GetTypeInParentheses< void(ArrayHandle< T, viskores::cont::StorageTagSOA >) >::type
 
using ValueType = typename Superclass::ValueType
 
using StorageTag = typename Superclass::StorageTag
 
using StorageType = typename Superclass::StorageType
 
using ReadPortalType = typename Superclass::ReadPortalType
 
using WritePortalType = typename Superclass::WritePortalType
 
- Public Types inherited from viskores::cont::ArrayHandle< T, viskores::cont::StorageTagSOA >
using ValueType = T
 
using StorageTag = viskores::cont::StorageTagSOA
 
using StorageType = viskores::cont::internal::Storage< ValueType, StorageTag >
 
using ReadPortalType = typename StorageType::ReadPortalType
 The type of portal used when accessing data in a read-only mode. More...
 
using WritePortalType = typename StorageType::WritePortalType
 The type of portal used when accessing data in a read-write mode. More...
 

Public Member Functions

 ArrayHandleSOA ()
 
VISKORES_CONT ArrayHandleSOA (const Thisclass &src)
 
VISKORES_CONT ArrayHandleSOA (Thisclass &&src) noexcept
 
VISKORES_CONT ArrayHandleSOA (const viskores::cont::ArrayHandle< typename Superclass::ValueType, typename Superclass::StorageTag > &src)
 
VISKORES_CONT ArrayHandleSOA (viskores::cont::ArrayHandle< typename Superclass::ValueType, typename Superclass::StorageTag > &&src) noexcept
 
VISKORES_CONT ArrayHandleSOA (const std::vector< viskores::cont::internal::Buffer > &buffers)
 
VISKORES_CONT ArrayHandleSOA (std::vector< viskores::cont::internal::Buffer > &&buffers) noexcept
 
VISKORES_CONT Thisclassoperator= (const Thisclass &src)
 
VISKORES_CONT Thisclassoperator= (Thisclass &&src) noexcept
 
 ArrayHandleSOA (std::initializer_list< viskores::cont::internal::Buffer > &&componentBuffers)
 
 ArrayHandleSOA (const std::array< ComponentArrayType, NUM_COMPONENTS > &componentArrays)
 Construct an ArrayHandleSOA from a collection of component arrays. More...
 
 ArrayHandleSOA (const std::vector< ComponentArrayType > &componentArrays)
 Construct an ArrayHandleSOA from a collection of component arrays. More...
 
 ArrayHandleSOA (std::initializer_list< ComponentArrayType > &&componentArrays)
 Construct an ArrayHandleSOA from a collection of component arrays. More...
 
 ArrayHandleSOA (std::initializer_list< std::vector< ComponentType >> &&componentVectors)
 Construct an ArrayHandleSOA from a collection of component arrays. More...
 
template<typename Allocator , typename... RemainingVectors>
 ArrayHandleSOA (viskores::CopyFlag copy, const std::vector< ComponentType, Allocator > &vector0, RemainingVectors &&... componentVectors)
 Construct an ArrayHandleSOA from a collection of component arrays. More...
 
template<typename... RemainingVectors>
 ArrayHandleSOA (viskores::CopyFlag copy, std::vector< ComponentType > &&vector0, RemainingVectors &&... componentVectors)
 Construct an ArrayHandleSOA from a collection of component arrays. More...
 
 ArrayHandleSOA (std::initializer_list< const ComponentType * > componentArrays, viskores::Id length, viskores::CopyFlag copy)
 Construct an ArrayHandleSOA from a collection of component arrays. More...
 
template<typename... RemainingArrays>
 ArrayHandleSOA (viskores::Id length, viskores::CopyFlag copy, const ComponentType *array0, const RemainingArrays &... componentArrays)
 Construct an ArrayHandleSOA from a collection of component arrays. More...
 
viskores::cont::ArrayHandleBasic< ComponentTypeGetArray (viskores::IdComponent index) const
 Get a basic array representing the component for the given index. More...
 
void SetArray (viskores::IdComponent index, const ComponentArrayType &array)
 Replace a component array. More...
 
- Public Member Functions inherited from viskores::cont::ArrayHandle< T, viskores::cont::StorageTagSOA >
 ArrayHandle ()
 Constructs an empty ArrayHandle. More...
 
 ArrayHandle (const viskores::cont::ArrayHandle< ValueType, StorageTag > &src)
 Copy constructor. More...
 
 ArrayHandle (viskores::cont::ArrayHandle< ValueType, StorageTag > &&src) noexcept
 Move constructor. More...
 
 ArrayHandle (const std::vector< viskores::cont::internal::Buffer > &buffers)
 Special constructor for subclass specializations that need to set the initial state array. More...
 
 ArrayHandle (std::vector< viskores::cont::internal::Buffer > &&buffers) noexcept
 Special constructor for subclass specializations that need to set the initial state array. More...
 
 ~ArrayHandle ()
 Destructs an empty ArrayHandle. More...
 
viskores::cont::ArrayHandle< ValueType, StorageTag > & operator= (const viskores::cont::ArrayHandle< ValueType, StorageTag > &src)
 Shallow copies an ArrayHandle. More...
 
viskores::cont::ArrayHandle< ValueType, StorageTag > & operator= (viskores::cont::ArrayHandle< ValueType, StorageTag > &&src) noexcept
 Move and Assignment of an ArrayHandle. More...
 
bool operator== (const ArrayHandle< ValueType, StorageTag > &rhs) const
 Like a pointer, two ArrayHandles are considered equal if they point to the same location in memory. More...
 
bool operator== (const ArrayHandle< VT, ST > &) const
 
bool operator!= (const ArrayHandle< ValueType, StorageTag > &rhs) const
 
bool operator!= (const ArrayHandle< VT, ST > &) const
 
StorageType GetStorage () const
 Get the storage. More...
 
ReadPortalType ReadPortal () const
 Get an array portal that can be used in the control environment. More...
 
ReadPortalType ReadPortal (viskores::cont::Token &token) const
 The type of portal used when accessing data in a read-only mode. More...
 
WritePortalType WritePortal () const
 Get an array portal that can be used in the control environment. More...
 
WritePortalType WritePortal (viskores::cont::Token &token) const
 Get an array portal that can be used in the control environment. More...
 
viskores::Id GetNumberOfValues () const
 Returns the number of entries in the array. More...
 
viskores::IdComponent GetNumberOfComponentsFlat () const
 Returns the total number of components for each value in the array. More...
 
void Allocate (viskores::Id numberOfValues, viskores::CopyFlag preserve, viskores::cont::Token &token) const
 Allocates an array large enough to hold the given number of values. More...
 
void Allocate (viskores::Id numberOfValues, viskores::CopyFlag preserve=viskores::CopyFlag::Off) const
 Allocates an array large enough to hold the given number of values. More...
 
void AllocateAndFill (viskores::Id numberOfValues, const ValueType &fillValue, viskores::CopyFlag preserve, viskores::cont::Token &token) const
 Allocates an array and fills it with an initial value. More...
 
void AllocateAndFill (viskores::Id numberOfValues, const ValueType &fillValue, viskores::CopyFlag preserve=viskores::CopyFlag::Off) const
 Allocates an array and fills it with an initial value. More...
 
void Fill (const ValueType &fillValue, viskores::Id startIndex, viskores::Id endIndex, viskores::cont::Token &token) const
 Fills the array with a given value. More...
 
void Fill (const ValueType &fillValue, viskores::Id startIndex, viskores::Id endIndex) const
 Fills the array with a given value. More...
 
void Fill (const ValueType &fillValue, viskores::Id startIndex=0) const
 Fills the array with a given value. More...
 
void ReleaseResourcesExecution () const
 Releases any resources being used in the execution environment (that are not being shared by the control environment). More...
 
void ReleaseResources () const
 Releases all resources in both the control and execution environments. More...
 
ReadPortalType PrepareForInput (viskores::cont::DeviceAdapterId device, viskores::cont::Token &token) const
 Prepares this array to be used as an input to an operation in the execution environment. More...
 
WritePortalType PrepareForInPlace (viskores::cont::DeviceAdapterId device, viskores::cont::Token &token) const
 Prepares this array to be used in an in-place operation (both as input and output) in the execution environment. More...
 
WritePortalType PrepareForOutput (viskores::Id numberOfValues, viskores::cont::DeviceAdapterId device, viskores::cont::Token &token) const
 Prepares (allocates) this array to be used as an output from an operation in the execution environment. More...
 
bool IsOnDevice (viskores::cont::DeviceAdapterId device) const
 Returns true if the ArrayHandle's data is on the given device. More...
 
bool IsOnHost () const
 Returns true if the ArrayHandle's data is on the host. More...
 
void SyncControlArray () const
 Synchronizes the control array with the execution array. More...
 
void Enqueue (const viskores::cont::Token &token) const
 Enqueue a token for access to this ArrayHandle. More...
 
void DeepCopyFrom (const viskores::cont::ArrayHandle< ValueType, StorageTag > &source) const
 Deep copies the data in the array. More...
 
const std::vector< viskores::cont::internal::Buffer > & GetBuffers () const
 Returns the internal Buffer structures that hold the data. More...
 
std::vector< viskores::cont::internal::Buffer > & GetBuffers ()
 

Private Types

using ComponentType = typename viskores::VecTraits< T >::ComponentType
 
using ComponentArrayType = viskores::cont::ArrayHandle< ComponentType, viskores::cont::StorageTagBasic >
 

Static Private Attributes

static constexpr viskores::IdComponent NUM_COMPONENTS = viskores::VecTraits<T>::NUM_COMPONENTS
 

Additional Inherited Members

- Protected Member Functions inherited from viskores::cont::ArrayHandle< T, viskores::cont::StorageTagSOA >
void SetBuffer (viskores::IdComponent index, const viskores::cont::internal::Buffer &buffer)
 
void SetBuffers (const std::vector< viskores::cont::internal::Buffer > &buffers)
 
void SetBuffers (std::vector< viskores::cont::internal::Buffer > &&buffers)
 

Detailed Description

template<typename T>
class viskores::cont::ArrayHandleSOA< T >

An ArrayHandle that for Vecs stores each component in a separate physical array.

ArrayHandleSOA behaves like a regular ArrayHandle (with a basic storage) except that if you specify a ValueType of a Vec or a Vec-like, it will actually store each component in a separate physical array. When data are retrieved from the array, they are reconstructed into Vec objects as expected.

The intention of this array type is to help cover the most common ways data is lain out in memory. Typically, arrays of data are either an "array of structures" like the basic storage where you have a single array of structures (like Vec) or a "structure of arrays" where you have an array of a basic type (like float) for each component of the data being represented. The ArrayHandleSOA makes it easy to cover this second case without creating special types.

ArrayHandleSOA can be constructed from a collection of ArrayHandle with basic storage. This allows you to construct Vec arrays from components without deep copies.

Member Typedef Documentation

◆ ComponentArrayType

◆ ComponentType

template<typename T >
using viskores::cont::ArrayHandleSOA< T >::ComponentType = typename viskores::VecTraits<T>::ComponentType
private

◆ ReadPortalType

template<typename T >
using viskores::cont::ArrayHandleSOA< T >::ReadPortalType = typename Superclass::ReadPortalType

◆ StorageTag

template<typename T >
using viskores::cont::ArrayHandleSOA< T >::StorageTag = typename Superclass::StorageTag

◆ StorageType

template<typename T >
using viskores::cont::ArrayHandleSOA< T >::StorageType = typename Superclass::StorageType

◆ Superclass

template<typename T >
using viskores::cont::ArrayHandleSOA< T >::Superclass = typename viskores::cont::detail::GetTypeInParentheses<void (ArrayHandle<T, viskores::cont::StorageTagSOA>) >::type

◆ Thisclass

template<typename T >
using viskores::cont::ArrayHandleSOA< T >::Thisclass = typename viskores::cont::detail::GetTypeInParentheses<void (ArrayHandleSOA<T>) >::type

◆ ValueType

template<typename T >
using viskores::cont::ArrayHandleSOA< T >::ValueType = typename Superclass::ValueType

◆ WritePortalType

template<typename T >
using viskores::cont::ArrayHandleSOA< T >::WritePortalType = typename Superclass::WritePortalType

Constructor & Destructor Documentation

◆ ArrayHandleSOA() [1/16]

template<typename T >
viskores::cont::ArrayHandleSOA< T >::ArrayHandleSOA ( )
inline

◆ ArrayHandleSOA() [2/16]

template<typename T >
VISKORES_CONT viskores::cont::ArrayHandleSOA< T >::ArrayHandleSOA ( const Thisclass src)
inline

◆ ArrayHandleSOA() [3/16]

template<typename T >
VISKORES_CONT viskores::cont::ArrayHandleSOA< T >::ArrayHandleSOA ( Thisclass &&  src)
inlinenoexcept

◆ ArrayHandleSOA() [4/16]

template<typename T >
VISKORES_CONT viskores::cont::ArrayHandleSOA< T >::ArrayHandleSOA ( const viskores::cont::ArrayHandle< typename Superclass::ValueType, typename Superclass::StorageTag > &  src)
inline

◆ ArrayHandleSOA() [5/16]

template<typename T >
VISKORES_CONT viskores::cont::ArrayHandleSOA< T >::ArrayHandleSOA ( viskores::cont::ArrayHandle< typename Superclass::ValueType, typename Superclass::StorageTag > &&  src)
inlinenoexcept

◆ ArrayHandleSOA() [6/16]

template<typename T >
VISKORES_CONT viskores::cont::ArrayHandleSOA< T >::ArrayHandleSOA ( const std::vector< viskores::cont::internal::Buffer > &  buffers)
inlineexplicit

◆ ArrayHandleSOA() [7/16]

template<typename T >
VISKORES_CONT viskores::cont::ArrayHandleSOA< T >::ArrayHandleSOA ( std::vector< viskores::cont::internal::Buffer > &&  buffers)
inlineexplicitnoexcept

◆ ArrayHandleSOA() [8/16]

template<typename T >
viskores::cont::ArrayHandleSOA< T >::ArrayHandleSOA ( std::initializer_list< viskores::cont::internal::Buffer > &&  componentBuffers)
inline

◆ ArrayHandleSOA() [9/16]

template<typename T >
viskores::cont::ArrayHandleSOA< T >::ArrayHandleSOA ( const std::array< ComponentArrayType, NUM_COMPONENTS > &  componentArrays)
inline

Construct an ArrayHandleSOA from a collection of component arrays.

// Fill arrays...
std::array<T, 3> allComponents{ components1, components2, components3 };
viskores::cont::make_ArrayHandleSOA<viskores::Vec<T, 3>vecarray(allComponents);

◆ ArrayHandleSOA() [10/16]

template<typename T >
viskores::cont::ArrayHandleSOA< T >::ArrayHandleSOA ( const std::vector< ComponentArrayType > &  componentArrays)
inline

Construct an ArrayHandleSOA from a collection of component arrays.

// Fill arrays...
std::vector<T> allComponents{ components1, components2, components3 };
viskores::cont::make_ArrayHandleSOA<viskores::Vec<T, 3>vecarray(allComponents);

◆ ArrayHandleSOA() [11/16]

template<typename T >
viskores::cont::ArrayHandleSOA< T >::ArrayHandleSOA ( std::initializer_list< ComponentArrayType > &&  componentArrays)
inline

Construct an ArrayHandleSOA from a collection of component arrays.

// Fill arrays...
viskores::cont::make_ArrayHandleSOA<viskores::Vec<T, 3> vecarray(
{ components1, components2, components3 });

◆ ArrayHandleSOA() [12/16]

template<typename T >
viskores::cont::ArrayHandleSOA< T >::ArrayHandleSOA ( std::initializer_list< std::vector< ComponentType >> &&  componentVectors)
inline

Construct an ArrayHandleSOA from a collection of component arrays.

The data is copied from the std::vectors to the array handle.

std::vector<T> components1;
std::vector<T> components2;
std::vector<T> components3;
// Fill arrays...
{ components1, components2, components3 });

◆ ArrayHandleSOA() [13/16]

template<typename T >
template<typename Allocator , typename... RemainingVectors>
viskores::cont::ArrayHandleSOA< T >::ArrayHandleSOA ( viskores::CopyFlag  copy,
const std::vector< ComponentType, Allocator > &  vector0,
RemainingVectors &&...  componentVectors 
)
inline

Construct an ArrayHandleSOA from a collection of component arrays.

The first argument is a viskores::CopyFlag to determine whether the input arrays should be copied. The component arrays are listed as arguments. This only works if all the templated arguments are of type std::vector<ComponentType>.

std::vector<T> components1;
std::vector<T> components2;
std::vector<T> components3;
// Fill arrays...
viskores::CopyFlag::On, components1, components2, components3);

◆ ArrayHandleSOA() [14/16]

template<typename T >
template<typename... RemainingVectors>
viskores::cont::ArrayHandleSOA< T >::ArrayHandleSOA ( viskores::CopyFlag  copy,
std::vector< ComponentType > &&  vector0,
RemainingVectors &&...  componentVectors 
)
inline

Construct an ArrayHandleSOA from a collection of component arrays.

The first argument is a viskores::CopyFlag to determine whether the input arrays should be copied. The component arrays are listed as arguments. This only works if all the templated arguments are rvalues of type std::vector<ComponentType>.

std::vector<T> components1;
std::vector<T> components2;
std::vector<T> components3;
// Fill arrays...
std::move(components1),
std::move(components2),
std::move(components3);

◆ ArrayHandleSOA() [15/16]

template<typename T >
viskores::cont::ArrayHandleSOA< T >::ArrayHandleSOA ( std::initializer_list< const ComponentType * >  componentArrays,
viskores::Id  length,
viskores::CopyFlag  copy 
)
inline

Construct an ArrayHandleSOA from a collection of component arrays.

T* components1;
T* components2;
T* components3;
// Fill arrays...
{ components1, components2, components3 }, size, viskores::CopyFlag::On);

◆ ArrayHandleSOA() [16/16]

template<typename T >
template<typename... RemainingArrays>
viskores::cont::ArrayHandleSOA< T >::ArrayHandleSOA ( viskores::Id  length,
viskores::CopyFlag  copy,
const ComponentType array0,
const RemainingArrays &...  componentArrays 
)
inline

Construct an ArrayHandleSOA from a collection of component arrays.

The component arrays are listed as arguments. This only works if all the templated arguments are of type ComponentType*.

T* components1;
T* components2;
T* components3;
// Fill arrays...
size, viskores::CopyFlag::On, components1, components2, components3);

Member Function Documentation

◆ GetArray()

template<typename T >
viskores::cont::ArrayHandleBasic<ComponentType> viskores::cont::ArrayHandleSOA< T >::GetArray ( viskores::IdComponent  index) const
inline

Get a basic array representing the component for the given index.

◆ operator=() [1/2]

template<typename T >
VISKORES_CONT Thisclass& viskores::cont::ArrayHandleSOA< T >::operator= ( const Thisclass src)
inline

◆ operator=() [2/2]

template<typename T >
VISKORES_CONT Thisclass& viskores::cont::ArrayHandleSOA< T >::operator= ( Thisclass &&  src)
inlinenoexcept

◆ SetArray()

template<typename T >
void viskores::cont::ArrayHandleSOA< T >::SetArray ( viskores::IdComponent  index,
const ComponentArrayType array 
)
inline

Replace a component array.

Member Data Documentation

◆ NUM_COMPONENTS

template<typename T >
constexpr viskores::IdComponent viskores::cont::ArrayHandleSOA< T >::NUM_COMPONENTS = viskores::VecTraits<T>::NUM_COMPONENTS
staticconstexprprivate

The documentation for this class was generated from the following file:
viskores::CopyFlag::Off
@ Off
viskores::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:313
viskores::CopyFlag::On
@ On
viskores::cont::ArrayHandleSOA
An ArrayHandle that for Vecs stores each component in a separate physical array.
Definition: ArrayHandleSOA.h:265