Go to the documentation of this file.
18 #ifndef viskores_worklet_Keys_h
19 #define viskores_worklet_Keys_h
56 class VISKORES_WORKLET_EXPORT KeysBase
59 KeysBase(
const KeysBase&) =
default;
60 KeysBase& operator=(
const KeysBase&) =
default;
61 ~KeysBase() =
default;
64 viskores::Id GetInputRange()
const {
return this->Offsets.GetNumberOfValues() - 1; }
69 return this->SortedValuesMap;
76 "Use the `GetOffsets()` array in an `ArrayHandleOffsetsToNumComponents`.")
81 viskores::
Id GetNumberOfValues()
const {
return this->SortedValuesMap.GetNumberOfValues(); }
83 using ExecLookup = viskores::exec::internal::ReduceByKeyLookupBase<
90 return ExecLookup(this->SortedValuesMap.PrepareForInput(device, token),
91 this->Offsets.PrepareForInput(device, token));
95 bool operator==(
const viskores::worklet::internal::KeysBase& other)
const
97 return ((this->SortedValuesMap == other.SortedValuesMap) && (this->Offsets == other.Offsets) &&
98 (this->Offsets == other.Offsets));
102 bool operator!=(
const viskores::worklet::internal::KeysBase& other)
const
104 return !(*
this == other);
108 KeysBase() =
default;
141 template <
typename T>
142 class VISKORES_ALWAYS_EXPORT
Keys :
public internal::KeysBase
160 template <
typename KeyStorage>
170 template <
typename KeyArrayType>
172 const KeyArrayType& keys,
179 template <
typename KeyArrayType>
190 #ifdef VISKORES_DOXYGEN_ONLY
220 using ExecLookup = viskores::exec::internal::ReduceByKeyLookup<
221 typename KeyArrayHandleType::ReadPortalType,
228 return ExecLookup(this->UniqueKeys.PrepareForInput(device, token),
229 this->SortedValuesMap.PrepareForInput(device, token),
230 this->Offsets.PrepareForInput(device, token));
236 return ((this->UniqueKeys == other.UniqueKeys) &&
237 (this->SortedValuesMap == other.SortedValuesMap) && (this->Offsets == other.Offsets));
245 KeyArrayHandleType UniqueKeys;
247 template <
typename KeyArrayType>
251 template <
typename KeyArrayType>
252 VISKORES_CONT void BuildArraysInternalStable(
const KeyArrayType& keys,
257 template <
typename T>
263 template <
typename KeyType>
265 -> decltype(inputDomain.GetInputRange())
267 return inputDomain.GetInputRange();
270 template <
typename KeyType>
272 -> decltype(inputDomain->GetInputRange())
274 return inputDomain->GetInputRange();
277 inline auto SchedulingRange(
const viskores::worklet::internal::KeysBase& inputDomain)
278 -> decltype(inputDomain.GetInputRange())
280 return inputDomain.GetInputRange();
283 inline auto SchedulingRange(
const viskores::worklet::internal::KeysBase*
const inputDomain)
284 -> decltype(inputDomain->GetInputRange())
286 return inputDomain->GetInputRange();
304 template <
typename KeyType>
307 static constexpr
bool value = std::is_base_of<viskores::worklet::internal::KeysBase,
308 typename std::decay<KeyType>::type>
::value;
311 template <
typename KeyType,
typename Device>
324 if (
object != inputDomain)
329 return object.PrepareForInput(Device(), token);
334 template <
typename InputDomainType>
336 const InputDomainType&,
341 template <
typename ArrayHandleType,
typename Device>
356 const viskores::worklet::internal::KeysBase& keys,
361 if (
object.GetNumberOfValues() != keys.GetNumberOfValues())
377 template <
typename ArrayHandleType,
typename Device>
392 const viskores::worklet::internal::KeysBase& keys,
397 if (
object.GetNumberOfValues() != keys.GetNumberOfValues())
413 template <
typename ArrayHandleType,
typename Device>
428 const viskores::worklet::internal::KeysBase& keys,
436 object.PrepareForOutput(keys.GetNumberOfValues(), Device(), token);
445 return groupedArray.
PrepareForOutput(keys.GetInputRange(), Device(), token);
452 #ifndef viskores_worklet_Keys_cxx
454 #define VISKORES_KEYS_EXPORT(T) \
455 extern template class VISKORES_WORKLET_TEMPLATE_EXPORT viskores::worklet::Keys<T>; \
456 extern template VISKORES_WORKLET_TEMPLATE_EXPORT VISKORES_CONT void \
457 viskores::worklet::Keys<T>::BuildArrays(const viskores::cont::ArrayHandle<T>& keys, \
458 viskores::worklet::KeysSortType sort, \
459 viskores::cont::DeviceAdapterId device)
468 #ifdef VISKORES_USE_64BIT_IDS
472 #undef VISKORES_KEYS_EXPORT
474 #endif // !viskores_worklet_Keys_cxx
476 #endif //viskores_worklet_Keys_h
typename Superclass::ReadPortalType ReadPortalType
Definition: ArrayHandleGroupVecVariable.h:299
bool operator==(const viskores::Matrix< T, NumRow, NumCol > &a, const viskores::Matrix< T, NumRow, NumCol > &b)
Definition: Matrix.h:632
typename ContObjectType::ExecLookup ExecObjectType
Definition: Keys.h:315
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.
Definition: ArrayHandle.h:615
ExecLookup PrepareForInput(viskores::cont::DeviceAdapterId device, viskores::cont::Token &token) const
Definition: Keys.h:225
T KeyType
Definition: Keys.h:145
Class for transporting from the control to the execution environment.
Definition: Transport.h:46
Transport tag for input values in a reduce by key.
Definition: TransportTagKeyedValuesOut.h:36
#define VISKORES_IS_ARRAY_HANDLE(T)
Checks that the given type is a viskores::cont::ArrayHandle.
Definition: ArrayHandle.h:145
typename ContObjectType::ReadPortalType ExecObjectType
The type used in the execution environment.
Definition: Transport.h:56
KeyArrayHandleType GetUniqueKeys() const
Returns an array of unique keys.
Definition: Keys.h:188
bool operator!=(const viskores::worklet::Keys< KeyType > &other) const
Definition: Keys.h:241
Tag for a device adapter used to specify that any device may be used for an operation.
Definition: DeviceAdapterTag.h:194
typename StorageType::ReadPortalType ReadPortalType
The type of portal used when accessing data in a read-only mode.
Definition: ArrayHandle.h:325
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
Manage keys for a viskores::worklet::WorkletReduceByKey.
Definition: Keys.h:142
KeysSortType
Select the type of sort for BuildArrays calls.
Definition: Keys.h:119
typename GroupedArrayType::WritePortalType ExecObjectType
Definition: Keys.h:389
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
#define VISKORES_CONT
Definition: ExportMacros.h:65
Groups connected points that have the same field value.
Definition: Atomic.h:27
Keys(const viskores::cont::ArrayHandle< KeyType, KeyStorage > &keys, viskores::cont::DeviceAdapterId device=viskores::cont::DeviceAdapterTagAny())
Construct a Keys class from an array of keys.
Definition: Keys.h:161
ExecObjectType operator()(const ContObjectType &object, const ContObjectType &inputDomain, viskores::Id, viskores::Id, viskores::cont::Token &token) const
Definition: Keys.h:318
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 e...
Definition: ArrayHandle.h:634
Transport tag for input values in a reduce by key.
Definition: TransportTagKeyedValuesInOut.h:36
ExecObjectType operator()(ContObjectType object, const viskores::worklet::internal::KeysBase &keys, viskores::Id, viskores::Id, viskores::cont::Token &token) const
Definition: Keys.h:427
#define VISKORES_DEPRECATED(...)
Definition: Deprecated.h:156
Transport tag for input values in a reduce by key.
Definition: TransportTagKeyedValuesIn.h:36
ExecObjectType operator()(const ContObjectType &object, const viskores::worklet::internal::KeysBase &keys, viskores::Id, viskores::Id, viskores::cont::Token &token) const
Definition: Keys.h:355
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 environmen...
Definition: ArrayHandle.h:654
A viskores::Pair is essentially the same as an STL pair object except that the methods (constructors ...
Definition: Pair.h:37
ArrayHandleType ContObjectType
Definition: Keys.h:382
uint8_t UInt8
Base type to use for 8-bit unsigned integer numbers.
Definition: Types.h:177
An object used to specify a device.
Definition: DeviceAdapterTag.h:66
Transport tag for keys in a reduce by key.
Definition: TransportTagKeysIn.h:36
Check for a Keys object.
Definition: TypeCheckTagKeys.h:32
This class is thrown when a Viskores function or method encounters an invalid value that inhibits pro...
Definition: ErrorBadValue.h:33
KeyType ContObjectType
Definition: Keys.h:314
bool operator!=(const viskores::Matrix< T, NumRow, NumCol > &a, const viskores::Matrix< T, NumRow, NumCol > &b)
Definition: Matrix.h:646
bool operator==(const viskores::worklet::Keys< KeyType > &other) const
Definition: Keys.h:234
typename Superclass::WritePortalType WritePortalType
Definition: ArrayHandleGroupVecVariable.h:299
typename GroupedArrayType::WritePortalType ExecObjectType
Definition: Keys.h:425
Fancy array handle that groups values into vectors of different sizes.
Definition: ArrayHandleGroupVecVariable.h:279
VISKORES_CONT ExecObjectType operator()(const ContObjectType contData, const InputDomainType &inputDomain viskores::Id outputSize) const
Send data to the execution environment.
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:43
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:47
viskores::UInt32 HashType
Definition: Hash.h:28
ArrayHandleType ContObjectType
Definition: Keys.h:346
typename GroupedArrayType::ReadPortalType ExecObjectType
Definition: Keys.h:353
Implicitly permutes the values in an array.
Definition: ArrayHandlePermutation.h:242
Class for checking that a type matches the semantics for an argument.
Definition: TypeCheck.h:42
ArrayHandleType ContObjectType
Definition: Keys.h:418
ExecObjectType operator()(ContObjectType object, const viskores::worklet::internal::KeysBase &keys, viskores::Id, viskores::Id, viskores::cont::Token &token) const
Definition: Keys.h:391