VTK-m  1.5
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
vtkm::cont::ArrayHandle< T, StorageTag_ > Class Template Reference

Manages an array-worth of data. More...

#include <ArrayHandle.h>

Inheritance diagram for vtkm::cont::ArrayHandle< T, StorageTag_ >:
vtkm::cont::ArrayHandleCartesianProduct< AxisIndexArrayCells, AxisIndexArrayCells, AxisIndexArrayCells > vtkm::cont::ArrayHandleCartesianProduct< AxisIndexArrayPoints, AxisIndexArrayPoints, AxisIndexArrayPoints > vtkm::cont::ArrayHandleImplicit< detail::PhiloxFunctor > vtkm::cont::ArrayHandleCartesianProduct< FirstHandleType, SecondHandleType, ThirdHandleType > vtkm::cont::ArrayHandleDecorator< DecoratorImplT, ArrayTs > vtkm::cont::ArrayHandleDiscard< ValueType_ > vtkm::cont::ArrayHandleImplicit< FunctorType > vtkm::cont::ArrayHandleZip< FirstHandleType, SecondHandleType >

Classes

struct  ExecutionTypes
 
class  InternalStruct
 

Public Types

using StorageType = vtkm::cont::internal::Storage< T, StorageTag_ >
 
using ValueType = T
 
using StorageTag = StorageTag_
 
using WritePortalType = vtkm::cont::internal::ArrayPortalCheck< typename StorageType::PortalType >
 
using ReadPortalType = vtkm::cont::internal::ArrayPortalCheck< typename StorageType::PortalConstType >
 
using instead = typename StorageType::PortalType
 
using instead = typename StorageType::PortalConstType
 

Public Member Functions

VTKM_CONT ArrayHandle ()
 Constructs an empty ArrayHandle. More...
 
 ArrayHandle (const vtkm::cont::ArrayHandle< ValueType, StorageTag > &src)
 Copy constructor. More...
 
 ArrayHandle (vtkm::cont::ArrayHandle< ValueType, StorageTag > &&src) noexcept
 Move constructor. More...
 
 ArrayHandle (const StorageType &storage)
 Special constructor for subclass specializations that need to set the initial state of the control array. More...
 
 ArrayHandle (StorageType &&storage) noexcept
 Special constructor for subclass specializations that need to set the initial state of the control array. More...
 
 ~ArrayHandle ()
 Destructs an empty ArrayHandle. More...
 
VTKM_CONT vtkm::cont::ArrayHandle< ValueType, StorageTag > & operator= (const vtkm::cont::ArrayHandle< ValueType, StorageTag > &src)
 Copies an ArrayHandle. More...
 
VTKM_CONT vtkm::cont::ArrayHandle< ValueType, StorageTag > & operator= (vtkm::cont::ArrayHandle< ValueType, StorageTag > &&src) noexcept
 Move and Assignment of an ArrayHandle. More...
 
VTKM_CONT 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...
 
VTKM_CONT bool operator!= (const ArrayHandle< ValueType, StorageTag > &rhs) const
 
template<typename VT , typename ST >
VTKM_CONT bool operator== (const ArrayHandle< VT, ST > &) const
 
template<typename VT , typename ST >
VTKM_CONT bool operator!= (const ArrayHandle< VT, ST > &) const
 
VTKM_CONT StorageTypeGetStorage ()
 Get the storage. More...
 
const VTKM_CONT StorageTypeGetStorage () const
 Get the storage. More...
 
VTKM_CONT VTKM_DEPRECATED (1.6, "Use ArrayHandle::WritePortal() instead. " "Note that the returned portal will lock the array while it is in scope.") VTKM_CONT VTKM_DEPRECATED(1.6
 Get the array portal of the control array. More...
 
VTKM_CONT Use ArrayHandle::ReadPortal () instead. " "Note that the returned portal will lock the array while it is in scope.") VTKM_CONT ReadPortalType ReadPortal() const
 @{ More...
 
VTKM_CONT WritePortalType WritePortal () const
 @} More...
 
VTKM_CONT vtkm::Id GetNumberOfValues () const
 @} More...
 
VTKM_CONT void Allocate (vtkm::Id numberOfValues)
 Allocates an array large enough to hold the given number of values. More...
 
void Shrink (vtkm::Id numberOfValues)
 Reduces the size of the array without changing its values. More...
 
