Go to the documentation of this file.
10 #ifndef vtk_m_worklet_Keys_h
11 #define vtk_m_worklet_Keys_h
35 #include <vtkm/worklet/vtkm_worklet_export.h>
47 class VTKM_WORKLET_EXPORT KeysBase
50 KeysBase(
const KeysBase&) =
default;
51 KeysBase& operator=(
const KeysBase&) =
default;
52 ~KeysBase() =
default;
55 vtkm::Id GetInputRange()
const {
return this->Counts.GetNumberOfValues(); }
67 vtkm::Id GetNumberOfValues()
const {
return this->SortedValuesMap.GetNumberOfValues(); }
69 using ExecLookup = vtkm::exec::internal::ReduceByKeyLookupBase<
76 return ExecLookup(this->SortedValuesMap.PrepareForInput(device, token),
77 this->Offsets.PrepareForInput(device, token),
78 this->Counts.PrepareForInput(device, token));
82 bool operator==(
const vtkm::worklet::internal::KeysBase& other)
const
84 return ((this->SortedValuesMap == other.SortedValuesMap) && (this->Offsets == other.Offsets) &&
85 (this->Counts == other.Counts));
89 bool operator!=(
const vtkm::worklet::internal::KeysBase& other)
const
91 return !(*
this == other);
130 template <
typename T>
149 template <
typename KeyStorage>
159 template <
typename KeyArrayType>
161 const KeyArrayType& keys,
168 template <
typename KeyArrayType>
177 using ExecLookup = vtkm::exec::internal::ReduceByKeyLookup<
178 typename KeyArrayHandleType::ReadPortalType,
185 return ExecLookup(this->UniqueKeys.PrepareForInput(device, token),
186 this->SortedValuesMap.PrepareForInput(device, token),
187 this->Offsets.PrepareForInput(device, token),
188 this->Counts.PrepareForInput(device, token));
194 return ((this->UniqueKeys == other.UniqueKeys) &&
195 (this->SortedValuesMap == other.SortedValuesMap) && (this->Offsets == other.Offsets) &&
196 (this->Counts == other.Counts));
204 KeyArrayHandleType UniqueKeys;
206 template <
typename KeyArrayType>
209 template <
typename KeyArrayType>
210 VTKM_CONT void BuildArraysInternalStable(
const KeyArrayType& keys,
215 template <
typename T>
221 template <
typename KeyType>
223 -> decltype(inputDomain.GetInputRange())
225 return inputDomain.GetInputRange();
228 template <
typename KeyType>
230 -> decltype(inputDomain->GetInputRange())
232 return inputDomain->GetInputRange();
235 inline auto SchedulingRange(
const vtkm::worklet::internal::KeysBase& inputDomain)
236 -> decltype(inputDomain.GetInputRange())
238 return inputDomain.GetInputRange();
241 inline auto SchedulingRange(
const vtkm::worklet::internal::KeysBase*
const inputDomain)
242 -> decltype(inputDomain->GetInputRange())
244 return inputDomain->GetInputRange();
262 template <
typename KeyType>
266 std::is_base_of<vtkm::worklet::internal::KeysBase, typename std::decay<KeyType>::type>
::value;
269 template <
typename KeyType,
typename Device>
282 if (
object != inputDomain)
287 return object.PrepareForInput(Device(), token);
292 template <
typename InputDomainType>
297 template <
typename ArrayHandleType,
typename Device>
311 const vtkm::worklet::internal::KeysBase& keys,
316 if (
object.GetNumberOfValues() != keys.GetNumberOfValues())
332 template <
typename ArrayHandleType,
typename Device>
346 const vtkm::worklet::internal::KeysBase& keys,
351 if (
object.GetNumberOfValues() != keys.GetNumberOfValues())
367 template <
typename ArrayHandleType,
typename Device>
381 const vtkm::worklet::internal::KeysBase& keys,
389 object.PrepareForOutput(keys.GetNumberOfValues(), Device(), token);
398 return groupedArray.
PrepareForOutput(keys.GetInputRange(), Device(), token);
405 #ifndef vtk_m_worklet_Keys_cxx
407 #define VTK_M_KEYS_EXPORT(T) \
408 extern template class VTKM_WORKLET_TEMPLATE_EXPORT vtkm::worklet::Keys<T>; \
409 extern template VTKM_WORKLET_TEMPLATE_EXPORT VTKM_CONT void vtkm::worklet::Keys<T>::BuildArrays( \
410 const vtkm::cont::ArrayHandle<T>& keys, \
411 vtkm::worklet::KeysSortType sort, \
412 vtkm::cont::DeviceAdapterId device)
421 #ifdef VTKM_USE_64BIT_IDS
425 #undef VTK_M_KEYS_EXPORT
427 #endif // !vtk_m_worklet_Keys_cxx
429 #endif //vtk_m_worklet_Keys_h
typename ContObjectType::ReadPortalType ExecObjectType
The type used in the execution environment.
Definition: Transport.h:48
ArrayHandleType ContObjectType
Definition: Keys.h:337
ArrayHandleType ContObjectType
Definition: Keys.h:372
Groups connected points that have the same field value.
Definition: Atomic.h:19
VTKM_CONT ReadPortalType PrepareForInput(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Prepares this array to be used as an input to an operation in the execution environment.
Definition: ArrayHandle.h:574
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
VTKM_CONT ExecObjectType operator()(ContObjectType object, const vtkm::worklet::internal::KeysBase &keys, vtkm::Id, vtkm::Id, vtkm::cont::Token &token) const
Definition: Keys.h:380
VTKM_CONT ExecLookup PrepareForInput(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Definition: Keys.h:182
Fancy array handle that groups values into vectors of different sizes.
Definition: ArrayHandleGroupVecVariable.h:255
typename GroupedArrayType::WritePortalType ExecObjectType
Definition: Keys.h:343
KeyType ContObjectType
Definition: Keys.h:272
VTKM_CONT Keys(const vtkm::cont::ArrayHandle< KeyType, KeyStorage > &keys, vtkm::cont::DeviceAdapterId device=vtkm::cont::DeviceAdapterTagAny())
Construct a Keys class from an array of keys.
Definition: Keys.h:150
VTKM_CONT bool operator==(const vtkm::worklet::Keys< KeyType > &other) const
Definition: Keys.h:192
VTKM_CONT WritePortalType PrepareForInPlace(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Prepares this array to be used in an in-place operation (both as input and output) in the execution e...
Definition: ArrayHandle.h:593
typename StorageType::ReadPortalType ReadPortalType
Definition: ArrayHandle.h:294
vtkm::UInt32 HashType
Definition: Hash.h:20
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
typename ContObjectType::ExecLookup ExecObjectType
Definition: Keys.h:273
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
Transport tag for input values in a reduce by key.
Definition: TransportTagKeyedValuesIn.h:28
VTKM_CONT ExecObjectType operator()(const ContObjectType &object, const vtkm::worklet::internal::KeysBase &keys, vtkm::Id, vtkm::Id, vtkm::cont::Token &token) const
Definition: Keys.h:310
#define VTKM_IS_ARRAY_HANDLE(T)
Definition: ArrayHandle.h:132
Transport tag for keys in a reduce by key.
Definition: TransportTagKeysIn.h:28
Implicitly permutes the values in an array.
Definition: ArrayHandlePermutation.h:227
Class for checking that a type matches the semantics for an argument.
Definition: TypeCheck.h:34
ArrayHandleType ContObjectType
Definition: Keys.h:302
#define VTKM_CONT
Definition: ExportMacros.h:57
KeysSortType
Select the type of sort for BuildArrays calls.
Definition: Keys.h:107
VTKM_EXEC_CONT bool operator==(const vtkm::Matrix< T, NumRow, NumCol > &a, const vtkm::Matrix< T, NumRow, NumCol > &b)
Definition: Matrix.h:615
typename StorageType::WritePortalType WritePortalType
Definition: ArrayHandle.h:295
VTKM_CONT KeyArrayHandleType GetUniqueKeys() const
Definition: Keys.h:175
uint8_t UInt8
Definition: Types.h:157
Transport tag for input values in a reduce by key.
Definition: TransportTagKeyedValuesOut.h:28
typename GroupedArrayType::ReadPortalType ExecObjectType
Definition: Keys.h:308
Definition: DeviceAdapterTag.h:52
A short fixed-length array.
Definition: Types.h:767
VTKM_EXEC_CONT bool operator!=(const vtkm::Matrix< T, NumRow, NumCol > &a, const vtkm::Matrix< T, NumRow, NumCol > &b)
Definition: Matrix.h:629
This class is thrown when a VTKm function or method encounters an invalid value that inhibits progres...
Definition: ErrorBadValue.h:25
static constexpr bool value
The static constant boolean value is set to true if the type is valid for the given check tag and fal...
Definition: TypeCheck.h:39
typename GroupedArrayType::WritePortalType ExecObjectType
Definition: Keys.h:378
VTKM_CONT WritePortalType PrepareForOutput(vtkm::Id numberOfValues, vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Prepares (allocates) this array to be used as an output from an operation in the execution environmen...
Definition: ArrayHandle.h:613
VTKM_CONT ExecObjectType operator()(const ContObjectType &object, const ContObjectType &inputDomain, vtkm::Id, vtkm::Id, vtkm::cont::Token &token) const
Definition: Keys.h:276
Manage keys for a WorkletReduceByKey.
Definition: Keys.h:131
vtkm::Id KeyType
Definition: Keys.h:134
Class for transporting from the control to the execution environment.
Definition: Transport.h:38
#define VTKM_ALWAYS_EXPORT
Definition: ExportMacros.h:92
Check for a Keys object.
Definition: TypeCheckTagKeys.h:24
A vtkm::Pair is essentially the same as an STL pair object except that the methods (constructors and ...
Definition: Pair.h:29
VTKM_CONT ExecObjectType operator()(const ContObjectType contData, const InputDomainType &inputDomain vtkm::Id outputSize) const
Send data to the execution environment.
VTKM_CONT ExecObjectType operator()(ContObjectType object, const vtkm::worklet::internal::KeysBase &keys, vtkm::Id, vtkm::Id, vtkm::cont::Token &token) const
Definition: Keys.h:345
VTKM_CONT bool operator!=(const vtkm::worklet::Keys< KeyType > &other) const
Definition: Keys.h:200
Transport tag for input values in a reduce by key.
Definition: TransportTagKeyedValuesInOut.h:28