Viskores  1.0
Public Types | Public Member Functions | List of all members
viskores::worklet::Keys< T > Class Template Reference

Manage keys for a viskores::worklet::WorkletReduceByKey. More...

#include <Keys.h>

Inheritance diagram for viskores::worklet::Keys< T >:

Public Types

using KeyType = T
 
using KeyArrayHandleType = viskores::cont::ArrayHandle< KeyType >
 
using ExecLookup = viskores::exec::internal::ReduceByKeyLookup< typename KeyArrayHandleType::ReadPortalType, typename viskores::cont::ArrayHandle< viskores::Id >::ReadPortalType, typename viskores::cont::ArrayHandle< viskores::IdComponent >::ReadPortalType >
 

Public Member Functions

 Keys ()
 
template<typename KeyStorage >
 Keys (const viskores::cont::ArrayHandle< KeyType, KeyStorage > &keys, viskores::cont::DeviceAdapterId device=viskores::cont::DeviceAdapterTagAny())
 Construct a Keys class from an array of keys. More...
 
template<typename KeyArrayType >
void BuildArrays (const KeyArrayType &keys, KeysSortType sort, viskores::cont::DeviceAdapterId device=viskores::cont::DeviceAdapterTagAny())
 Build the internal arrays without modifying the input. More...
 
template<typename KeyArrayType >
void BuildArraysInPlace (KeyArrayType &keys, KeysSortType sort, viskores::cont::DeviceAdapterId device=viskores::cont::DeviceAdapterTagAny())
 Build the internal arrays and also sort the input keys. More...
 
KeyArrayHandleType GetUniqueKeys () const
 Returns an array of unique keys. More...
 
viskores::Id GetInputRange () const
 Returns the input range of a keys object when used as an input domain. More...
 
viskores::cont::ArrayHandle< viskores::IdGetSortedValuesMap () const
 Returns the array that maps each input value to an array of sorted keys. More...
 
viskores::cont::ArrayHandle< viskores::IdGetOffsets () const
 Returns an offsets array to group keys. More...
 
viskores::Id GetNumberOfValues () const
 Returns the number of input keys and values used to build this structure. More...
 
ExecLookup PrepareForInput (viskores::cont::DeviceAdapterId device, viskores::cont::Token &token) const
 
bool operator== (const viskores::worklet::Keys< KeyType > &other) const
 
bool operator!= (const viskores::worklet::Keys< KeyType > &other) const
 

Detailed Description

template<typename T>
class viskores::worklet::Keys< T >

Manage keys for a viskores::worklet::WorkletReduceByKey.

The viskores::worklet::WorkletReduceByKey worklet takes an array of keys for its input domain, finds all identical keys, and runs a worklet that produces a single value for every key given all matching values. This class is used as the associated input for the keys input domain.

Keys is templated on the key array handle type and accepts an instance of this array handle as its constructor. It builds the internal structures needed to use the keys.

The same Keys structure can be used for multiple different invokes of different or the same worklets. When used in this way, the processing done in the Keys structure is reused for all the invokes. This is more efficient than creating a different Keys structure for each invoke.

Member Typedef Documentation

◆ ExecLookup

template<typename T >
using viskores::worklet::Keys< T >::ExecLookup = viskores::exec::internal::ReduceByKeyLookup< typename KeyArrayHandleType::ReadPortalType, typename viskores::cont::ArrayHandle<viskores::Id>::ReadPortalType, typename viskores::cont::ArrayHandle<viskores::IdComponent>::ReadPortalType>

◆ KeyArrayHandleType

◆ KeyType

template<typename T >
using viskores::worklet::Keys< T >::KeyType = T

Constructor & Destructor Documentation

◆ Keys() [1/2]

template<typename T >
viskores::worklet::Keys< T >::Keys ( )
default

◆ Keys() [2/2]

template<typename T >
template<typename KeyStorage >
viskores::worklet::Keys< T >::Keys ( const viskores::cont::ArrayHandle< KeyType, KeyStorage > &  keys,
viskores::cont::DeviceAdapterId  device = viskores::cont::DeviceAdapterTagAny() 
)
inline

Construct a Keys class from an array of keys.

Given an array of keys, construct a Keys class that will manage using these keys to perform reduce-by-key operations.

The input keys object is not modified and the result is not stable sorted. This is the equivalent of calling BuildArrays(keys, KeysSortType::Unstable, device).

Member Function Documentation

◆ BuildArrays()

template<typename T >
template<typename KeyArrayType >
template VISKORES_WORKLET_TEMPLATE_EXPORT VISKORES_CONT void viskores::worklet::Keys< T >::BuildArrays ( const KeyArrayType &  keys,
KeysSortType  sort,
viskores::cont::DeviceAdapterId  device = viskores::cont::DeviceAdapterTagAny() 
)

Build the internal arrays without modifying the input.

This is more efficient for stable sorted arrays, but requires an extra copy of the keys for unstable sorting.

◆ BuildArraysInPlace()

template<typename T >
template<typename KeyArrayType >
void viskores::worklet::Keys< T >::BuildArraysInPlace ( KeyArrayType &  keys,
KeysSortType  sort,
viskores::cont::DeviceAdapterId  device = viskores::cont::DeviceAdapterTagAny() 
)

Build the internal arrays and also sort the input keys.

This is more efficient for unstable sorting, but requires an extra copy for stable sorting.

◆ GetInputRange()

template<typename T >
viskores::Id viskores::worklet::Keys< T >::GetInputRange ( ) const

Returns the input range of a keys object when used as an input domain.

This will be equal to the number of unique keys.

◆ GetNumberOfValues()

template<typename T >
viskores::Id viskores::worklet::Keys< T >::GetNumberOfValues ( ) const

Returns the number of input keys and values used to build this structure.

This is also the size of input arrays to a viskores::worklet::WorkletReduceByKey.

◆ GetOffsets()

template<typename T >
viskores::cont::ArrayHandle<viskores::Id> viskores::worklet::Keys< T >::GetOffsets ( ) const

Returns an offsets array to group keys.

Given an array of sorted keys (or more frequently values permuted to the sorting of the keys), this array of indices can be used as offsets for a viskores::cont::ArrayHandleGroupVecVariable. This is an internal array that is seldom of use to code outside the viskores::worklet::WorkletReduceByKey implementation.

◆ GetSortedValuesMap()

template<typename T >
viskores::cont::ArrayHandle<viskores::Id> viskores::worklet::Keys< T >::GetSortedValuesMap ( ) const

Returns the array that maps each input value to an array of sorted keys.

This array is used internally as the indices to a viskores::cont::ArrayHandlePermutation to order input values with the grouped keys so that they can then be grouped. This is an internal array that is seldom of use to code outside the viskores::worklet::WorkletReduceByKey implementation.

◆ GetUniqueKeys()

template<typename T >
KeyArrayHandleType viskores::worklet::Keys< T >::GetUniqueKeys ( ) const
inline

Returns an array of unique keys.

The order of keys in this array describes the order that result values will be placed in a viskores::worklet::WorkletReduceByKey.

◆ operator!=()

template<typename T >
bool viskores::worklet::Keys< T >::operator!= ( const viskores::worklet::Keys< KeyType > &  other) const
inline

◆ operator==()

template<typename T >
bool viskores::worklet::Keys< T >::operator== ( const viskores::worklet::Keys< KeyType > &  other) const
inline

◆ PrepareForInput()

template<typename T >
ExecLookup viskores::worklet::Keys< T >::PrepareForInput ( viskores::cont::DeviceAdapterId  device,
viskores::cont::Token token 
) const
inline

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