VTKM_CONT void ReleaseResourcesExecution ()
 Releases any resources being used in the execution environment (that are not being shared by the control environment). More...
 
VTKM_CONT void ReleaseResources ()
 Releases all resources in both the control and execution environments. More...
 
template<typename DeviceAdapterTag >
VTKM_CONT ExecutionTypes< DeviceAdapterTag >::PortalConst PrepareForInput (DeviceAdapterTag, vtkm::cont::Token &token) const
 Prepares this array to be used as an input to an operation in the execution environment. More...
 
template<typename DeviceAdapterTag >
VTKM_CONT ExecutionTypes< DeviceAdapterTag >::Portal PrepareForOutput (vtkm::Id numberOfValues, DeviceAdapterTag, vtkm::cont::Token &token)
 Prepares (allocates) this array to be used as an output from an operation in the execution environment. More...
 
template<typename DeviceAdapterTag >
VTKM_CONT ExecutionTypes< DeviceAdapterTag >::Portal PrepareForInPlace (DeviceAdapterTag, vtkm::cont::Token &token)
 Prepares this array to be used in an in-place operation (both as input and output) in the execution environment. More...
 
template<typename DeviceAdapterTag >
VTKM_CONT VTKM_DEPRECATED (1.6, "PrepareForInput now requires a vtkm::cont::Token object.") typename ExecutionTypes< DeviceAdapterTag >
 
template<typename DeviceAdapterTag >
VTKM_CONT VTKM_DEPRECATED (1.6, "PrepareForInPlace now requires a vtkm::cont::Token object.") typename ExecutionTypes< DeviceAdapterTag >
 
VTKM_CONT DeviceAdapterId GetDeviceAdapterId () const
 Returns the DeviceAdapterId for the current device. More...
 
VTKM_CONT void SyncControlArray () const
 Synchronizes the control array with the execution array. More...
 
VTKM_CONT void Enqueue (const vtkm::cont::Token &token) const
 Enqueue a token for access to this ArrayHandle. More...
 

Private Types

using ExecutionManagerType = vtkm::cont::internal::ArrayHandleExecutionManagerBase< T, StorageTag_ >
 
using MutexType = std::mutex
 
using LockType = std::unique_lock< MutexType >
 

Private Member Functions

LockType GetLock () const
 Acquires a lock on the internals of this ArrayHandle. More...
 
VTKM_CONT bool CanRead (const LockType &lock, const vtkm::cont::Token &token) const
 Returns true if read operations can currently be performed. More...
 
VTKM_CONT bool CanWrite (const LockType &lock, const vtkm::cont::Token &token) const
 Returns true if write operations can currently be performed. More...
 
VTKM_CONT void WaitToRead (LockType &lock, vtkm::cont::Token &token) const
 Will block the current thread until a read can be performed. More...
 
VTKM_CONT void WaitToWrite (LockType &lock, vtkm::cont::Token &token, bool fakeRead=false) const
 Will block the current thread until a write can be performed. More...
 
template<typename DeviceAdapterTag >
VTKM_CONT void PrepareForDevice (LockType &lock, vtkm::cont::Token &token, DeviceAdapterTag) const
 Gets this array handle ready to interact with the given device. More...
 
VTKM_CONT void SyncControlArray (LockType &lock, vtkm::cont::Token &token) const
 Synchronizes the control array with the execution array. More...
 
vtkm::Id GetNumberOfValues (LockType &lock) const
 
VTKM_CONT void ReleaseResourcesExecutionInternal (LockType &lock, vtkm::cont::Token &token) const
 
VTKM_CONT void Enqueue (const LockType &lock, const vtkm::cont::Token &token) const
 
VTKM_CONT ArrayHandle (const std::shared_ptr< InternalStruct > &i)
 

Private Attributes

std::shared_ptr< InternalStructInternals
 

Detailed Description

template<typename T, typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
class vtkm::cont::ArrayHandle< T, StorageTag_ >

Manages an array-worth of data.

ArrayHandle manages as array of data that can be manipulated by VTKm algorithms. The ArrayHandle may have up to two copies of the array, one for the control environment and one for the execution environment, although depending on the device and how the array is being used, the ArrayHandle will only have one copy when possible.

An ArrayHandle can be constructed one of two ways. Its default construction creates an empty, unallocated array that can later be allocated and filled either by the user or a VTKm algorithm. The ArrayHandle can also be constructed with iterators to a user's array. In this case the ArrayHandle will keep a reference to this array but will throw an exception if asked to re-allocate to a larger size.

