Go to the documentation of this file.
10 #ifndef vtk_m_cont_kokkos_internal_DeviceAdapterAlgorithmKokkos_h
11 #define vtk_m_cont_kokkos_internal_DeviceAdapterAlgorithmKokkos_h
26 #include <vtkmstd/void_t.h>
29 #include <Kokkos_Core.hpp>
30 #include <Kokkos_DualView.hpp>
31 #include <Kokkos_Sort.hpp>
34 #include <type_traits>
36 #if KOKKOS_VERSION_MAJOR > 3 || (KOKKOS_VERSION_MAJOR == 3 && KOKKOS_VERSION_MINOR >= 7)
39 #define VTKM_VOLATILE volatile
42 #if defined(VTKM_ENABLE_KOKKOS_THRUST) && (defined(__HIP__) || defined(__CUDA__))
43 #define VTKM_USE_KOKKOS_THRUST
46 #if defined(VTKM_USE_KOKKOS_THRUST)
47 #include <thrust/device_ptr.h>
48 #include <thrust/iterator/constant_iterator.h>
49 #include <thrust/sort.h>
57 template <
typename,
typename =
void>
58 struct is_type_complete :
public std::false_type
63 struct is_type_complete<T, vtkmstd::void_t<decltype(sizeof(T))>> :
public std::true_type
77 template <
typename BitsPortal>
83 explicit BitFieldToBoolField(
const BitsPortal& bp)
88 VTKM_EXEC bool operator()(
vtkm::Id bitIdx)
const {
return this->Bits.GetBit(bitIdx); }
94 template <
typename BitsPortal>
100 explicit BitFieldCountSetBitsWord(
const BitsPortal& bp)
107 auto word = this->Bits.GetWord(wordIdx);
108 if (wordIdx == (this->Bits.GetNumberOfWords() - 1))
110 word &= this->Bits.GetFinalWordMask();
121 template <
typename Operator,
typename ResultType>
122 struct ReductionIdentity;
124 template <
typename ResultType>
125 struct ReductionIdentity<
vtkm::
Sum, ResultType>
127 static constexpr ResultType value = Kokkos::reduction_identity<ResultType>::sum();
130 template <
typename ResultType>
131 struct ReductionIdentity<
vtkm::
Add, ResultType>
133 static constexpr ResultType value = Kokkos::reduction_identity<ResultType>::sum();
136 template <
typename ResultType>
137 struct ReductionIdentity<
vtkm::
Product, ResultType>
139 static constexpr ResultType value = Kokkos::reduction_identity<ResultType>::prod();
142 template <
typename ResultType>
145 static constexpr ResultType value = Kokkos::reduction_identity<ResultType>::prod();
148 template <
typename ResultType>
149 struct ReductionIdentity<
vtkm::
Minimum, ResultType>
151 static constexpr ResultType value = Kokkos::reduction_identity<ResultType>::min();
154 template <
typename ResultType>
155 struct ReductionIdentity<
vtkm::
Maximum, ResultType>
157 static constexpr ResultType value = Kokkos::reduction_identity<ResultType>::max();
160 template <
typename ResultType>
165 Kokkos::reduction_identity<ResultType>::max());
168 template <
typename ResultType>
171 static constexpr ResultType value = Kokkos::reduction_identity<ResultType>::band();
174 template <
typename ResultType>
177 static constexpr ResultType value = Kokkos::reduction_identity<ResultType>::bor();
185 : vtkm::cont::internal::DeviceAdapterAlgorithmGeneral<
186 DeviceAdapterAlgorithm<vtkm::cont::DeviceAdapterTagKokkos>,
187 vtkm::cont::DeviceAdapterTagKokkos>
190 using Superclass = vtkm::cont::internal::DeviceAdapterAlgorithmGeneral<
194 VTKM_CONT_EXPORT static vtkm::exec::internal::ErrorMessageBuffer GetErrorMessageBufferInstance();
198 template <
typename IndicesStorage>
205 auto bits2bools = kokkos::internal::BitFieldToBoolField<decltype(bitsPortal)>(bitsPortal);
220 kokkos::internal::BitFieldCountSetBitsWord<decltype(bitsPortal)>(bitsPortal);
228 using Superclass::Copy;
230 template <
typename T>
242 kokkos::internal::KokkosViewConstExec<T> viewIn(portalIn.GetArray(), inSize);
243 kokkos::internal::KokkosViewExec<T> viewOut(portalOut.GetArray(), inSize);
244 Kokkos::deep_copy(vtkm::cont::kokkos::internal::GetExecutionSpaceInstance(), viewOut, viewIn);
252 template <
typename ArrayHandle,
typename BinaryOperator,
typename ResultType>
254 BinaryOperator binaryOperator,
255 ResultType initialValue,
258 return Superclass::Reduce(input, initialValue, binaryOperator);
261 template <
typename BinaryOperator,
typename FunctorOperator,
typename ResultType>
262 class KokkosReduceFunctor
268 KOKKOS_INLINE_FUNCTION
271 template <
typename... Args>
274 , Functor(std::forward<Args>(args)...)
278 KOKKOS_INLINE_FUNCTION
281 dst = this->Operator(dst, src);
284 KOKKOS_INLINE_FUNCTION
287 dst = kokkos::internal::ReductionIdentity<BinaryOperator, value_type>::value;
291 KOKKOS_INLINE_FUNCTION
294 this->Functor(this->Operator, i, update);
298 KOKKOS_INLINE_FUNCTION
301 this->Functor(this->Operator, i, update,
final);
309 template <
typename ArrayPortal,
typename BinaryOperator,
typename ResultType>
313 KOKKOS_INLINE_FUNCTION
316 KOKKOS_INLINE_FUNCTION
322 KOKKOS_INLINE_FUNCTION
325 update = op(update, this->Portal.Get(i));
332 template <
typename BinaryOperator,
typename ArrayPortal,
typename ResultType>
334 ReduceOperator<ArrayPortal, BinaryOperator, ResultType>,
337 template <
typename ArrayHandle,
typename BinaryOperator,
typename ResultType>
339 BinaryOperator binaryOperator,
340 ResultType initialValue,
346 ReduceFunctor<BinaryOperator, decltype(inputPortal), ResultType> functor(binaryOperator,
351 Kokkos::RangePolicy<vtkm::cont::kokkos::internal::ExecutionSpace, vtkm::Id> policy(
352 vtkm::cont::kokkos::internal::GetExecutionSpaceInstance(), 0, input.
GetNumberOfValues());
353 Kokkos::parallel_reduce(policy, functor, result);
355 return binaryOperator(initialValue, result);
358 template <
bool P1,
typename BinaryOperator,
typename ResultType>
359 struct UseKokkosReduceP1 : std::false_type
363 template <
typename BinaryOperator,
typename ResultType>
364 struct UseKokkosReduceP1<true, BinaryOperator, ResultType>
365 : vtkm::internal::is_type_complete<
366 kokkos::internal::ReductionIdentity<BinaryOperator, ResultType>>
370 template <
typename BinaryOperator,
typename ResultType>
371 struct UseKokkosReduce
373 vtkm::internal::is_type_complete<Kokkos::reduction_identity<ResultType>>::value,
380 template <
typename T,
typename U,
class CIn,
class BinaryOperator>
383 BinaryOperator binaryOperator)
393 return binaryOperator(initialValue, input.
ReadPortal().Get(0));
396 #if defined(VTKM_KOKKOS_CUDA)
400 std::integral_constant<
402 !std::is_same<vtkm::cont::kokkos::internal::ExecutionSpace, Kokkos::Cuda>::value &&
403 UseKokkosReduce<BinaryOperator, U>::value>
406 typename UseKokkosReduce<BinaryOperator, U>::type use_kokkos_reduce;
408 return ReduceImpl(input, binaryOperator, initialValue, use_kokkos_reduce);
411 template <
typename T,
typename U,
class CIn>
425 template <
typename BinaryOperator,
typename ResultType>
428 template <
typename T,
typename StorageIn,
typename StorageOut,
typename BinaryOperator>
431 BinaryOperator binaryOperator,
432 const T& initialValue,
435 return Superclass::ScanExclusive(input, output, binaryOperator, initialValue);
438 template <
typename T,
typename StorageIn,
typename StorageOut,
typename BinaryOperator>
439 class ScanExclusiveOperator
446 KOKKOS_INLINE_FUNCTION
449 KOKKOS_INLINE_FUNCTION
452 const T& initialValue)
454 , PortalOut(portalOut)
455 , InitialValue(initialValue)
459 KOKKOS_INLINE_FUNCTION
462 auto val = this->PortalIn.Get(i);
465 update = InitialValue;
469 this->PortalOut.Set(i, update);
471 update = op(update, val);
480 template <
typename BinaryOperator,
typename T,
typename StorageIn,
typename StorageOut>
482 KokkosReduceFunctor<BinaryOperator,
483 ScanExclusiveOperator<T, StorageIn, StorageOut, BinaryOperator>,
486 template <
typename T,
typename StorageIn,
typename StorageOut,
typename BinaryOperator>
489 BinaryOperator binaryOperator,
490 const T& initialValue,
501 binaryOperator, inputPortal, outputPortal, initialValue);
504 Kokkos::RangePolicy<vtkm::cont::kokkos::internal::ExecutionSpace, vtkm::Id> policy(
505 vtkm::cont::kokkos::internal::GetExecutionSpaceInstance(), 0, length);
506 Kokkos::parallel_scan(policy, functor, result);
512 template <
typename T,
class CIn,
class COut,
class BinaryOperator>
515 BinaryOperator binaryOperator,
516 const T& initialValue)
529 Fill(output, initialValue, 1);
530 return binaryOperator(initialValue, v0);
533 #if defined(VTKM_KOKKOS_CUDA)
535 std::integral_constant<bool,
536 !(std::is_integral<T>::value &&
sizeof(T) < 4) &&
542 return ScanExclusiveImpl(input, output, binaryOperator, initialValue, use_kokkos_scan);
545 template <
typename T,
class CIn,
class COut>
559 template <
typename T,
typename StorageIn,
typename StorageOut,
typename BinaryOperator>
562 BinaryOperator binaryOperator,
565 return Superclass::ScanInclusive(input, output, binaryOperator);
568 template <
typename T,
typename StorageIn,
typename StorageOut,
typename BinaryOperator>
569 class ScanInclusiveOperator
576 KOKKOS_INLINE_FUNCTION
579 KOKKOS_INLINE_FUNCTION
582 , PortalOut(portalOut)
586 KOKKOS_INLINE_FUNCTION
589 update = op(update, this->PortalIn.Get(i));
592 this->PortalOut.Set(i, update);
601 template <
typename BinaryOperator,
typename T,
typename StorageIn,
typename StorageOut>
603 KokkosReduceFunctor<BinaryOperator,
604 ScanInclusiveOperator<T, StorageIn, StorageOut, BinaryOperator>,
607 template <
typename T,
typename StorageIn,
typename StorageOut,
typename BinaryOperator>
610 BinaryOperator binaryOperator,
621 binaryOperator, inputPortal, outputPortal);
624 Kokkos::RangePolicy<vtkm::cont::kokkos::internal::ExecutionSpace, vtkm::Id> policy(
625 vtkm::cont::kokkos::internal::GetExecutionSpaceInstance(), 0, length);
626 Kokkos::parallel_scan(policy, functor, result);
632 template <
typename T,
class CIn,
class COut,
class BinaryOperator>
635 BinaryOperator binaryOperator)
647 Fill(output, result, 1);
651 #if defined(VTKM_KOKKOS_CUDA)
653 std::integral_constant<bool,
654 !(std::is_integral<T>::value &&
sizeof(T) < 4) &&
660 return ScanInclusiveImpl(input, output, binaryOperator, use_kokkos_scan);
663 template <
typename T,
class CIn,
class COut>
673 template <
typename WType,
typename IType,
typename H
ints>
675 vtkm::exec::kokkos::internal::TaskBasic1D<WType, IType, Hints>& functor,
680 if (numInstances < 1)
686 functor.SetErrorMessageBuffer(GetErrorMessageBufferInstance());
689 vtkm::cont::internal::HintFind<Hints,
690 vtkm::cont::internal::HintThreadsPerBlock<0>,
693 Kokkos::RangePolicy<vtkm::cont::kokkos::internal::ExecutionSpace,
694 Kokkos::LaunchBounds<maxThreadsPerBlock, 0>,
695 Kokkos::IndexType<vtkm::Id>>
696 policy(vtkm::cont::kokkos::internal::GetExecutionSpaceInstance(), 0, numInstances);
697 Kokkos::parallel_for(policy, functor);
701 template <
typename WType,
typename IType,
typename H
ints>
703 vtkm::exec::kokkos::internal::TaskBasic3D<WType, IType, Hints>& functor,
708 if ((rangeMax[0] < 1) || (rangeMax[1] < 1) || (rangeMax[2] < 1))
714 functor.SetErrorMessageBuffer(GetErrorMessageBufferInstance());
717 vtkm::cont::internal::HintFind<Hints,
718 vtkm::cont::internal::HintThreadsPerBlock<0>,
721 Kokkos::MDRangePolicy<vtkm::cont::kokkos::internal::ExecutionSpace,
722 Kokkos::LaunchBounds<maxThreadsPerBlock, 0>,
724 Kokkos::IndexType<vtkm::Id>>
725 policy(vtkm::cont::kokkos::internal::GetExecutionSpaceInstance(),
727 { rangeMax[0], rangeMax[1], rangeMax[2] });
734 const auto rMax_0 = rangeMax[0];
735 const auto rMax_1 = rangeMax[1];
737 Kokkos::parallel_for(
739 auto flatIdx = i + (j * rMax_0) + (k * rMax_0 * rMax_1);
745 template <
typename H
ints,
typename Functor>
750 vtkm::exec::kokkos::internal::TaskBasic1D<Functor, vtkm::internal::NullType, Hints> kernel(
752 ScheduleTask(kernel, numInstances);
755 template <
typename FunctorType>
758 Schedule(vtkm::cont::internal::HintList<>{}, functor, numInstances);
761 template <
typename H
ints,
typename Functor>
766 vtkm::exec::kokkos::internal::TaskBasic3D<Functor, vtkm::internal::NullType, Hints> kernel(
768 ScheduleTask(kernel, rangeMax);
771 template <
typename FunctorType>
774 Schedule(vtkm::cont::internal::HintList<>{}, functor, rangeMax);
779 template <
typename T>
791 kokkos::internal::KokkosViewExec<T> view(portal.GetArray(), portal.GetNumberOfValues());
798 vtkm::cont::kokkos::internal::GetExecutionSpaceInstance().fence();
800 vtkm::cont::kokkos::internal::GetExecutionSpaceInstance().fence();
803 template <
typename T>
808 Superclass::Sort(values, comp);
812 using Superclass::Sort;
814 template <
typename T>
817 SortImpl(values, comp,
typename std::is_scalar<T>::type{});
823 #if defined(VTKM_USE_KOKKOS_THRUST)
825 template <
typename T,
typename U,
typename BinaryCompare>
826 VTKM_CONT static std::enable_if_t<(std::is_same<BinaryCompare, vtkm::SortLess>::value ||
827 std::is_same<BinaryCompare, vtkm::SortGreater>::value)>
838 kokkos::internal::KokkosViewExec<T> keys_view(keys_portal.GetArray(),
839 keys_portal.GetNumberOfValues());
840 kokkos::internal::KokkosViewExec<U> values_view(values_portal.GetArray(),
841 values_portal.GetNumberOfValues());
843 thrust::device_ptr<T> keys_begin(keys_view.data());
844 thrust::device_ptr<T> keys_end(keys_view.data() + keys_view.size());
845 thrust::device_ptr<U> values_begin(values_view.data());
847 if (std::is_same<BinaryCompare, vtkm::SortLess>::value)
849 thrust::sort_by_key(keys_begin, keys_end, values_begin, thrust::less<T>());
853 thrust::sort_by_key(keys_begin, keys_end, values_begin, thrust::greater<T>());
859 template <
typename T,
865 typename ValidValues>
868 BinaryCompare binary_compare,
873 Superclass::SortByKey(keys, values, binary_compare);
877 template <
typename T,
typename U,
class StorageT,
class StorageU>
886 template <
typename T,
typename U,
class StorageT,
class StorageU,
class BinaryCompare>
889 BinaryCompare binary_compare)
896 typename std::is_scalar<T>::type{},
897 typename std::is_scalar<U>::type{});
903 #ifdef VTKM_USE_KOKKOS_THRUST
906 template <
typename K,
typename V,
class BinaryFunctor>
911 BinaryFunctor binary_functor)
924 auto keys_output_portal =
926 auto values_output_portal =
929 thrust::device_ptr<const K> keys_begin(keys_portal.GetArray());
930 thrust::device_ptr<const K> keys_end(keys_portal.GetArray() + numberOfKeys);
931 thrust::device_ptr<const V> values_begin(values_portal.GetArray());
932 thrust::device_ptr<K> keys_output_begin(keys_output_portal.GetArray());
933 thrust::device_ptr<V> values_output_begin(values_output_portal.GetArray());
935 auto ends = thrust::reduce_by_key(keys_begin,
940 thrust::equal_to<K>(),
943 num_unique_keys = ends.first - keys_output_begin;
952 template <
typename K,
typename V,
class BinaryFunctor>
958 BinaryFunctor binary_functor)
971 auto keys_output_portal =
973 auto values_output_portal =
976 thrust::device_ptr<const K> keys_begin(keys_portal.GetArray());
977 thrust::device_ptr<const K> keys_end(keys_portal.GetArray() + numberOfKeys);
978 thrust::constant_iterator<const V> values_begin(value);
979 thrust::device_ptr<K> keys_output_begin(keys_output_portal.GetArray());
980 thrust::device_ptr<V> values_output_begin(values_output_portal.GetArray());
982 auto ends = thrust::reduce_by_key(keys_begin,
987 thrust::equal_to<K>(),
990 num_unique_keys = ends.first - keys_output_begin;
998 template <
typename T,
1004 class BinaryFunctor>
1009 BinaryFunctor binary_functor)
1013 Superclass::ReduceByKey(keys, values, keys_output, values_output, binary_functor);
1017 template <
typename T,
1023 class BinaryFunctor>
1028 BinaryFunctor binary_functor)
1032 ReduceByKeyImpl(keys, values, keys_output, values_output, binary_functor);
1041 vtkm::cont::kokkos::internal::GetExecutionSpaceInstance().fence();
1050 template <
typename H
ints,
typename WorkletType,
typename InvocationType>
1051 VTKM_CONT static vtkm::exec::kokkos::internal::TaskBasic1D<WorkletType, InvocationType, Hints>
1054 return vtkm::exec::kokkos::internal::TaskBasic1D<WorkletType, InvocationType, Hints>(
1055 worklet, invocation);
1058 template <
typename H
ints,
typename WorkletType,
typename InvocationType>
1059 VTKM_CONT static vtkm::exec::kokkos::internal::TaskBasic3D<WorkletType, InvocationType, Hints>
1062 return vtkm::exec::kokkos::internal::TaskBasic3D<WorkletType, InvocationType, Hints>(
1063 worklet, invocation);
1066 template <
typename WorkletType,
typename InvocationType,
typename RangeType>
1068 InvocationType& invocation,
1069 const RangeType& range)
1071 return MakeTask<vtkm::cont::internal::HintList<>>(worklet, invocation, range);
1077 #undef VTKM_VOLATILE
1079 #endif //vtk_m_cont_kokkos_internal_DeviceAdapterAlgorithmKokkos_h
static T ScanInclusiveImpl(const vtkm::cont::ArrayHandle< T, StorageIn > &input, vtkm::cont::ArrayHandle< T, StorageOut > &output, BinaryOperator binaryOperator, std::true_type)
Definition: DeviceAdapterAlgorithmKokkos.h:608
typename ArrayHandle< T, StorageOut >::WritePortalType ArrayPortalOut
Definition: DeviceAdapterAlgorithmKokkos.h:573
static T ScanExclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Compute an exclusive prefix sum operation on the input ArrayHandle.
KOKKOS_INLINE_FUNCTION void operator()(vtkm::Id i, ResultType &update) const
Definition: DeviceAdapterAlgorithmKokkos.h:292
static T ScanInclusiveImpl(const vtkm::cont::ArrayHandle< T, StorageIn > &input, vtkm::cont::ArrayHandle< T, StorageOut > &output, BinaryOperator binaryOperator, std::false_type)
Definition: DeviceAdapterAlgorithmKokkos.h:560
Manages an array-worth of data.
Definition: ArrayHandle.h:300
KOKKOS_INLINE_FUNCTION ReduceOperator(const ArrayPortal &portal)
Definition: DeviceAdapterAlgorithmKokkos.h:317
static void Fill(vtkm::cont::BitField &bits, bool value, vtkm::Id numBits)
Fill the BitField with a specific pattern of bits.
static U Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue)
Definition: DeviceAdapterAlgorithmKokkos.h:412
#define VTKM_EXEC
Definition: ExportMacros.h:51
KOKKOS_INLINE_FUNCTION ScanExclusiveOperator()
Definition: DeviceAdapterAlgorithmKokkos.h:447
Groups connected points that have the same field value.
Definition: Atomic.h:19
KOKKOS_INLINE_FUNCTION void operator()(const BinaryOperator &op, const vtkm::Id i, T &update, const bool final) const
Definition: DeviceAdapterAlgorithmKokkos.h:460
KOKKOS_INLINE_FUNCTION void operator()(vtkm::Id i, ResultType &update, const bool final) const
Definition: DeviceAdapterAlgorithmKokkos.h:299
static vtkm::exec::kokkos::internal::TaskBasic1D< WorkletType, InvocationType, Hints > MakeTask(WorkletType &worklet, InvocationType &invocation, vtkm::Id, Hints=Hints{})
Definition: DeviceAdapterAlgorithmKokkos.h:1052
Binary Predicate that takes two arguments argument x, and y and returns product (multiplication) of t...
Definition: BinaryOperators.h:56
UseKokkosReduce< BinaryOperator, ResultType > UseKokkosScan
Definition: DeviceAdapterAlgorithmKokkos.h:426
The TypeTraits class provides helpful compile-time information about the basic types used in VTKm (an...
Definition: TypeTraits.h:61
KOKKOS_INLINE_FUNCTION void operator()(const BinaryOperator &op, const vtkm::Id i, T &update, const bool final) const
Definition: DeviceAdapterAlgorithmKokkos.h:587
Binary Predicate that takes two arguments argument x, and y and returns the bitwise operation x|y
Definition: BinaryOperators.h:168
static vtkm::exec::kokkos::internal::TaskBasic3D< WorkletType, InvocationType, Hints > MakeTask(WorkletType &worklet, InvocationType &invocation, vtkm::Id3, Hints={})
Definition: DeviceAdapterAlgorithmKokkos.h:1060
vtkm::cont::ArrayHandleImplicit< FunctorType > make_ArrayHandleImplicit(FunctorType functor, vtkm::Id length)
make_ArrayHandleImplicit is convenience function to generate an ArrayHandleImplicit.
Definition: ArrayHandleImplicit.h:203
Binary Predicate that takes two arguments argument x, and y and returns a vtkm::Vec<T,...
Definition: BinaryOperators.h:112
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
static void Sort(vtkm::cont::ArrayHandle< T > &values, vtkm::SortLess comp)
Definition: DeviceAdapterAlgorithmKokkos.h:815
static void Schedule(Functor functor, vtkm::Id numInstances)
Schedule many instances of a function to run on concurrent threads.
KOKKOS_INLINE_FUNCTION void init(value_type &dst) const
Definition: DeviceAdapterAlgorithmKokkos.h:285
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
static void Schedule(Hints, Functor functor, const vtkm::Id3 &rangeMax)
Definition: DeviceAdapterAlgorithmKokkos.h:762
vtkm::Id size_type
Definition: DeviceAdapterAlgorithmKokkos.h:265
static auto MakeTask(WorkletType &worklet, InvocationType &invocation, const RangeType &range)
Definition: DeviceAdapterAlgorithmKokkos.h:1067
static T ScanExclusiveImpl(const vtkm::cont::ArrayHandle< T, StorageIn > &input, vtkm::cont::ArrayHandle< T, StorageOut > &output, BinaryOperator binaryOperator, const T &initialValue, std::true_type)
Definition: DeviceAdapterAlgorithmKokkos.h:487
#define VTKM_VOLATILE
Definition: DeviceAdapterAlgorithmKokkos.h:39
vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:468
static ResultType ReduceImpl(const ArrayHandle &input, BinaryOperator binaryOperator, ResultType initialValue, std::false_type)
Definition: DeviceAdapterAlgorithmKokkos.h:253
Binary Predicate that takes two arguments argument x, and y and returns the x if x > y otherwise retu...
Definition: BinaryOperators.h:85
static vtkm::Id CountSetBits(const vtkm::cont::BitField &bits)
Definition: DeviceAdapterAlgorithmKokkos.h:215
static void SortImpl(vtkm::cont::ArrayHandle< T > &values, vtkm::SortLess comp, std::false_type)
Definition: DeviceAdapterAlgorithmKokkos.h:804
ArrayPortalOut PortalOut
Definition: DeviceAdapterAlgorithmKokkos.h:476
vtkm::Id GetNumberOfBits() const
Return the number of bits stored by this BitField.
static void Copy(const vtkm::cont::ArrayHandle< T > &input, vtkm::cont::ArrayHandle< T > &output)
Definition: DeviceAdapterAlgorithmKokkos.h:231
KokkosReduceFunctor< BinaryOperator, ScanInclusiveOperator< T, StorageIn, StorageOut, BinaryOperator >, T > ScanInclusiveFunctor
Definition: DeviceAdapterAlgorithmKokkos.h:605
KOKKOS_INLINE_FUNCTION KokkosReduceFunctor(const BinaryOperator &op, Args... args)
Definition: DeviceAdapterAlgorithmKokkos.h:272
KOKKOS_INLINE_FUNCTION ScanExclusiveOperator(const ArrayPortalIn &portalIn, const ArrayPortalOut &portalOut, const T &initialValue)
Definition: DeviceAdapterAlgorithmKokkos.h:450
static T VIn
Definition: DeviceAdapterAlgorithm.h:349
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
Binary Predicate that takes two arguments argument x, and y and returns sum (addition) of the two val...
Definition: BinaryOperators.h:33
KOKKOS_INLINE_FUNCTION void operator()(const BinaryOperator &op, vtkm::Id i, ResultType &update) const
Definition: DeviceAdapterAlgorithmKokkos.h:323
Binary Predicate that takes two arguments argument x, and y and returns True if and only if x is less...
Definition: BinaryPredicates.h:45
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:618
static ResultType ReduceImpl(const ArrayHandle &input, BinaryOperator binaryOperator, ResultType initialValue, std::true_type)
Definition: DeviceAdapterAlgorithmKokkos.h:338
static T KIn
Definition: DeviceAdapterAlgorithm.h:348
static T ScanInclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Compute an inclusive prefix sum operation on the input ArrayHandle.
static void Schedule(FunctorType &&functor, vtkm::Id numInstances)
Definition: DeviceAdapterAlgorithmKokkos.h:756
#define VTKM_CONT_EXPORT
Definition: vtkm_cont_export.h:44
T InitialValue
Definition: DeviceAdapterAlgorithmKokkos.h:477
KOKKOS_INLINE_FUNCTION ReduceOperator()
Definition: DeviceAdapterAlgorithmKokkos.h:314
static T U
Definition: DeviceAdapterAlgorithm.h:347
BinaryOperator Operator
Definition: DeviceAdapterAlgorithmKokkos.h:305
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:638
typename ArrayHandle< T, StorageOut >::WritePortalType ArrayPortalOut
Definition: DeviceAdapterAlgorithmKokkos.h:443
Class providing a device-specific support for selecting the optimal Task type for a given worklet.
Definition: DeviceAdapterAlgorithm.h:744
#define VTKM_CONT
Definition: ExportMacros.h:57
void ReleaseResources() const
Releases all resources in both the control and execution environments.
Definition: ArrayHandle.h:584
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
#define VTKM_LOG_SCOPE_FUNCTION(level)
Definition: Logging.h:214
Struct containing device adapter algorithms.
Definition: DeviceAdapterAlgorithm.h:41
static T ScanInclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output, BinaryOperator binaryOperator)
Definition: DeviceAdapterAlgorithmKokkos.h:633
ArrayPortalIn PortalIn
Definition: DeviceAdapterAlgorithmKokkos.h:475
static void ScheduleTask(vtkm::exec::kokkos::internal::TaskBasic3D< WType, IType, Hints > &functor, vtkm::Id3 rangeMax)
Definition: DeviceAdapterAlgorithmKokkos.h:702
static void SortByKey(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values)
Unstable ascending sort of keys and values.
static void SortByKey(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmKokkos.h:887
static void ReduceByKey(const vtkm::cont::ArrayHandle< T, CKeyIn > &keys, const vtkm::cont::ArrayHandle< U, CValIn > &values, vtkm::cont::ArrayHandle< T, CKeyOut > &keys_output, vtkm::cont::ArrayHandle< U, CValOut > &values_output, BinaryFunctor binary_functor)
Compute a accumulated sum operation on the input key value pairs.
FunctorOperator Functor
Definition: DeviceAdapterAlgorithmKokkos.h:306
KOKKOS_INLINE_FUNCTION ScanInclusiveOperator(const ArrayPortalIn &portalIn, const ArrayPortalOut &portalOut)
Definition: DeviceAdapterAlgorithmKokkos.h:580
ArrayPortalIn PortalIn
Definition: DeviceAdapterAlgorithmKokkos.h:597
ReadPortalType ReadPortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:433
ResultType value_type
Definition: DeviceAdapterAlgorithmKokkos.h:266
static void Synchronize()
Definition: DeviceAdapterAlgorithmKokkos.h:1039
Base class for all user worklets invoked in the execution environment from a call to vtkm::cont::Devi...
Definition: FunctorBase.h:30
static T ScanInclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmKokkos.h:664
KokkosReduceFunctor< BinaryOperator, ReduceOperator< ArrayPortal, BinaryOperator, ResultType >, ResultType > ReduceFunctor
Definition: DeviceAdapterAlgorithmKokkos.h:335
static T ScanExclusiveImpl(const vtkm::cont::ArrayHandle< T, StorageIn > &input, vtkm::cont::ArrayHandle< T, StorageOut > &output, BinaryOperator binaryOperator, const T &initialValue, std::false_type)
Definition: DeviceAdapterAlgorithmKokkos.h:429
A short fixed-length array.
Definition: Types.h:357
static T ScanExclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmKokkos.h:546
static T ScanExclusive(const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output, BinaryOperator binaryOperator, const T &initialValue)
Definition: DeviceAdapterAlgorithmKokkos.h:513
Binary Predicate that takes two arguments argument x, and y and returns the bitwise operation x&y
Definition: BinaryOperators.h:145
Definition: BitField.h:497
static void Schedule(FunctorType &&functor, vtkm::Id3 rangeMax)
Definition: DeviceAdapterAlgorithmKokkos.h:772
static void SortImpl(vtkm::cont::ArrayHandle< T > &values, vtkm::SortLess, std::true_type)
Definition: DeviceAdapterAlgorithmKokkos.h:780
KOKKOS_INLINE_FUNCTION void join(volatile value_type &dst, const volatile value_type &src) const
Definition: DeviceAdapterAlgorithmKokkos.h:279
static void CopyIf(const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< U, CStencil > &stencil, vtkm::cont::ArrayHandle< T, COut > &output)
Conditionally copy elements in the input array to the output array.
ReadPortalType PrepareForInput(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Prepares this BitField to be used as an input to an operation in the execution environment.
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:599
static vtkm::Id BitFieldToUnorderedSet(const vtkm::cont::BitField &bits, vtkm::cont::ArrayHandle< Id, IndicesStorage > &indices)
Definition: DeviceAdapterAlgorithmKokkos.h:199
static void ScheduleTask(vtkm::exec::kokkos::internal::TaskBasic1D< WType, IType, Hints > &functor, vtkm::Id numInstances)
Definition: DeviceAdapterAlgorithmKokkos.h:674
static T ZeroInitialization()
A static function that returns 0 (or the closest equivalent to it) for the given type.
Definition: TypeTraits.h:77
static U Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue)
Compute a accumulated sum operation on the input ArrayHandle.
void Allocate(vtkm::Id numberOfValues, vtkm::CopyFlag preserve, vtkm::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:490
KOKKOS_INLINE_FUNCTION KokkosReduceFunctor()
Definition: DeviceAdapterAlgorithmKokkos.h:269
ArrayPortalOut PortalOut
Definition: DeviceAdapterAlgorithmKokkos.h:598
Definition: DeviceAdapterAlgorithmKokkos.h:184
static U Reduce(const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue, BinaryOperator binaryOperator)
Definition: DeviceAdapterAlgorithmKokkos.h:381
KokkosReduceFunctor< BinaryOperator, ScanExclusiveOperator< T, StorageIn, StorageOut, BinaryOperator >, T > ScanExclusiveFunctor
Definition: DeviceAdapterAlgorithmKokkos.h:484
static void SortByKeyImpl(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values, BinaryCompare binary_compare, ValidKeys, ValidValues)
Definition: DeviceAdapterAlgorithmKokkos.h:866
static void SortByKey(vtkm::cont::ArrayHandle< T, StorageT > &keys, vtkm::cont::ArrayHandle< U, StorageU > &values)
Definition: DeviceAdapterAlgorithmKokkos.h:878
static T VOut
Definition: DeviceAdapterAlgorithm.h:350
A class that points to and access and array of data.
Definition: ArrayPortal.h:62
typename ArrayHandle< T, StorageIn >::ReadPortalType ArrayPortalIn
Definition: DeviceAdapterAlgorithmKokkos.h:442
@ Perf
General timing data and algorithm flow information, such as filter execution, worklet dispatches,...
Tag for a device adapter that uses the Kokkos library to run algorithms in parallel.
Definition: DeviceAdapterTagKokkos.h:31
vtkm::cont::internal::DeviceAdapterAlgorithmGeneral< DeviceAdapterAlgorithm< vtkm::cont::DeviceAdapterTagKokkos >, vtkm::cont::DeviceAdapterTagKokkos > Superclass
Definition: DeviceAdapterAlgorithmKokkos.h:192
An implicit array handle containing the its own indices.
Definition: ArrayHandleIndex.h:55
typename ArrayHandle< T, StorageIn >::ReadPortalType ArrayPortalIn
Definition: DeviceAdapterAlgorithmKokkos.h:572
vtkm::Int32 CountSetBits(vtkm::UInt32 word)
Count the total number of bits set in word.
Definition: Math.h:2940
Binary Predicate that takes two arguments argument x, and y and returns the x if x < y otherwise retu...
Definition: BinaryOperators.h:99
ArrayPortal Portal
Definition: DeviceAdapterAlgorithmKokkos.h:329
KOKKOS_INLINE_FUNCTION ScanInclusiveOperator()
Definition: DeviceAdapterAlgorithmKokkos.h:577
static void Schedule(Hints, Functor functor, vtkm::Id numInstances)
Definition: DeviceAdapterAlgorithmKokkos.h:746