Go to the documentation of this file.
18 #ifndef viskores_cont_kokkos_internal_DeviceAdapterAlgorithmKokkos_h
19 #define viskores_cont_kokkos_internal_DeviceAdapterAlgorithmKokkos_h
34 #include <viskoresstd/void_t.h>
37 #include <Kokkos_Core.hpp>
38 #include <Kokkos_DualView.hpp>
39 #include <Kokkos_Sort.hpp>
42 #include <type_traits>
44 #if KOKKOS_VERSION_MAJOR > 3 || (KOKKOS_VERSION_MAJOR == 3 && KOKKOS_VERSION_MINOR >= 7)
45 #define VISKORES_VOLATILE
47 #define VISKORES_VOLATILE volatile
50 #if defined(VISKORES_ENABLE_KOKKOS_THRUST) && (defined(__HIP__) || defined(__CUDA__))
51 #define VISKORES_USE_KOKKOS_THRUST
54 #if defined(VISKORES_USE_KOKKOS_THRUST)
55 #include <thrust/device_ptr.h>
56 #include <thrust/iterator/constant_iterator.h>
57 #include <thrust/sort.h>
65 template <
typename,
typename =
void>
66 struct is_type_complete :
public std::false_type
71 struct is_type_complete<T, viskoresstd::void_t<decltype(sizeof(T))>> :
public std::true_type
85 template <
typename BitsPortal>
91 explicit BitFieldToBoolField(
const BitsPortal& bp)
102 template <
typename BitsPortal>
108 explicit BitFieldCountSetBitsWord(
const BitsPortal& bp)
115 auto word = this->Bits.GetWord(wordIdx);
116 if (wordIdx == (this->Bits.GetNumberOfWords() - 1))
118 word &= this->Bits.GetFinalWordMask();
129 template <
typename Operator,
typename ResultType>
130 struct ReductionIdentity;
132 template <
typename ResultType>
133 struct ReductionIdentity<
viskores::
Sum, ResultType>
135 static constexpr ResultType value = Kokkos::reduction_identity<ResultType>::sum();
138 template <
typename ResultType>
139 struct ReductionIdentity<
viskores::
Add, ResultType>
141 static constexpr ResultType value = Kokkos::reduction_identity<ResultType>::sum();
144 template <
typename ResultType>
147 static constexpr ResultType value = Kokkos::reduction_identity<ResultType>::prod();
150 template <
typename ResultType>
153 static constexpr ResultType value = Kokkos::reduction_identity<ResultType>::prod();
156 template <
typename ResultType>
159 static constexpr ResultType value = Kokkos::reduction_identity<ResultType>::min();
162 template <
typename ResultType>
165 static constexpr ResultType value = Kokkos::reduction_identity<ResultType>::max();
168 template <
typename ResultType>
173 Kokkos::reduction_identity<ResultType>::max());
176 template <
typename ResultType>
179 static constexpr ResultType value = Kokkos::reduction_identity<ResultType>::band();
182 template <
typename ResultType>
185 static constexpr ResultType value = Kokkos::reduction_identity<ResultType>::bor();
193 : viskores::cont::internal::DeviceAdapterAlgorithmGeneral<
194 DeviceAdapterAlgorithm<viskores::cont::DeviceAdapterTagKokkos>,
195 viskores::cont::DeviceAdapterTagKokkos>
198 using Superclass = viskores::cont::internal::DeviceAdapterAlgorithmGeneral<
202 VISKORES_CONT_EXPORT
static viskores::exec::internal::ErrorMessageBuffer
203 GetErrorMessageBufferInstance();
204 VISKORES_CONT_EXPORT
static void CheckForErrors();
207 template <
typename IndicesStorage>
214 auto bits2bools = kokkos::internal::BitFieldToBoolField<decltype(bitsPortal)>(bitsPortal);
229 kokkos::internal::BitFieldCountSetBitsWord<decltype(bitsPortal)>(bitsPortal);
237 using Superclass::Copy;
239 template <
typename T>
252 kokkos::internal::KokkosViewConstExec<T> viewIn(portalIn.GetArray(), inSize);
253 kokkos::internal::KokkosViewExec<T> viewOut(portalOut.GetArray(), inSize);
255 viskores::cont::kokkos::internal::GetExecutionSpaceInstance(), viewOut, viewIn);
259 #ifndef VISKORES_CUDA
263 template <
typename ArrayHandle,
typename BinaryOperator,
typename ResultType>
265 BinaryOperator binaryOperator,
266 ResultType initialValue,
269 return Superclass::Reduce(input, initialValue, binaryOperator);
272 template <
typename BinaryOperator,
typename FunctorOperator,
typename ResultType>
273 class KokkosReduceFunctor
279 KOKKOS_INLINE_FUNCTION
282 template <
typename... Args>
285 , Functor(std::forward<Args>(args)...)
289 KOKKOS_INLINE_FUNCTION
292 dst = this->Operator(dst, src);
295 KOKKOS_INLINE_FUNCTION
298 dst = kokkos::internal::ReductionIdentity<BinaryOperator, value_type>::value;
302 KOKKOS_INLINE_FUNCTION
305 this->Functor(this->Operator, i, update);
309 KOKKOS_INLINE_FUNCTION
312 this->Functor(this->Operator, i, update,
final);
320 template <
typename ArrayPortal,
typename BinaryOperator,
typename ResultType>
324 KOKKOS_INLINE_FUNCTION
327 KOKKOS_INLINE_FUNCTION
333 KOKKOS_INLINE_FUNCTION
336 update = op(update, this->Portal.Get(i));
343 template <
typename BinaryOperator,
typename ArrayPortal,
typename ResultType>
345 ReduceOperator<ArrayPortal, BinaryOperator, ResultType>,
348 template <
typename ArrayHandle,
typename BinaryOperator,
typename ResultType>
350 BinaryOperator binaryOperator,
351 ResultType initialValue,
357 ReduceFunctor<BinaryOperator, decltype(inputPortal), ResultType> functor(binaryOperator,
362 Kokkos::RangePolicy<viskores::cont::kokkos::internal::ExecutionSpace, viskores::Id> policy(
363 viskores::cont::kokkos::internal::GetExecutionSpaceInstance(), 0, input.
GetNumberOfValues());
364 Kokkos::parallel_reduce(policy, functor, result);
366 return binaryOperator(initialValue, result);
369 template <
bool P1,
typename BinaryOperator,
typename ResultType>
370 struct UseKokkosReduceP1 : std::false_type
374 template <
typename BinaryOperator,
typename ResultType>
375 struct UseKokkosReduceP1<true, BinaryOperator, ResultType>
376 : viskores::internal::is_type_complete<
377 kokkos::internal::ReductionIdentity<BinaryOperator, ResultType>>
381 template <
typename BinaryOperator,
typename ResultType>
382 struct UseKokkosReduce
384 viskores::internal::is_type_complete<Kokkos::reduction_identity<ResultType>>::value,
391 template <
typename T,
typename U,
class CIn,
class BinaryOperator>
394 BinaryOperator binaryOperator)
404 return binaryOperator(initialValue, input.
ReadPortal().Get(0));
407 #if defined(VISKORES_KOKKOS_CUDA)
411 std::integral_constant<
413 !std::is_same<viskores::cont::kokkos::internal::ExecutionSpace, Kokkos::Cuda>::value &&
414 UseKokkosReduce<BinaryOperator, U>::value>
417 typename UseKokkosReduce<BinaryOperator, U>::type use_kokkos_reduce;
419 return ReduceImpl(input, binaryOperator, initialValue, use_kokkos_reduce);
422 template <
typename T,
typename U,
class CIn>
431 #ifndef VISKORES_CUDA
436 template <
typename BinaryOperator,
typename ResultType>
439 template <
typename T,
typename StorageIn,
typename StorageOut,
typename BinaryOperator>
442 BinaryOperator binaryOperator,
443 const T& initialValue,
446 return Superclass::ScanExclusive(input, output, binaryOperator, initialValue);
449 template <
typename T,
typename StorageIn,
typename StorageOut,
typename BinaryOperator>
450 class ScanExclusiveOperator
457 KOKKOS_INLINE_FUNCTION
460 KOKKOS_INLINE_FUNCTION
463 const T& initialValue)
465 , PortalOut(portalOut)
466 , InitialValue(initialValue)
470 KOKKOS_INLINE_FUNCTION
474 const bool final)
const
476 auto val = this->PortalIn.Get(i);
479 update = InitialValue;
483 this->PortalOut.Set(i, update);
485 update = op(update, val);
494 template <
typename BinaryOperator,
typename T,
typename StorageIn,
typename StorageOut>
496 KokkosReduceFunctor<BinaryOperator,
497 ScanExclusiveOperator<T, StorageIn, StorageOut, BinaryOperator>,
500 template <
typename T,
typename StorageIn,
typename StorageOut,
typename BinaryOperator>
503 BinaryOperator binaryOperator,
504 const T& initialValue,
515 binaryOperator, inputPortal, outputPortal, initialValue);
518 Kokkos::RangePolicy<viskores::cont::kokkos::internal::ExecutionSpace, viskores::Id> policy(
519 viskores::cont::kokkos::internal::GetExecutionSpaceInstance(), 0, length);
520 Kokkos::parallel_scan(policy, functor, result);
526 template <
typename T,
class CIn,
class COut,
class BinaryOperator>
529 BinaryOperator binaryOperator,
530 const T& initialValue)
543 Fill(output, initialValue, 1);
544 return binaryOperator(initialValue, v0);
547 #if defined(VISKORES_KOKKOS_CUDA)
549 std::integral_constant<bool,
550 !(std::is_integral<T>::value &&
sizeof(T) < 4) &&
556 return ScanExclusiveImpl(input, output, binaryOperator, initialValue, use_kokkos_scan);
559 template <
typename T,
class CIn,
class COut>
570 #ifndef VISKORES_CUDA
574 template <
typename T,
typename StorageIn,
typename StorageOut,
typename BinaryOperator>
577 BinaryOperator binaryOperator,
580 return Superclass::ScanInclusive(input, output, binaryOperator);
583 template <
typename T,
typename StorageIn,
typename StorageOut,
typename BinaryOperator>
584 class ScanInclusiveOperator
591 KOKKOS_INLINE_FUNCTION
594 KOKKOS_INLINE_FUNCTION
597 , PortalOut(portalOut)
601 KOKKOS_INLINE_FUNCTION
605 const bool final)
const
607 update = op(update, this->PortalIn.Get(i));
610 this->PortalOut.Set(i, update);
619 template <
typename BinaryOperator,
typename T,
typename StorageIn,
typename StorageOut>
621 KokkosReduceFunctor<BinaryOperator,
622 ScanInclusiveOperator<T, StorageIn, StorageOut, BinaryOperator>,
625 template <
typename T,
typename StorageIn,
typename StorageOut,
typename BinaryOperator>
628 BinaryOperator binaryOperator,
639 binaryOperator, inputPortal, outputPortal);
642 Kokkos::RangePolicy<viskores::cont::kokkos::internal::ExecutionSpace, viskores::Id> policy(
643 viskores::cont::kokkos::internal::GetExecutionSpaceInstance(), 0, length);
644 Kokkos::parallel_scan(policy, functor, result);
650 template <
typename T,
class CIn,
class COut,
class BinaryOperator>
653 BinaryOperator binaryOperator)
665 Fill(output, result, 1);
669 #if defined(VISKORES_KOKKOS_CUDA)
671 std::integral_constant<bool,
672 !(std::is_integral<T>::value &&
sizeof(T) < 4) &&
678 return ScanInclusiveImpl(input, output, binaryOperator, use_kokkos_scan);
681 template <
typename T,
class CIn,
class COut>
691 template <
typename WType,
typename IType,
typename H
ints>
693 viskores::exec::kokkos::internal::TaskBasic1D<WType, IType, Hints>& functor,
698 if (numInstances < 1)
704 functor.SetErrorMessageBuffer(GetErrorMessageBufferInstance());
707 viskores::cont::internal::HintFind<Hints,
708 viskores::cont::internal::HintThreadsPerBlock<0>,
711 Kokkos::RangePolicy<viskores::cont::kokkos::internal::ExecutionSpace,
712 Kokkos::LaunchBounds<maxThreadsPerBlock, 0>,
713 Kokkos::IndexType<viskores::Id>>
714 policy(viskores::cont::kokkos::internal::GetExecutionSpaceInstance(), 0, numInstances);
715 Kokkos::parallel_for(policy, functor);
719 template <
typename WType,
typename IType,
typename H
ints>
721 viskores::exec::kokkos::internal::TaskBasic3D<WType, IType, Hints>& functor,
726 if ((rangeMax[0] < 1) || (rangeMax[1] < 1) || (rangeMax[2] < 1))
732 functor.SetErrorMessageBuffer(GetErrorMessageBufferInstance());
735 viskores::cont::internal::HintFind<Hints,
736 viskores::cont::internal::HintThreadsPerBlock<0>,
739 Kokkos::MDRangePolicy<viskores::cont::kokkos::internal::ExecutionSpace,
740 Kokkos::LaunchBounds<maxThreadsPerBlock, 0>,
742 Kokkos::IndexType<viskores::Id>>
743 policy(viskores::cont::kokkos::internal::GetExecutionSpaceInstance(),
745 { rangeMax[0], rangeMax[1], rangeMax[2] });
752 const auto rMax_0 = rangeMax[0];
753 const auto rMax_1 = rangeMax[1];
755 Kokkos::parallel_for(
757 auto flatIdx = i + (j * rMax_0) + (k * rMax_0 * rMax_1);
763 template <
typename H
ints,
typename Functor>
768 viskores::exec::kokkos::internal::TaskBasic1D<Functor, viskores::internal::NullType, Hints>
770 ScheduleTask(kernel, numInstances);
773 template <
typename FunctorType>
776 Schedule(viskores::cont::internal::HintList<>{}, functor, numInstances);
779 template <
typename H
ints,
typename Functor>
784 viskores::exec::kokkos::internal::TaskBasic3D<Functor, viskores::internal::NullType, Hints>
786 ScheduleTask(kernel, rangeMax);
789 template <
typename FunctorType>
792 Schedule(viskores::cont::internal::HintList<>{}, functor, rangeMax);
797 template <
typename T>
811 kokkos::internal::KokkosViewExec<T> view(portal.GetArray(), portal.GetNumberOfValues());
818 viskores::cont::kokkos::internal::GetExecutionSpaceInstance().fence();
820 viskores::cont::kokkos::internal::GetExecutionSpaceInstance().fence();
823 template <
typename T>
828 Superclass::Sort(values, comp);
832 using Superclass::Sort;
834 template <
typename T>
837 SortImpl(values, comp,
typename std::is_scalar<T>::type{});
843 #if defined(VISKORES_USE_KOKKOS_THRUST)
845 template <
typename T,
typename U,
typename BinaryCompare>
846 VISKORES_CONT static std::enable_if_t<(std::is_same<BinaryCompare, viskores::SortLess>::value ||
847 std::is_same<BinaryCompare, viskores::SortGreater>::value)>
858 kokkos::internal::KokkosViewExec<T> keys_view(keys_portal.GetArray(),
859 keys_portal.GetNumberOfValues());
860 kokkos::internal::KokkosViewExec<U> values_view(values_portal.GetArray(),
861 values_portal.GetNumberOfValues());
863 thrust::device_ptr<T> keys_begin(keys_view.data());
864 thrust::device_ptr<T> keys_end(keys_view.data() + keys_view.size());
865 thrust::device_ptr<U> values_begin(values_view.data());
867 if (std::is_same<BinaryCompare, viskores::SortLess>::value)
869 thrust::sort_by_key(keys_begin, keys_end, values_begin, thrust::less<T>());
873 thrust::sort_by_key(keys_begin, keys_end, values_begin, thrust::greater<T>());
879 template <
typename T,
885 typename ValidValues>
888 BinaryCompare binary_compare,
893 Superclass::SortByKey(keys, values, binary_compare);
897 template <
typename T,
typename U,
class StorageT,
class StorageU>
906 template <
typename T,
typename U,
class StorageT,
class StorageU,
class BinaryCompare>
909 BinaryCompare binary_compare)
916 typename std::is_scalar<T>::type{},
917 typename std::is_scalar<U>::type{});
923 #ifdef VISKORES_USE_KOKKOS_THRUST
926 template <
typename K,
typename V,
class BinaryFunctor>
931 BinaryFunctor binary_functor)
944 auto keys_output_portal =
949 thrust::device_ptr<const K> keys_begin(keys_portal.GetArray());
950 thrust::device_ptr<const K> keys_end(keys_portal.GetArray() + numberOfKeys);
951 thrust::device_ptr<const V> values_begin(values_portal.GetArray());
952 thrust::device_ptr<K> keys_output_begin(keys_output_portal.GetArray());
953 thrust::device_ptr<V> values_output_begin(values_output_portal.GetArray());
955 auto ends = thrust::reduce_by_key(keys_begin,
960 thrust::equal_to<K>(),
963 num_unique_keys = ends.first - keys_output_begin;
972 template <
typename K,
typename V,
class BinaryFunctor>
978 BinaryFunctor binary_functor)
991 auto keys_output_portal =
996 thrust::device_ptr<const K> keys_begin(keys_portal.GetArray());
997 thrust::device_ptr<const K> keys_end(keys_portal.GetArray() + numberOfKeys);
998 thrust::constant_iterator<const V> values_begin(value);
999 thrust::device_ptr<K> keys_output_begin(keys_output_portal.GetArray());
1000 thrust::device_ptr<V> values_output_begin(values_output_portal.GetArray());
1002 auto ends = thrust::reduce_by_key(keys_begin,
1006 values_output_begin,
1007 thrust::equal_to<K>(),
1010 num_unique_keys = ends.first - keys_output_begin;
1018 template <
typename T,
1024 class BinaryFunctor>
1029 BinaryFunctor binary_functor)
1033 Superclass::ReduceByKey(keys, values, keys_output, values_output, binary_functor);
1037 template <
typename T,
1043 class BinaryFunctor>
1048 BinaryFunctor binary_functor)
1052 ReduceByKeyImpl(keys, values, keys_output, values_output, binary_functor);
1061 viskores::cont::kokkos::internal::GetExecutionSpaceInstance().fence();
1070 template <
typename H
ints,
typename WorkletType,
typename InvocationType>
1072 TaskBasic1D<WorkletType, InvocationType, Hints>
1075 return viskores::exec::kokkos::internal::TaskBasic1D<WorkletType, InvocationType, Hints>(
1076 worklet, invocation);
1079 template <
typename H
ints,
typename WorkletType,
typename InvocationType>
1081 TaskBasic3D<WorkletType, InvocationType, Hints>
1084 return viskores::exec::kokkos::internal::TaskBasic3D<WorkletType, InvocationType, Hints>(
1085 worklet, invocation);
1088 template <
typename WorkletType,
typename InvocationType,
typename RangeType>
1090 InvocationType& invocation,
1091 const RangeType& range)
1093 return MakeTask<viskores::cont::internal::HintList<>>(worklet, invocation, range);
1099 #undef VISKORES_VOLATILE
1101 #endif //viskores_cont_kokkos_internal_DeviceAdapterAlgorithmKokkos_h
static viskores::exec::kokkos::internal::TaskBasic3D< WorkletType, InvocationType, Hints > MakeTask(WorkletType &worklet, InvocationType &invocation, viskores::Id3, Hints={})
Definition: DeviceAdapterAlgorithmKokkos.h:1082
static void CopyIf(const viskores::cont::ArrayHandle< T, CIn > &input, const viskores::cont::ArrayHandle< U, CStencil > &stencil, viskores::cont::ArrayHandle< T, COut > &output)
Conditionally copy elements in the input array to the output array.
Struct containing device adapter algorithms.
Definition: DeviceAdapterAlgorithm.h:49
Binary Predicate that takes two arguments argument x, and y and returns product (multiplication) of t...
Definition: BinaryOperators.h:64
KokkosReduceFunctor< BinaryOperator, ScanExclusiveOperator< T, StorageIn, StorageOut, BinaryOperator >, T > ScanExclusiveFunctor
Definition: DeviceAdapterAlgorithmKokkos.h:498
static T ScanInclusiveImpl(const viskores::cont::ArrayHandle< T, StorageIn > &input, viskores::cont::ArrayHandle< T, StorageOut > &output, BinaryOperator binaryOperator, std::true_type)
Definition: DeviceAdapterAlgorithmKokkos.h:626
ReadPortalType ReadPortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:447
Base class for all user worklets invoked in the execution environment from a call to viskores::cont::...
Definition: FunctorBase.h:38
ArrayPortal Portal
Definition: DeviceAdapterAlgorithmKokkos.h:340
ArrayPortalIn PortalIn
Definition: DeviceAdapterAlgorithmKokkos.h:489
Binary Predicate that takes two arguments argument x, and y and returns True if and only if x is less...
Definition: BinaryPredicates.h:53
static T ScanExclusive(const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output, BinaryOperator binaryOperator, const T &initialValue)
Definition: DeviceAdapterAlgorithmKokkos.h:527
KOKKOS_INLINE_FUNCTION void operator()(const BinaryOperator &op, const viskores::Id i, T &update, const bool final) const
Definition: DeviceAdapterAlgorithmKokkos.h:471
typename ArrayHandle< T, StorageIn >::ReadPortalType ArrayPortalIn
Definition: DeviceAdapterAlgorithmKokkos.h:453
static void SortByKey(viskores::cont::ArrayHandle< T, StorageT > &keys, viskores::cont::ArrayHandle< U, StorageU > &values, BinaryCompare binary_compare)
Definition: DeviceAdapterAlgorithmKokkos.h:907
static viskores::Id BitFieldToUnorderedSet(const viskores::cont::BitField &bits, viskores::cont::ArrayHandle< Id, IndicesStorage > &indices)
Definition: DeviceAdapterAlgorithmKokkos.h:208
FunctorOperator Functor
Definition: DeviceAdapterAlgorithmKokkos.h:317
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
static viskores::exec::kokkos::internal::TaskBasic1D< WorkletType, InvocationType, Hints > MakeTask(WorkletType &worklet, InvocationType &invocation, viskores::Id, Hints=Hints{})
Definition: DeviceAdapterAlgorithmKokkos.h:1073
static void Schedule(FunctorType &&functor, viskores::Id numInstances)
Definition: DeviceAdapterAlgorithmKokkos.h:774
static T ScanExclusive(const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmKokkos.h:560
static void SortByKeyImpl(viskores::cont::ArrayHandle< T, StorageT > &keys, viskores::cont::ArrayHandle< U, StorageU > &values, BinaryCompare binary_compare, ValidKeys, ValidValues)
Definition: DeviceAdapterAlgorithmKokkos.h:886
UseKokkosReduce< BinaryOperator, ResultType > UseKokkosScan
Definition: DeviceAdapterAlgorithmKokkos.h:437
static T ZeroInitialization()
A static function that returns 0 (or the closest equivalent to it) for the given type.
Definition: TypeTraits.h:85
Binary Predicate that takes two arguments argument x, and y and returns the bitwise operation x&y
Definition: BinaryOperators.h:153
static U Reduce(const viskores::cont::ArrayHandle< T, CIn > &input, U initialValue, BinaryOperator binaryOperator)
Definition: DeviceAdapterAlgorithmKokkos.h:392
typename ArrayHandle< T, StorageIn >::ReadPortalType ArrayPortalIn
Definition: DeviceAdapterAlgorithmKokkos.h:587
BinaryOperator Operator
Definition: DeviceAdapterAlgorithmKokkos.h:316
KOKKOS_INLINE_FUNCTION void operator()(const BinaryOperator &op, viskores::Id i, ResultType &update) const
Definition: DeviceAdapterAlgorithmKokkos.h:334
KOKKOS_INLINE_FUNCTION void join(volatile value_type &dst, const volatile value_type &src) const
Definition: DeviceAdapterAlgorithmKokkos.h:290
KOKKOS_INLINE_FUNCTION ScanInclusiveOperator(const ArrayPortalIn &portalIn, const ArrayPortalOut &portalOut)
Definition: DeviceAdapterAlgorithmKokkos.h:595
viskores::Id GetNumberOfBits() const
Return the number of bits stored by this BitField.
Manages an array-worth of data.
Definition: ArrayHandle.h:313
typename ArrayHandle< T, StorageOut >::WritePortalType ArrayPortalOut
Definition: DeviceAdapterAlgorithmKokkos.h:454
A class that points to and access and array of data.
Definition: ArrayPortal.h:70
static void SortByKey(viskores::cont::ArrayHandle< T, StorageT > &keys, viskores::cont::ArrayHandle< U, StorageU > &values)
Definition: DeviceAdapterAlgorithmKokkos.h:898
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
static ResultType ReduceImpl(const ArrayHandle &input, BinaryOperator binaryOperator, ResultType initialValue, std::true_type)
Definition: DeviceAdapterAlgorithmKokkos.h:349
static T VIn
Definition: DeviceAdapterAlgorithm.h:360
static void Schedule(FunctorType &&functor, viskores::Id3 rangeMax)
Definition: DeviceAdapterAlgorithmKokkos.h:790
#define VISKORES_EXEC_CONT
Definition: ExportMacros.h:60
static T U
Definition: DeviceAdapterAlgorithm.h:358
static void Synchronize()
Definition: DeviceAdapterAlgorithmKokkos.h:1059
static T VOut
Definition: DeviceAdapterAlgorithm.h:361
KOKKOS_INLINE_FUNCTION void operator()(viskores::Id i, ResultType &update, const bool final) const
Definition: DeviceAdapterAlgorithmKokkos.h:310
Tag for a device adapter that uses the Kokkos library to run algorithms in parallel.
Definition: DeviceAdapterTagKokkos.h:39
static T ScanExclusive(const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output)
Compute an exclusive prefix sum operation on the input ArrayHandle.
static ResultType ReduceImpl(const ArrayHandle &input, BinaryOperator binaryOperator, ResultType initialValue, std::false_type)
Definition: DeviceAdapterAlgorithmKokkos.h:264
static U Reduce(const viskores::cont::ArrayHandle< T, CIn > &input, U initialValue)
Compute a accumulated sum operation on the input ArrayHandle.
static void SortImpl(viskores::cont::ArrayHandle< T > &values, viskores::SortLess, std::true_type)
Definition: DeviceAdapterAlgorithmKokkos.h:798
ReadPortalType PrepareForInput(viskores::cont::DeviceAdapterId device, viskores::cont::Token &token) const
Prepares this BitField to be used as an input to an operation in the execution environment.
static void Copy(const viskores::cont::ArrayHandle< T > &input, viskores::cont::ArrayHandle< T > &output)
Definition: DeviceAdapterAlgorithmKokkos.h:240
Binary Predicate that takes two arguments argument x, and y and returns the x if x > y otherwise retu...
Definition: BinaryOperators.h:93
static viskores::Id CountSetBits(const viskores::cont::BitField &bits)
Definition: DeviceAdapterAlgorithmKokkos.h:224
static void ScheduleTask(viskores::exec::kokkos::internal::TaskBasic1D< WType, IType, Hints > &functor, viskores::Id numInstances)
Definition: DeviceAdapterAlgorithmKokkos.h:692
KOKKOS_INLINE_FUNCTION void init(value_type &dst) const
Definition: DeviceAdapterAlgorithmKokkos.h:296
The TypeTraits class provides helpful compile-time information about the basic types used in Viskores...
Definition: TypeTraits.h:69
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
void ReleaseResources() const
Releases all resources in both the control and execution environments.
Definition: ArrayHandle.h:600
Binary Predicate that takes two arguments argument x, and y and returns the bitwise operation x|y
Definition: BinaryOperators.h:176
KOKKOS_INLINE_FUNCTION ScanExclusiveOperator()
Definition: DeviceAdapterAlgorithmKokkos.h:458
static void SortByKey(viskores::cont::ArrayHandle< T, StorageT > &keys, viskores::cont::ArrayHandle< U, StorageU > &values)
Unstable ascending sort of keys and values.
#define VISKORES_CONT
Definition: ExportMacros.h:65
Definition: BitField.h:507
static T ScanExclusiveImpl(const viskores::cont::ArrayHandle< T, StorageIn > &input, viskores::cont::ArrayHandle< T, StorageOut > &output, BinaryOperator binaryOperator, const T &initialValue, std::false_type)
Definition: DeviceAdapterAlgorithmKokkos.h:440
Groups connected points that have the same field value.
Definition: Atomic.h:27
static T ScanExclusiveImpl(const viskores::cont::ArrayHandle< T, StorageIn > &input, viskores::cont::ArrayHandle< T, StorageOut > &output, BinaryOperator binaryOperator, const T &initialValue, std::true_type)
Definition: DeviceAdapterAlgorithmKokkos.h:501
ArrayPortalIn PortalIn
Definition: DeviceAdapterAlgorithmKokkos.h:615
KOKKOS_INLINE_FUNCTION ScanInclusiveOperator()
Definition: DeviceAdapterAlgorithmKokkos.h:592
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
KOKKOS_INLINE_FUNCTION ReduceOperator(const ArrayPortal &portal)
Definition: DeviceAdapterAlgorithmKokkos.h:328
static void Schedule(Hints, Functor functor, viskores::Id numInstances)
Definition: DeviceAdapterAlgorithmKokkos.h:764
viskores::Int32 CountSetBits(viskores::UInt32 word)
Count the total number of bits set in word.
Definition: Math.h:2948
static T ScanInclusive(const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output)
Compute an inclusive prefix sum operation on the input ArrayHandle.
void Allocate(viskores::Id numberOfValues, viskores::CopyFlag preserve, viskores::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:504
KOKKOS_INLINE_FUNCTION KokkosReduceFunctor(const BinaryOperator &op, Args... args)
Definition: DeviceAdapterAlgorithmKokkos.h:283
viskores::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:482
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
static U Reduce(const viskores::cont::ArrayHandle< T, CIn > &input, U initialValue)
Definition: DeviceAdapterAlgorithmKokkos.h:423
static T ScanInclusiveImpl(const viskores::cont::ArrayHandle< T, StorageIn > &input, viskores::cont::ArrayHandle< T, StorageOut > &output, BinaryOperator binaryOperator, std::false_type)
Definition: DeviceAdapterAlgorithmKokkos.h:575
KOKKOS_INLINE_FUNCTION void operator()(const BinaryOperator &op, const viskores::Id i, T &update, const bool final) const
Definition: DeviceAdapterAlgorithmKokkos.h:602
KOKKOS_INLINE_FUNCTION KokkosReduceFunctor()
Definition: DeviceAdapterAlgorithmKokkos.h:280
typename ArrayHandle< T, StorageOut >::WritePortalType ArrayPortalOut
Definition: DeviceAdapterAlgorithmKokkos.h:588
static T KIn
Definition: DeviceAdapterAlgorithm.h:359
static T ScanInclusive(const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output)
Definition: DeviceAdapterAlgorithmKokkos.h:682
static void SortImpl(viskores::cont::ArrayHandle< T > &values, viskores::SortLess comp, std::false_type)
Definition: DeviceAdapterAlgorithmKokkos.h:824
Binary Predicate that takes two arguments argument x, and y and returns sum (addition) of the two val...
Definition: BinaryOperators.h:41
Definition: DeviceAdapterAlgorithmKokkos.h:192
static void ReduceByKey(const viskores::cont::ArrayHandle< T, CKeyIn > &keys, const viskores::cont::ArrayHandle< U, CValIn > &values, viskores::cont::ArrayHandle< T, CKeyOut > &keys_output, viskores::cont::ArrayHandle< U, CValOut > &values_output, BinaryFunctor binary_functor)
Compute a accumulated sum operation on the input key value pairs.
#define VISKORES_VOLATILE
Definition: DeviceAdapterAlgorithmKokkos.h:47
ResultType value_type
Definition: DeviceAdapterAlgorithmKokkos.h:277
KokkosReduceFunctor< BinaryOperator, ScanInclusiveOperator< T, StorageIn, StorageOut, BinaryOperator >, T > ScanInclusiveFunctor
Definition: DeviceAdapterAlgorithmKokkos.h:623
T InitialValue
Definition: DeviceAdapterAlgorithmKokkos.h:491
viskores::cont::internal::DeviceAdapterAlgorithmGeneral< DeviceAdapterAlgorithm< viskores::cont::DeviceAdapterTagKokkos >, viskores::cont::DeviceAdapterTagKokkos > Superclass
Definition: DeviceAdapterAlgorithmKokkos.h:200
KOKKOS_INLINE_FUNCTION ScanExclusiveOperator(const ArrayPortalIn &portalIn, const ArrayPortalOut &portalOut, const T &initialValue)
Definition: DeviceAdapterAlgorithmKokkos.h:461
ArrayPortalOut PortalOut
Definition: DeviceAdapterAlgorithmKokkos.h:616
static T ScanInclusive(const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< T, COut > &output, BinaryOperator binaryOperator)
Definition: DeviceAdapterAlgorithmKokkos.h:651
#define VISKORES_LOG_SCOPE_FUNCTION(level)
Definition: Logging.h:225
@ Perf
General timing data and algorithm flow information, such as filter execution, worklet dispatches,...
Class providing a device-specific support for selecting the optimal Task type for a given worklet.
Definition: DeviceAdapterAlgorithm.h:757
static void Sort(viskores::cont::ArrayHandle< T > &values, viskores::SortLess comp)
Definition: DeviceAdapterAlgorithmKokkos.h:835
Binary Predicate that takes two arguments argument x, and y and returns the x if x < y otherwise retu...
Definition: BinaryOperators.h:107
KOKKOS_INLINE_FUNCTION ReduceOperator()
Definition: DeviceAdapterAlgorithmKokkos.h:325
static auto MakeTask(WorkletType &worklet, InvocationType &invocation, const RangeType &range)
Definition: DeviceAdapterAlgorithmKokkos.h:1089
KokkosReduceFunctor< BinaryOperator, ReduceOperator< ArrayPortal, BinaryOperator, ResultType >, ResultType > ReduceFunctor
Definition: DeviceAdapterAlgorithmKokkos.h:346
viskores::Id size_type
Definition: DeviceAdapterAlgorithmKokkos.h:276
static void ScheduleTask(viskores::exec::kokkos::internal::TaskBasic3D< WType, IType, Hints > &functor, viskores::Id3 rangeMax)
Definition: DeviceAdapterAlgorithmKokkos.h:720
viskores::cont::ArrayHandleImplicit< FunctorType > make_ArrayHandleImplicit(FunctorType functor, viskores::Id length)
make_ArrayHandleImplicit is convenience function to generate an ArrayHandleImplicit.
Definition: ArrayHandleImplicit.h:210
KOKKOS_INLINE_FUNCTION void operator()(viskores::Id i, ResultType &update) const
Definition: DeviceAdapterAlgorithmKokkos.h:303
static void Schedule(Hints, Functor functor, const viskores::Id3 &rangeMax)
Definition: DeviceAdapterAlgorithmKokkos.h:780
static void Fill(viskores::cont::BitField &bits, bool value, viskores::Id numBits)
Fill the BitField with a specific pattern of bits.
A short fixed-length array.
Definition: Types.h:365
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:43
Binary Predicate that takes two arguments argument x, and y and returns a viskores::Vec<T,...
Definition: BinaryOperators.h:120
#define VISKORES_EXEC
Definition: ExportMacros.h:59
An implicit array handle containing the its own indices.
Definition: ArrayHandleIndex.h:64
ArrayPortalOut PortalOut
Definition: DeviceAdapterAlgorithmKokkos.h:490
static void Schedule(Functor functor, viskores::Id numInstances)
Schedule many instances of a function to run on concurrent threads.