ArrayHandle behaves like a shared smart pointer in that when it is copied each copy holds a reference to the same array. These copies are reference counted so that when all copies of the ArrayHandle are destroyed, any allocated memory is released.

Member Typedef Documentation

◆ ExecutionManagerType

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
using vtkm::cont::ArrayHandle< T, StorageTag_ >::ExecutionManagerType = vtkm::cont::internal::ArrayHandleExecutionManagerBase<T, StorageTag_>
private

◆ instead [1/2]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
using vtkm::cont::ArrayHandle< T, StorageTag_ >::instead = typename StorageType::PortalType

◆ instead [2/2]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
using vtkm::cont::ArrayHandle< T, StorageTag_ >::instead = typename StorageType::PortalConstType

◆ LockType

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
using vtkm::cont::ArrayHandle< T, StorageTag_ >::LockType = std::unique_lock<MutexType>
private

◆ MutexType

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
using vtkm::cont::ArrayHandle< T, StorageTag_ >::MutexType = std::mutex
private

◆ ReadPortalType

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
using vtkm::cont::ArrayHandle< T, StorageTag_ >::ReadPortalType = vtkm::cont::internal::ArrayPortalCheck<typename StorageType::PortalConstType>

◆ StorageTag

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
using vtkm::cont::ArrayHandle< T, StorageTag_ >::StorageTag = StorageTag_

◆ StorageType

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
using vtkm::cont::ArrayHandle< T, StorageTag_ >::StorageType = vtkm::cont::internal::Storage<T, StorageTag_>

◆ ValueType

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
using vtkm::cont::ArrayHandle< T, StorageTag_ >::ValueType = T

◆ WritePortalType

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
using vtkm::cont::ArrayHandle< T, StorageTag_ >::WritePortalType = vtkm::cont::internal::ArrayPortalCheck<typename StorageType::PortalType>

Constructor & Destructor Documentation

◆ ArrayHandle() [1/6]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT vtkm::cont::ArrayHandle< T, StorageTag_ >::ArrayHandle ( )

Constructs an empty ArrayHandle.

Typically used for output or intermediate arrays that will be filled by a VTKm algorithm.

◆ ArrayHandle() [2/6]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
vtkm::cont::ArrayHandle< T, StorageTag_ >::ArrayHandle ( const vtkm::cont::ArrayHandle< ValueType, StorageTag > &  src)

Copy constructor.

Implemented so that it is defined exclusively in the control environment. If there is a separate device for the execution environment (for example, with CUDA), then the automatically generated copy constructor could be created for all devices, and it would not be valid for all devices.

◆ ArrayHandle() [3/6]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
vtkm::cont::ArrayHandle< T, StorageTag_ >::ArrayHandle ( vtkm::cont::ArrayHandle< ValueType, StorageTag > &&  src)
noexcept

Move constructor.

Implemented so that it is defined exclusively in the control environment. If there is a separate device for the execution environment (for example, with CUDA), then the automatically generated move constructor could be created for all devices, and it would not be valid for all devices.

◆ ArrayHandle() [4/6]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
vtkm::cont::ArrayHandle< T, StorageTag_ >::ArrayHandle ( const StorageType storage)

Special constructor for subclass specializations that need to set the initial state of the control array.

When this constructor is used, it is assumed that the control array is valid.

◆ ArrayHandle() [5/6]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
vtkm::cont::ArrayHandle< T, StorageTag_ >::ArrayHandle ( StorageType &&  storage)
noexcept

Special constructor for subclass specializations that need to set the initial state of the control array.

When this constructor is used, it is assumed that the control array is valid.

◆ ~ArrayHandle()

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
vtkm::cont::ArrayHandle< T, StorageTag_ >::~ArrayHandle ( )

Destructs an empty ArrayHandle.

Implemented so that it is defined exclusively in the control environment. If there is a separate device for the execution environment (for example, with CUDA), then the automatically generated destructor could be created for all devices, and it would not be valid for all devices.

◆ ArrayHandle() [6/6]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT vtkm::cont::ArrayHandle< T, StorageTag_ >::ArrayHandle ( const std::shared_ptr< InternalStruct > &  i)
inlineprivate

Member Function Documentation

◆ Allocate()

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT void vtkm::cont::ArrayHandle< T, StorageTag_ >::Allocate ( vtkm::Id  numberOfValues)
inline

Allocates an array large enough to hold the given number of values.

The allocation may be done on an already existing array, but can wipe out any data already in the array. This method can throw ErrorBadAllocation if the array cannot be allocated or ErrorBadValue if the allocation is not feasible (for example, the array storage is read-only).

◆ ArrayHandle::ReadPortal()

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT Use vtkm::cont::ArrayHandle< T, StorageTag_ >::ArrayHandle::ReadPortal ( ) const

@{

Get an array portal that can be used in the control environment.

The returned array can be used in the control environment to read values from the array. (It is not possible to write to the returned portal. That is Get will work on the portal, but Set will not.)

Note: The returned portal cannot be used in the execution environment. This is because the portal will not work on some devices like GPUs. To get a portal that will work in the execution environment, use PrepareForInput.

◆ CanRead()

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT bool vtkm::cont::ArrayHandle< T, StorageTag_ >::CanRead ( const LockType lock,
const vtkm::cont::Token token 
) const
private

Returns true if read operations can currently be performed.

◆ CanWrite()

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT bool vtkm::cont::ArrayHandle< T, StorageTag_ >::CanWrite ( const LockType lock,
const vtkm::cont::Token token 
) const
private

Returns true if write operations can currently be performed.

◆ Enqueue() [1/2]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT void vtkm::cont::ArrayHandle< T, StorageTag_ >::Enqueue ( const LockType lock,
const vtkm::cont::Token token 
) const
private

◆ Enqueue() [2/2]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT void vtkm::cont::ArrayHandle< T, StorageTag_ >::Enqueue ( const vtkm::cont::Token token) const

Enqueue a token for access to this ArrayHandle.

This method places the given Token into the queue of Tokens waiting for access to this ArrayHandle and then returns immediately. When this token is later used to get data from this ArrayHandle (for example, in a call to PrepareForInput), it will use this place in the queue while waiting for access.

This method is to be used to ensure that a set of accesses to an ArrayHandle that happen on multiple threads occur in a specified order. For example, if you spawn of a job to modify data in an ArrayHandle and then spawn off a job that reads that same data, you need to make sure that the first job gets access to the ArrayHandle before the second. If they both just attempt to call their respective Prepare methods, there is no guarantee which order they will occur. Having the spawning thread first call this method will ensure the order.

Warning
After calling this method it is required to subsequently call a method like one of the Prepare methods that attaches the token to this ArrayHandle. Otherwise, the enqueued token will block any subsequent access to the ArrayHandle, even if the Token is destroyed.

◆ GetDeviceAdapterId()

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT DeviceAdapterId vtkm::cont::ArrayHandle< T, StorageTag_ >::GetDeviceAdapterId ( ) const
inline

Returns the DeviceAdapterId for the current device.

If there is no device with an up-to-date copy of the data, VTKM_DEVICE_ADAPTER_UNDEFINED is returned.

Note that in a multithreaded environment the validity of this result can change.

◆ GetLock()

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
LockType vtkm::cont::ArrayHandle< T, StorageTag_ >::GetLock ( ) const
inlineprivate

Acquires a lock on the internals of this ArrayHandle.

The calling function should keep the returned lock and let it go out of scope when the lock is no longer needed.

◆ GetNumberOfValues() [1/2]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT vtkm::Id vtkm::cont::ArrayHandle< T, StorageTag_ >::GetNumberOfValues ( ) const
inline

@}

Returns the number of entries in the array.

◆ GetNumberOfValues() [2/2]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
vtkm::Id vtkm::cont::ArrayHandle< T, StorageTag_ >::GetNumberOfValues ( LockType lock) const
private

◆ GetStorage() [1/2]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT StorageType& vtkm::cont::ArrayHandle< T, StorageTag_ >::GetStorage ( )

Get the storage.

◆ GetStorage() [2/2]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
const VTKM_CONT StorageType& vtkm::cont::ArrayHandle< T, StorageTag_ >::GetStorage ( ) const

Get the storage.

◆ operator!=() [1/2]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT bool vtkm::cont::ArrayHandle< T, StorageTag_ >::operator!= ( const ArrayHandle< ValueType, StorageTag > &  rhs) const
inline

◆ operator!=() [2/2]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
template<typename VT , typename ST >
VTKM_CONT bool vtkm::cont::ArrayHandle< T, StorageTag_ >::operator!= ( const ArrayHandle< VT, ST > &  ) const
inline

◆ operator=() [1/2]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT vtkm::cont::ArrayHandle<ValueType, StorageTag>& vtkm::cont::ArrayHandle< T, StorageTag_ >::operator= ( const vtkm::cont::ArrayHandle< ValueType, StorageTag > &  src)

Copies an ArrayHandle.

◆ operator=() [2/2]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT vtkm::cont::ArrayHandle<ValueType, StorageTag>& vtkm::cont::ArrayHandle< T, StorageTag_ >::operator= ( vtkm::cont::ArrayHandle< ValueType, StorageTag > &&  src)
noexcept

Move and Assignment of an ArrayHandle.

◆ operator==() [1/2]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT bool vtkm::cont::ArrayHandle< T, StorageTag_ >::operator== ( const ArrayHandle< ValueType, StorageTag > &  rhs) const
inline

Like a pointer, two ArrayHandles are considered equal if they point to the same location in memory.

◆ operator==() [2/2]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
template<typename VT , typename ST >
VTKM_CONT bool vtkm::cont::ArrayHandle< T, StorageTag_ >::operator== ( const ArrayHandle< VT, ST > &  ) const
inline

◆ PrepareForDevice()

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
template<typename DeviceAdapterTag >
VTKM_CONT void vtkm::cont::ArrayHandle< T, StorageTag_ >::PrepareForDevice ( LockType lock,
vtkm::cont::Token token,
DeviceAdapterTag   
) const
private

Gets this array handle ready to interact with the given device.

If the array handle has already interacted with this device, then this method does nothing. Although the internal state of this class can change, the method is declared const because logically the data does not.

◆ PrepareForInPlace()

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
template<typename DeviceAdapterTag >
VTKM_CONT ExecutionTypes<DeviceAdapterTag>::Portal vtkm::cont::ArrayHandle< T, StorageTag_ >::PrepareForInPlace ( DeviceAdapterTag  ,
vtkm::cont::Token token 
)

Prepares this array to be used in an in-place operation (both as input and output) in the execution environment.

If necessary, copies data to the execution environment. Can throw an exception if this array does not yet contain any data. Returns a portal that can be used in code running in the execution environment.

The Token object provided will be attached to this ArrayHandle. The returned portal is guaranteed to be valid while the Token is still attached and in scope. Other operations on this ArrayHandle that would invalidate the returned portal will block until the Token is released. Likewise, this method will block if another Token is already attached. This can potentially lead to deadlocks.

◆ PrepareForInput()

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
template<typename DeviceAdapterTag >
VTKM_CONT ExecutionTypes<DeviceAdapterTag>::PortalConst vtkm::cont::ArrayHandle< T, StorageTag_ >::PrepareForInput ( DeviceAdapterTag  ,
vtkm::cont::Token token 
) const

Prepares this array to be used as an input to an operation in the execution environment.

If necessary, copies data to the execution environment. Can throw an exception if this array does not yet contain any data. Returns a portal that can be used in code running in the execution environment.

The Token object provided will be attached to this ArrayHandle. The returned portal is guaranteed to be valid while the Token is still attached and in scope. Other operations on this ArrayHandle that would invalidate the returned portal will block until the Token is released. Likewise, this method will block if another Token is already attached. This can potentially lead to deadlocks.

◆ PrepareForOutput()

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
template<typename DeviceAdapterTag >
VTKM_CONT ExecutionTypes<DeviceAdapterTag>::Portal vtkm::cont::ArrayHandle< T, StorageTag_ >::PrepareForOutput ( vtkm::Id  numberOfValues,
DeviceAdapterTag  ,
vtkm::cont::Token token 
)

Prepares (allocates) this array to be used as an output from an operation in the execution environment.

The internal state of this class is set to have valid data in the execution array with the assumption that the array will be filled soon (i.e. before any other methods of this object are called). Returns a portal that can be used in code running in the execution environment.

The Token object provided will be attached to this ArrayHandle. The returned portal is guaranteed to be valid while the Token is still attached and in scope. Other operations on this ArrayHandle that would invalidate the returned portal will block until the Token is released. Likewise, this method will block if another Token is already attached. This can potentially lead to deadlocks.

◆ ReleaseResources()

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT void vtkm::cont::ArrayHandle< T, StorageTag_ >::ReleaseResources ( )
inline

Releases all resources in both the control and execution environments.

◆ ReleaseResourcesExecution()

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT void vtkm::cont::ArrayHandle< T, StorageTag_ >::ReleaseResourcesExecution ( )
inline

Releases any resources being used in the execution environment (that are not being shared by the control environment).

◆ ReleaseResourcesExecutionInternal()

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT void vtkm::cont::ArrayHandle< T, StorageTag_ >::ReleaseResourcesExecutionInternal ( LockType lock,
vtkm::cont::Token token 
) const
inlineprivate

◆ Shrink()

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
void vtkm::cont::ArrayHandle< T, StorageTag_ >::Shrink ( vtkm::Id  numberOfValues)

Reduces the size of the array without changing its values.

This method allows you to resize the array without reallocating it. The number of entries in the array is changed to numberOfValues. The data in the array (from indices 0 to numberOfValues - 1) are the same, but numberOfValues must be equal or less than the preexisting size (returned from GetNumberOfValues). That is, this method can only be used to shorten the array, not lengthen.

◆ SyncControlArray() [1/2]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT void vtkm::cont::ArrayHandle< T, StorageTag_ >::SyncControlArray ( ) const
inline

Synchronizes the control array with the execution array.

If either the user array or control array is already valid, this method does nothing (because the data is already available in the control environment). Although the internal state of this class can change, the method is declared const because logically the data does not.

◆ SyncControlArray() [2/2]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT void vtkm::cont::ArrayHandle< T, StorageTag_ >::SyncControlArray ( LockType lock,
vtkm::cont::Token token 
) const
private

Synchronizes the control array with the execution array.

If either the user array or control array is already valid, this method does nothing (because the data is already available in the control environment). Although the internal state of this class can change, the method is declared const because logically the data does not.

◆ VTKM_DEPRECATED() [1/3]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
template<typename DeviceAdapterTag >
VTKM_CONT vtkm::cont::ArrayHandle< T, StorageTag_ >::VTKM_DEPRECATED ( 1.  6,
"PrepareForInPlace now requires a vtkm::cont::Token object."   
)
inline

◆ VTKM_DEPRECATED() [2/3]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
template<typename DeviceAdapterTag >
VTKM_CONT vtkm::cont::ArrayHandle< T, StorageTag_ >::VTKM_DEPRECATED ( 1.  6,
"PrepareForInput now requires a vtkm::cont::Token object."   
)
inline

◆ VTKM_DEPRECATED() [3/3]

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT vtkm::cont::ArrayHandle< T, StorageTag_ >::VTKM_DEPRECATED ( 1.  6,
"Use ArrayHandle< T, StorageTag_ >::WritePortal() instead. " "Note that the returned portal will lock the array while it is in scope."   
)

Get the array portal of the control array.

Since worklet invocations are asynchronous and this routine is a synchronization point, exceptions maybe thrown for errors from previously executed worklets.

Deprecated:
Use WritePortal instead. Note that the portal returned from WritePortal will disallow any other reads or writes to the array while it is in scope.

Get the array portal of the control array. Since worklet invocations are asynchronous and this routine is a synchronization point, exceptions maybe thrown for errors from previously executed worklets.

Deprecated:
Use ReadPortal instead. Note that the portal returned from ReadPortal will disallow any writes to the array while it is in scope.

◆ WaitToRead()

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT void vtkm::cont::ArrayHandle< T, StorageTag_ >::WaitToRead ( LockType lock,
vtkm::cont::Token token 
) const
private

Will block the current thread until a read can be performed.

◆ WaitToWrite()

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT void vtkm::cont::ArrayHandle< T, StorageTag_ >::WaitToWrite ( LockType lock,
vtkm::cont::Token token,
bool  fakeRead = false 
) const
private

Will block the current thread until a write can be performed.

◆ WritePortal()

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
VTKM_CONT WritePortalType vtkm::cont::ArrayHandle< T, StorageTag_ >::WritePortal ( ) const

@}

@{

Get an array portal that can be used in the control environment.

The returned array can be used in the control environment to reand and write values to the array.

Note: The returned portal cannot be used in the execution environment. This is because the portal will not work on some devices like GPUs. To get a portal that will work in the execution environment, use PrepareForInput.

Member Data Documentation

◆ Internals

template<typename T , typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
std::shared_ptr<InternalStruct> vtkm::cont::ArrayHandle< T, StorageTag_ >::Internals
private

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