51 #ifndef KOKKOS_SCATTER_VIEW_HPP 52 #define KOKKOS_SCATTER_VIEW_HPP 54 #include <Kokkos_Core.hpp> 66 struct ScatterProd {};
70 struct ScatterNonDuplicated {};
71 struct ScatterDuplicated {};
73 struct ScatterNonAtomic {};
74 struct ScatterAtomic {};
83 template <
typename ExecSpace>
84 struct DefaultDuplication;
86 template <
typename ExecSpace,
typename Duplication>
87 struct DefaultContribution;
89 #ifdef KOKKOS_ENABLE_SERIAL 91 struct DefaultDuplication<
Kokkos::Serial> {
92 using type = Kokkos::Experimental::ScatterNonDuplicated;
96 struct DefaultContribution<
Kokkos::Serial,
97 Kokkos::Experimental::ScatterNonDuplicated> {
98 using type = Kokkos::Experimental::ScatterNonAtomic;
101 struct DefaultContribution<
Kokkos::Serial,
102 Kokkos::Experimental::ScatterDuplicated> {
103 using type = Kokkos::Experimental::ScatterNonAtomic;
107 #ifdef KOKKOS_ENABLE_OPENMP 109 struct DefaultDuplication<
Kokkos::OpenMP> {
110 using type = Kokkos::Experimental::ScatterDuplicated;
113 struct DefaultContribution<
Kokkos::OpenMP,
114 Kokkos::Experimental::ScatterNonDuplicated> {
115 using type = Kokkos::Experimental::ScatterAtomic;
118 struct DefaultContribution<
Kokkos::OpenMP,
119 Kokkos::Experimental::ScatterDuplicated> {
120 using type = Kokkos::Experimental::ScatterNonAtomic;
124 #ifdef KOKKOS_ENABLE_OPENMPTARGET 126 struct DefaultDuplication<
Kokkos::Experimental::OpenMPTarget> {
127 using type = Kokkos::Experimental::ScatterNonDuplicated;
130 struct DefaultContribution<
Kokkos::Experimental::OpenMPTarget,
131 Kokkos::Experimental::ScatterNonDuplicated> {
132 using type = Kokkos::Experimental::ScatterAtomic;
135 struct DefaultContribution<
Kokkos::Experimental::OpenMPTarget,
136 Kokkos::Experimental::ScatterDuplicated> {
137 using type = Kokkos::Experimental::ScatterNonAtomic;
141 #ifdef KOKKOS_ENABLE_HPX 143 struct DefaultDuplication<
Kokkos::Experimental::HPX> {
144 using type = Kokkos::Experimental::ScatterDuplicated;
147 struct DefaultContribution<
Kokkos::Experimental::HPX,
148 Kokkos::Experimental::ScatterNonDuplicated> {
149 using type = Kokkos::Experimental::ScatterAtomic;
152 struct DefaultContribution<
Kokkos::Experimental::HPX,
153 Kokkos::Experimental::ScatterDuplicated> {
154 using type = Kokkos::Experimental::ScatterNonAtomic;
158 #ifdef KOKKOS_ENABLE_THREADS 160 struct DefaultDuplication<
Kokkos::Threads> {
161 using type = Kokkos::Experimental::ScatterDuplicated;
164 struct DefaultContribution<
Kokkos::Threads,
165 Kokkos::Experimental::ScatterNonDuplicated> {
166 using type = Kokkos::Experimental::ScatterAtomic;
169 struct DefaultContribution<
Kokkos::Threads,
170 Kokkos::Experimental::ScatterDuplicated> {
171 using type = Kokkos::Experimental::ScatterNonAtomic;
175 #ifdef KOKKOS_ENABLE_CUDA 177 struct DefaultDuplication<
Kokkos::Cuda> {
178 using type = Kokkos::Experimental::ScatterNonDuplicated;
181 struct DefaultContribution<
Kokkos::Cuda,
182 Kokkos::Experimental::ScatterNonDuplicated> {
183 using type = Kokkos::Experimental::ScatterAtomic;
186 struct DefaultContribution<
Kokkos::Cuda,
187 Kokkos::Experimental::ScatterDuplicated> {
188 using type = Kokkos::Experimental::ScatterAtomic;
192 #ifdef KOKKOS_ENABLE_HIP 194 struct DefaultDuplication<
Kokkos::Experimental::HIP> {
195 using type = Kokkos::Experimental::ScatterNonDuplicated;
198 struct DefaultContribution<
Kokkos::Experimental::HIP,
199 Kokkos::Experimental::ScatterNonDuplicated> {
200 using type = Kokkos::Experimental::ScatterAtomic;
203 struct DefaultContribution<
Kokkos::Experimental::HIP,
204 Kokkos::Experimental::ScatterDuplicated> {
205 using type = Kokkos::Experimental::ScatterAtomic;
209 #ifdef KOKKOS_ENABLE_SYCL 211 struct DefaultDuplication<
Kokkos::Experimental::SYCL> {
212 using type = Kokkos::Experimental::ScatterNonDuplicated;
215 struct DefaultContribution<
Kokkos::Experimental::SYCL,
216 Kokkos::Experimental::ScatterNonDuplicated> {
217 using type = Kokkos::Experimental::ScatterAtomic;
220 struct DefaultContribution<
Kokkos::Experimental::SYCL,
221 Kokkos::Experimental::ScatterDuplicated> {
222 using type = Kokkos::Experimental::ScatterAtomic;
231 template <
typename ValueType,
typename Op,
typename DeviceType,
232 typename Contribution>
241 template <
typename ValueType,
typename DeviceType>
242 struct ScatterValue<ValueType,
Kokkos::Experimental::ScatterSum, DeviceType,
243 Kokkos::Experimental::ScatterNonAtomic> {
247 KOKKOS_FORCEINLINE_FUNCTION ScatterValue(ValueType& value_in)
249 KOKKOS_FORCEINLINE_FUNCTION ScatterValue(ScatterValue&& other)
250 : value(other.value) {}
251 KOKKOS_FORCEINLINE_FUNCTION
void operator+=(ValueType
const& rhs) {
254 KOKKOS_FORCEINLINE_FUNCTION
void operator++() { update(1); }
255 KOKKOS_FORCEINLINE_FUNCTION
void operator++(
int) { update(1); }
256 KOKKOS_FORCEINLINE_FUNCTION
void operator-=(ValueType
const& rhs) {
257 update(ValueType(-rhs));
259 KOKKOS_FORCEINLINE_FUNCTION
void operator--() { update(ValueType(-1)); }
260 KOKKOS_FORCEINLINE_FUNCTION
void operator--(
int) { update(ValueType(-1)); }
261 KOKKOS_FORCEINLINE_FUNCTION
void update(ValueType
const& rhs) {
264 KOKKOS_FORCEINLINE_FUNCTION
void reset() {
265 value = reduction_identity<ValueType>::sum();
274 template <
typename ValueType,
typename DeviceType>
275 struct ScatterValue<ValueType,
Kokkos::Experimental::ScatterSum, DeviceType,
276 Kokkos::Experimental::ScatterAtomic> {
280 KOKKOS_FORCEINLINE_FUNCTION ScatterValue(ValueType& value_in)
283 KOKKOS_FORCEINLINE_FUNCTION
void operator+=(ValueType
const& rhs) {
284 this->join(value, rhs);
286 KOKKOS_FORCEINLINE_FUNCTION
void operator++() { this->join(value, 1); }
287 KOKKOS_FORCEINLINE_FUNCTION
void operator++(
int) { this->join(value, 1); }
288 KOKKOS_FORCEINLINE_FUNCTION
void operator-=(ValueType
const& rhs) {
289 this->join(value, ValueType(-rhs));
291 KOKKOS_FORCEINLINE_FUNCTION
void operator--() {
292 this->join(value, ValueType(-1));
294 KOKKOS_FORCEINLINE_FUNCTION
void operator--(
int) {
295 this->join(value, ValueType(-1));
298 KOKKOS_INLINE_FUNCTION
299 void join(ValueType& dest,
const ValueType& src)
const {
300 Kokkos::atomic_add(&dest, src);
303 KOKKOS_INLINE_FUNCTION
304 void join(
volatile ValueType& dest,
const volatile ValueType& src)
const {
305 Kokkos::atomic_add(&dest, src);
308 KOKKOS_FORCEINLINE_FUNCTION
void update(ValueType
const& rhs) {
309 this->join(value, rhs);
312 KOKKOS_FORCEINLINE_FUNCTION
void reset() {
313 value = reduction_identity<ValueType>::sum();
323 template <
typename ValueType,
typename DeviceType>
324 struct ScatterValue<ValueType,
Kokkos::Experimental::ScatterProd, DeviceType,
325 Kokkos::Experimental::ScatterNonAtomic> {
329 KOKKOS_FORCEINLINE_FUNCTION ScatterValue(ValueType& value_in)
331 KOKKOS_FORCEINLINE_FUNCTION ScatterValue(ScatterValue&& other)
332 : value(other.value) {}
333 KOKKOS_FORCEINLINE_FUNCTION
void operator*=(ValueType
const& rhs) {
336 KOKKOS_FORCEINLINE_FUNCTION
void operator/=(ValueType
const& rhs) {
340 KOKKOS_FORCEINLINE_FUNCTION
void update(ValueType
const& rhs) {
343 KOKKOS_FORCEINLINE_FUNCTION
void reset() {
344 value = reduction_identity<ValueType>::prod();
354 template <
typename ValueType,
typename DeviceType>
355 struct ScatterValue<ValueType,
Kokkos::Experimental::ScatterProd, DeviceType,
356 Kokkos::Experimental::ScatterAtomic> {
360 KOKKOS_FORCEINLINE_FUNCTION ScatterValue(ValueType& value_in)
362 KOKKOS_FORCEINLINE_FUNCTION ScatterValue(ScatterValue&& other)
363 : value(other.value) {}
365 KOKKOS_FORCEINLINE_FUNCTION
void operator*=(ValueType
const& rhs) {
366 Kokkos::atomic_mul(&value, rhs);
368 KOKKOS_FORCEINLINE_FUNCTION
void operator/=(ValueType
const& rhs) {
369 Kokkos::atomic_div(&value, rhs);
372 KOKKOS_FORCEINLINE_FUNCTION
373 void atomic_prod(ValueType& dest,
const ValueType& src)
const {
374 bool success =
false;
376 ValueType dest_old = dest;
377 ValueType dest_new = dest_old * src;
379 Kokkos::atomic_compare_exchange<ValueType>(&dest, dest_old, dest_new);
380 success = ((dest_new - dest_old) / dest_old <= 1e-15);
384 KOKKOS_INLINE_FUNCTION
385 void join(ValueType& dest,
const ValueType& src)
const {
386 atomic_prod(&dest, src);
389 KOKKOS_INLINE_FUNCTION
390 void join(
volatile ValueType& dest,
const volatile ValueType& src)
const {
391 atomic_prod(&dest, src);
394 KOKKOS_FORCEINLINE_FUNCTION
void update(ValueType
const& rhs) {
395 atomic_prod(&value, rhs);
397 KOKKOS_FORCEINLINE_FUNCTION
void reset() {
398 value = reduction_identity<ValueType>::prod();
408 template <
typename ValueType,
typename DeviceType>
409 struct ScatterValue<ValueType,
Kokkos::Experimental::ScatterMin, DeviceType,
410 Kokkos::Experimental::ScatterNonAtomic> {
412 KOKKOS_FORCEINLINE_FUNCTION ScatterValue(ValueType& value_in)
414 KOKKOS_FORCEINLINE_FUNCTION ScatterValue(ScatterValue&& other)
415 : value(other.value) {}
418 KOKKOS_FORCEINLINE_FUNCTION
void update(ValueType
const& rhs) {
419 value = rhs < value ? rhs : value;
421 KOKKOS_FORCEINLINE_FUNCTION
void reset() {
422 value = reduction_identity<ValueType>::min();
432 template <
typename ValueType,
typename DeviceType>
433 struct ScatterValue<ValueType,
Kokkos::Experimental::ScatterMin, DeviceType,
434 Kokkos::Experimental::ScatterAtomic> {
438 KOKKOS_FORCEINLINE_FUNCTION ScatterValue(ValueType& value_in)
440 KOKKOS_FORCEINLINE_FUNCTION ScatterValue(ScatterValue&& other)
441 : value(other.value) {}
443 KOKKOS_FORCEINLINE_FUNCTION
444 void atomic_min(ValueType& dest,
const ValueType& src)
const {
445 bool success =
false;
447 ValueType dest_old = dest;
448 ValueType dest_new = (dest_old > src) ? src : dest_old;
450 Kokkos::atomic_compare_exchange<ValueType>(&dest, dest_old, dest_new);
451 success = ((dest_new - dest_old) / dest_old <= 1e-15);
455 KOKKOS_INLINE_FUNCTION
456 void join(ValueType& dest,
const ValueType& src)
const {
457 atomic_min(dest, src);
460 KOKKOS_INLINE_FUNCTION
461 void join(
volatile ValueType& dest,
const volatile ValueType& src)
const {
462 atomic_min(dest, src);
465 KOKKOS_FORCEINLINE_FUNCTION
void update(ValueType
const& rhs) {
466 this->join(value, rhs);
468 KOKKOS_FORCEINLINE_FUNCTION
void reset() {
469 value = reduction_identity<ValueType>::min();
479 template <
typename ValueType,
typename DeviceType>
480 struct ScatterValue<ValueType,
Kokkos::Experimental::ScatterMax, DeviceType,
481 Kokkos::Experimental::ScatterNonAtomic> {
485 KOKKOS_FORCEINLINE_FUNCTION ScatterValue(ValueType& value_in)
487 KOKKOS_FORCEINLINE_FUNCTION ScatterValue(ScatterValue&& other)
488 : value(other.value) {}
489 KOKKOS_FORCEINLINE_FUNCTION
void update(ValueType
const& rhs) {
490 value = rhs > value ? rhs : value;
492 KOKKOS_FORCEINLINE_FUNCTION
void reset() {
493 value = reduction_identity<ValueType>::max();
503 template <
typename ValueType,
typename DeviceType>
504 struct ScatterValue<ValueType,
Kokkos::Experimental::ScatterMax, DeviceType,
505 Kokkos::Experimental::ScatterAtomic> {
509 KOKKOS_FORCEINLINE_FUNCTION ScatterValue(ValueType& value_in)
511 KOKKOS_FORCEINLINE_FUNCTION ScatterValue(ScatterValue&& other)
512 : value(other.value) {}
514 KOKKOS_FORCEINLINE_FUNCTION
515 void atomic_max(ValueType& dest,
const ValueType& src)
const {
516 bool success =
false;
518 ValueType dest_old = dest;
519 ValueType dest_new = (dest_old < src) ? src : dest_old;
521 Kokkos::atomic_compare_exchange<ValueType>(&dest, dest_old, dest_new);
522 success = ((dest_new - dest_old) / dest_old <= 1e-15);
526 KOKKOS_INLINE_FUNCTION
527 void join(ValueType& dest,
const ValueType& src)
const {
528 atomic_max(dest, src);
531 KOKKOS_INLINE_FUNCTION
532 void join(
volatile ValueType& dest,
const volatile ValueType& src)
const {
533 atomic_max(dest, src);
536 KOKKOS_FORCEINLINE_FUNCTION
void update(ValueType
const& rhs) {
537 this->join(value, rhs);
539 KOKKOS_FORCEINLINE_FUNCTION
void reset() {
540 value = reduction_identity<ValueType>::max();
549 template <
typename T,
typename Layout>
550 struct DuplicatedDataType;
552 template <
typename T>
553 struct DuplicatedDataType<T,
Kokkos::LayoutRight> {
554 using value_type = T*;
557 template <
typename T,
size_t N>
558 struct DuplicatedDataType<T[N],
Kokkos::LayoutRight> {
560 typename DuplicatedDataType<T, Kokkos::LayoutRight>::value_type[N];
563 template <
typename T>
564 struct DuplicatedDataType<T[],
Kokkos::LayoutRight> {
566 typename DuplicatedDataType<T, Kokkos::LayoutRight>::value_type[];
569 template <
typename T>
572 typename DuplicatedDataType<T, Kokkos::LayoutRight>::value_type*;
575 template <
typename T>
576 struct DuplicatedDataType<T,
Kokkos::LayoutLeft> {
577 using value_type = T*;
580 template <
typename T,
size_t N>
581 struct DuplicatedDataType<T[N],
Kokkos::LayoutLeft> {
583 typename DuplicatedDataType<T, Kokkos::LayoutLeft>::value_type*;
586 template <
typename T>
587 struct DuplicatedDataType<T[],
Kokkos::LayoutLeft> {
589 typename DuplicatedDataType<T, Kokkos::LayoutLeft>::value_type*;
592 template <
typename T>
595 typename DuplicatedDataType<T, Kokkos::LayoutLeft>::value_type*;
601 void args_to_array(
size_t* array,
int pos, T dim0) {
604 template <
class T,
class... Dims>
605 void args_to_array(
size_t* array,
int pos, T dim0, Dims... dims) {
607 args_to_array(array, pos + 1, dims...);
613 template <
typename Layout,
int rank,
typename V,
typename... Args>
615 using next = Slice<Layout, rank - 1, V, Kokkos::Impl::ALL_t, Args...>;
616 using value_type =
typename next::value_type;
618 static value_type
get(V
const& src,
const size_t i, Args... args) {
619 return next::get(src, i, Kokkos::ALL, args...);
623 template <
typename V,
typename... Args>
624 struct Slice<
Kokkos::LayoutRight, 1, V, Args...> {
626 typename Kokkos::Impl::ViewMapping<void, V,
const size_t, Args...>::type;
627 static value_type
get(V
const& src,
const size_t i, Args... args) {
628 return Kokkos::subview(src, i, args...);
632 template <
typename V,
typename... Args>
633 struct Slice<
Kokkos::LayoutLeft, 1, V, Args...> {
635 typename Kokkos::Impl::ViewMapping<void, V, Args...,
const size_t>::type;
636 static value_type
get(V
const& src,
const size_t i, Args... args) {
637 return Kokkos::subview(src, args..., i);
641 template <
typename ExecSpace,
typename ValueType,
typename Op>
642 struct ReduceDuplicates;
644 template <
typename ExecSpace,
typename ValueType,
typename Op>
645 struct ReduceDuplicatesBase {
646 using Derived = ReduceDuplicates<ExecSpace, ValueType, Op>;
647 ValueType
const* src;
652 ReduceDuplicatesBase(ExecSpace
const& exec_space, ValueType
const* src_in,
653 ValueType* dest_in,
size_t stride_in,
size_t start_in,
654 size_t n_in, std::string
const& name)
655 : src(src_in), dst(dest_in), stride(stride_in), start(start_in), n(n_in) {
657 std::string(
"Kokkos::ScatterView::ReduceDuplicates [") + name +
"]",
658 RangePolicy<ExecSpace, size_t>(exec_space, 0, stride),
659 static_cast<Derived const&>(*
this));
666 template <
typename ExecSpace,
typename ValueType,
typename Op>
667 struct ReduceDuplicates
668 :
public ReduceDuplicatesBase<ExecSpace, ValueType, Op> {
669 using Base = ReduceDuplicatesBase<ExecSpace, ValueType, Op>;
670 ReduceDuplicates(ExecSpace
const& exec_space, ValueType
const* src_in,
671 ValueType* dst_in,
size_t stride_in,
size_t start_in,
672 size_t n_in, std::string
const& name)
673 : Base(exec_space, src_in, dst_in, stride_in, start_in, n_in, name) {}
674 KOKKOS_FORCEINLINE_FUNCTION
void operator()(
size_t i)
const {
675 for (
size_t j = Base::start; j < Base::n; ++j) {
676 ScatterValue<ValueType, Op, ExecSpace,
677 Kokkos::Experimental::ScatterNonAtomic>
679 sv.update(Base::src[i + Base::stride * j]);
684 template <
typename ExecSpace,
typename ValueType,
typename Op>
685 struct ResetDuplicates;
687 template <
typename ExecSpace,
typename ValueType,
typename Op>
688 struct ResetDuplicatesBase {
689 using Derived = ResetDuplicates<ExecSpace, ValueType, Op>;
691 ResetDuplicatesBase(ExecSpace
const& exec_space, ValueType* data_in,
692 size_t size_in, std::string
const& name)
695 std::string(
"Kokkos::ScatterView::ResetDuplicates [") + name +
"]",
696 RangePolicy<ExecSpace, size_t>(exec_space, 0, size_in),
697 static_cast<Derived const&>(*
this));
704 template <
typename ExecSpace,
typename ValueType,
typename Op>
705 struct ResetDuplicates :
public ResetDuplicatesBase<ExecSpace, ValueType, Op> {
706 using Base = ResetDuplicatesBase<ExecSpace, ValueType, Op>;
707 ResetDuplicates(ExecSpace
const& exec_space, ValueType* data_in,
708 size_t size_in, std::string
const& name)
709 : Base(exec_space, data_in, size_in, name) {}
710 KOKKOS_FORCEINLINE_FUNCTION
void operator()(
size_t i)
const {
711 ScatterValue<ValueType, Op, ExecSpace,
712 Kokkos::Experimental::ScatterNonAtomic>
718 template <
typename... P>
719 void check_scatter_view_allocation_properties_argument(
720 ViewCtorProp<P...>
const&) {
721 static_assert(ViewCtorProp<P...>::has_execution_space &&
722 ViewCtorProp<P...>::has_label &&
723 ViewCtorProp<P...>::initialize,
724 "Allocation property must have an execution name as well as a " 725 "label, and must perform the view initialization");
735 template <
typename DataType,
736 typename Layout = Kokkos::DefaultExecutionSpace::array_layout,
737 typename DeviceType = Kokkos::DefaultExecutionSpace,
738 typename Op = Kokkos::Experimental::ScatterSum,
739 typename Duplication =
typename Kokkos::Impl::Experimental::
740 DefaultDuplication<typename DeviceType::execution_space>::type,
741 typename Contribution =
742 typename Kokkos::Impl::Experimental::DefaultContribution<
743 typename DeviceType::execution_space, Duplication>::type>
746 template <
typename DataType,
typename Op,
typename DeviceType,
typename Layout,
747 typename Duplication,
typename Contribution,
748 typename OverrideContribution>
752 template <
typename DataType,
typename Op,
typename DeviceType,
typename Layout,
753 typename Contribution>
754 class ScatterView<DataType, Layout, DeviceType, Op, ScatterNonDuplicated,
757 using execution_space =
typename DeviceType::execution_space;
758 using memory_space =
typename DeviceType::memory_space;
759 using device_type = Kokkos::Device<execution_space, memory_space>;
761 using original_value_type =
typename original_view_type::value_type;
762 using original_reference_type =
typename original_view_type::reference_type;
763 friend class ScatterAccess<DataType, Op, DeviceType, Layout,
764 ScatterNonDuplicated, Contribution,
766 friend class ScatterAccess<DataType, Op, DeviceType, Layout,
767 ScatterNonDuplicated, Contribution, ScatterAtomic>;
768 template <
class,
class,
class,
class,
class,
class>
769 friend class ScatterView;
771 ScatterView() =
default;
773 template <
typename RT,
typename... RP>
774 ScatterView(View<RT, RP...>
const& original_view)
775 : internal_view(original_view) {}
777 template <
typename RT,
typename... P,
typename... RP>
778 ScatterView(execution_space
const& ,
779 View<RT, RP...>
const& original_view)
780 : internal_view(original_view) {}
782 template <
typename... Dims>
783 ScatterView(std::string
const& name, Dims... dims)
784 : internal_view(name, dims...) {}
789 template <
typename... P,
typename... Dims>
790 ScatterView(::Kokkos::Impl::ViewCtorProp<P...>
const& arg_prop, Dims... dims)
791 : internal_view(arg_prop, dims...) {
792 using ::Kokkos::Impl::Experimental::
793 check_scatter_view_allocation_properties_argument;
794 check_scatter_view_allocation_properties_argument(arg_prop);
797 template <
typename OtherDataType,
typename OtherDeviceType>
798 KOKKOS_FUNCTION ScatterView(
799 const ScatterView<OtherDataType, Layout, OtherDeviceType, Op,
800 ScatterNonDuplicated, Contribution>& other_view)
801 : internal_view(other_view.internal_view) {}
803 template <
typename OtherDataType,
typename OtherDeviceType>
804 KOKKOS_FUNCTION
void operator=(
805 const ScatterView<OtherDataType, Layout, OtherDeviceType, Op,
806 ScatterNonDuplicated, Contribution>& other_view) {
807 internal_view = other_view.internal_view;
810 template <
typename Overr
ideContribution = Contribution>
811 KOKKOS_FORCEINLINE_FUNCTION
812 ScatterAccess<DataType, Op, DeviceType, Layout, ScatterNonDuplicated,
813 Contribution, OverrideContribution>
815 return ScatterAccess<DataType, Op, DeviceType, Layout, ScatterNonDuplicated,
816 Contribution, OverrideContribution>(*this);
819 original_view_type subview()
const {
return internal_view; }
821 KOKKOS_INLINE_FUNCTION constexpr
bool is_allocated()
const {
822 return internal_view.is_allocated();
825 template <
typename DT,
typename... RP>
826 void contribute_into(View<DT, RP...>
const& dest)
const {
827 contribute_into(execution_space(), dest);
830 template <
typename DT,
typename... RP>
831 void contribute_into(execution_space
const& exec_space,
832 View<DT, RP...>
const& dest)
const {
833 using dest_type =
View<DT, RP...>;
834 static_assert(std::is_same<typename dest_type::array_layout, Layout>::value,
835 "ScatterView contribute destination has different layout");
838 execution_space,
typename dest_type::memory_space>::accessible,
839 "ScatterView contribute destination memory space not accessible");
840 if (dest.data() == internal_view.data())
return;
841 Kokkos::Impl::Experimental::ReduceDuplicates<execution_space,
842 original_value_type, Op>(
843 exec_space, internal_view.data(), dest.data(), 0, 0, 1,
844 internal_view.label());
847 void reset(execution_space
const& exec_space = execution_space()) {
848 Kokkos::Impl::Experimental::ResetDuplicates<execution_space,
849 original_value_type, Op>(
850 exec_space, internal_view.data(), internal_view.size(),
851 internal_view.label());
853 template <
typename DT,
typename... RP>
854 void reset_except(View<DT, RP...>
const& view) {
855 reset_except(execution_space(), view);
858 template <
typename DT,
typename... RP>
859 void reset_except(
const execution_space& exec_space,
860 View<DT, RP...>
const& view) {
861 if (view.data() != internal_view.data()) reset(exec_space);
864 void resize(
const size_t n0 = 0,
const size_t n1 = 0,
const size_t n2 = 0,
865 const size_t n3 = 0,
const size_t n4 = 0,
const size_t n5 = 0,
866 const size_t n6 = 0,
const size_t n7 = 0) {
867 ::Kokkos::resize(internal_view, n0, n1, n2, n3, n4, n5, n6, n7);
870 void realloc(
const size_t n0 = 0,
const size_t n1 = 0,
const size_t n2 = 0,
871 const size_t n3 = 0,
const size_t n4 = 0,
const size_t n5 = 0,
872 const size_t n6 = 0,
const size_t n7 = 0) {
873 ::Kokkos::realloc(internal_view, n0, n1, n2, n3, n4, n5, n6, n7);
877 template <
typename... Args>
878 KOKKOS_FORCEINLINE_FUNCTION original_reference_type at(Args... args)
const {
879 return internal_view(args...);
883 using internal_view_type = original_view_type;
884 internal_view_type internal_view;
887 template <
typename DataType,
typename Op,
typename DeviceType,
typename Layout,
888 typename Contribution,
typename OverrideContribution>
889 class ScatterAccess<DataType, Op, DeviceType, Layout, ScatterNonDuplicated,
890 Contribution, OverrideContribution> {
892 using view_type = ScatterView<DataType, Layout, DeviceType, Op,
893 ScatterNonDuplicated, Contribution>;
894 using original_value_type =
typename view_type::original_value_type;
895 using value_type = Kokkos::Impl::Experimental::ScatterValue<
896 original_value_type, Op, DeviceType, OverrideContribution>;
898 KOKKOS_INLINE_FUNCTION
899 ScatterAccess() : view(view_type()) {}
901 KOKKOS_INLINE_FUNCTION
902 ScatterAccess(view_type
const& view_in) : view(view_in) {}
903 KOKKOS_DEFAULTED_FUNCTION
904 ~ScatterAccess() =
default;
906 template <
typename... Args>
907 KOKKOS_FORCEINLINE_FUNCTION value_type operator()(Args... args)
const {
908 return view.at(args...);
911 template <
typename Arg>
912 KOKKOS_FORCEINLINE_FUNCTION
913 typename std::enable_if<view_type::original_view_type::rank == 1 &&
914 std::is_integral<Arg>::value,
916 operator[](Arg arg)
const {
921 view_type
const& view;
928 template <
typename DataType,
typename Op,
typename DeviceType,
929 typename Contribution>
930 class ScatterView<DataType,
Kokkos::LayoutRight, DeviceType, Op,
931 ScatterDuplicated, Contribution> {
933 using execution_space =
typename DeviceType::execution_space;
934 using memory_space =
typename DeviceType::memory_space;
935 using device_type = Kokkos::Device<execution_space, memory_space>;
936 using original_view_type =
938 using original_value_type =
typename original_view_type::value_type;
939 using original_reference_type =
typename original_view_type::reference_type;
940 friend class ScatterAccess<DataType, Op, DeviceType,
Kokkos::LayoutRight,
941 ScatterDuplicated, Contribution, ScatterNonAtomic>;
942 friend class ScatterAccess<DataType, Op, DeviceType, Kokkos::LayoutRight,
943 ScatterDuplicated, Contribution, ScatterAtomic>;
944 template <class, class, class, class, class, class>
945 friend class ScatterView;
947 using data_type_info =
948 typename Kokkos::Impl::Experimental::DuplicatedDataType<
949 DataType, Kokkos::LayoutRight>;
950 using internal_data_type = typename data_type_info::value_type;
951 using internal_view_type =
952 Kokkos::View<internal_data_type, Kokkos::LayoutRight, device_type>;
954 ScatterView() = default;
956 template <typename OtherDataType, typename OtherDeviceType>
957 KOKKOS_FUNCTION ScatterView(
958 const ScatterView<OtherDataType, Kokkos::LayoutRight, OtherDeviceType, Op,
959 ScatterDuplicated, Contribution>& other_view)
960 : unique_token(other_view.unique_token),
961 internal_view(other_view.internal_view) {}
963 template <
typename OtherDataType,
typename OtherDeviceType>
964 KOKKOS_FUNCTION
void operator=(
966 ScatterDuplicated, Contribution>& other_view) {
967 unique_token = other_view.unique_token;
968 internal_view = other_view.internal_view;
971 template <
typename RT,
typename... RP>
972 ScatterView(View<RT, RP...>
const& original_view)
973 : ScatterView(execution_space(), original_view) {}
975 template <
typename RT,
typename... P,
typename... RP>
976 ScatterView(execution_space
const& exec_space,
977 View<RT, RP...>
const& original_view)
980 view_alloc(WithoutInitializing,
981 std::string(
"duplicated_") + original_view.label(),
984 original_view.rank_dynamic > 0 ? original_view.extent(0)
985 : KOKKOS_IMPL_CTOR_DEFAULT_ARG,
986 original_view.rank_dynamic > 1 ? original_view.extent(1)
987 : KOKKOS_IMPL_CTOR_DEFAULT_ARG,
988 original_view.rank_dynamic > 2 ? original_view.extent(2)
989 : KOKKOS_IMPL_CTOR_DEFAULT_ARG,
990 original_view.rank_dynamic > 3 ? original_view.extent(3)
991 : KOKKOS_IMPL_CTOR_DEFAULT_ARG,
992 original_view.rank_dynamic > 4 ? original_view.extent(4)
993 : KOKKOS_IMPL_CTOR_DEFAULT_ARG,
994 original_view.rank_dynamic > 5 ? original_view.extent(5)
995 : KOKKOS_IMPL_CTOR_DEFAULT_ARG,
996 original_view.rank_dynamic > 6 ? original_view.extent(6)
997 : KOKKOS_IMPL_CTOR_DEFAULT_ARG)
1003 template <
typename... Dims>
1004 ScatterView(std::string
const& name, Dims... dims)
1005 : ScatterView(view_alloc(execution_space(), name), dims...) {}
1010 template <
typename... P,
typename... Dims>
1011 ScatterView(::Kokkos::Impl::ViewCtorProp<P...>
const& arg_prop, Dims... dims)
1012 : internal_view(view_alloc(WithoutInitializing,
1013 static_cast<::
Kokkos::Impl::ViewCtorProp<
1014 void, std::string> const&>(arg_prop)
1016 unique_token.size(), dims...) {
1017 using ::Kokkos::Impl::Experimental::
1018 check_scatter_view_allocation_properties_argument;
1019 check_scatter_view_allocation_properties_argument(arg_prop);
1021 auto const exec_space =
1022 static_cast<::Kokkos::Impl::ViewCtorProp<void, execution_space> const&
>(
1028 template <
typename Overr
ideContribution = Contribution>
1029 KOKKOS_FORCEINLINE_FUNCTION
1031 ScatterDuplicated, Contribution, OverrideContribution>
1034 ScatterDuplicated, Contribution, OverrideContribution>(
1039 internal_view_type::rank,
1040 internal_view_type>::value_type
1042 return Kokkos::Impl::Experimental::Slice<
1044 internal_view_type>::get(internal_view, 0);
1047 KOKKOS_INLINE_FUNCTION constexpr
bool is_allocated()
const {
1048 return internal_view.is_allocated();
1051 template <
typename DT,
typename... RP>
1052 void contribute_into(View<DT, RP...>
const& dest)
const {
1053 contribute_into(execution_space(), dest);
1056 template <
typename DT,
typename... RP>
1057 void contribute_into(execution_space
const& exec_space,
1058 View<DT, RP...>
const& dest)
const {
1059 using dest_type =
View<DT, RP...>;
1060 static_assert(std::is_same<
typename dest_type::array_layout,
1062 "ScatterView deep_copy destination has different layout");
1065 execution_space,
typename dest_type::memory_space>::accessible,
1066 "ScatterView deep_copy destination memory space not accessible");
1067 bool is_equal = (dest.data() == internal_view.data());
1068 size_t start = is_equal ? 1 : 0;
1069 Kokkos::Impl::Experimental::ReduceDuplicates<execution_space,
1070 original_value_type, Op>(
1071 exec_space, internal_view.data(), dest.data(), internal_view.stride(0),
1072 start, internal_view.extent(0), internal_view.label());
1075 void reset(execution_space
const& exec_space = execution_space()) {
1076 Kokkos::Impl::Experimental::ResetDuplicates<execution_space,
1077 original_value_type, Op>(
1078 exec_space, internal_view.data(), internal_view.size(),
1079 internal_view.label());
1082 template <
typename DT,
typename... RP>
1083 void reset_except(View<DT, RP...>
const& view) {
1084 reset_except(execution_space(), view);
1087 template <
typename DT,
typename... RP>
1088 void reset_except(execution_space
const& exec_space,
1089 View<DT, RP...>
const& view) {
1090 if (view.data() != internal_view.data()) {
1094 Kokkos::Impl::Experimental::ResetDuplicates<execution_space,
1095 original_value_type, Op>(
1096 exec_space, internal_view.data() + view.size(),
1097 internal_view.size() - view.size(), internal_view.label());
1100 void resize(
const size_t n0 = 0,
const size_t n1 = 0,
const size_t n2 = 0,
1101 const size_t n3 = 0,
const size_t n4 = 0,
const size_t n5 = 0,
1102 const size_t n6 = 0) {
1103 ::Kokkos::resize(internal_view, unique_token.size(), n0, n1, n2, n3, n4, n5,
1107 void realloc(
const size_t n0 = 0,
const size_t n1 = 0,
const size_t n2 = 0,
1108 const size_t n3 = 0,
const size_t n4 = 0,
const size_t n5 = 0,
1109 const size_t n6 = 0) {
1110 ::Kokkos::realloc(internal_view, unique_token.size(), n0, n1, n2, n3, n4,
1115 template <
typename... Args>
1116 KOKKOS_FORCEINLINE_FUNCTION original_reference_type at(
int rank,
1117 Args... args)
const {
1118 return internal_view(rank, args...);
1123 execution_space, Kokkos::Experimental::UniqueTokenScope::Global>;
1125 unique_token_type unique_token;
1126 internal_view_type internal_view;
1129 template <
typename DataType,
typename Op,
typename DeviceType,
1130 typename Contribution>
1131 class ScatterView<DataType,
Kokkos::LayoutLeft, DeviceType, Op,
1132 ScatterDuplicated, Contribution> {
1134 using execution_space =
typename DeviceType::execution_space;
1135 using memory_space =
typename DeviceType::memory_space;
1136 using device_type = Kokkos::Device<execution_space, memory_space>;
1137 using original_view_type =
1139 using original_value_type =
typename original_view_type::value_type;
1140 using original_reference_type =
typename original_view_type::reference_type;
1141 friend class ScatterAccess<DataType, Op, DeviceType,
Kokkos::LayoutLeft,
1142 ScatterDuplicated, Contribution, ScatterNonAtomic>;
1143 friend class ScatterAccess<DataType, Op, DeviceType, Kokkos::LayoutLeft,
1144 ScatterDuplicated, Contribution, ScatterAtomic>;
1145 template <class, class, class, class, class, class>
1146 friend class ScatterView;
1148 using data_type_info =
1149 typename Kokkos::Impl::Experimental::DuplicatedDataType<
1150 DataType, Kokkos::LayoutLeft>;
1151 using internal_data_type = typename data_type_info::value_type;
1152 using internal_view_type =
1153 Kokkos::View<internal_data_type, Kokkos::LayoutLeft, device_type>;
1155 ScatterView() = default;
1157 template <typename RT, typename... RP>
1158 ScatterView(View<RT, RP...> const& original_view)
1159 : ScatterView(execution_space(), original_view) {}
1161 template <
typename RT,
typename... P,
typename... RP>
1162 ScatterView(execution_space
const& exec_space,
1163 View<RT, RP...>
const& original_view)
1165 size_t arg_N[8] = {original_view.rank > 0 ? original_view.extent(0)
1166 : KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1167 original_view.rank > 1 ? original_view.extent(1)
1168 : KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1169 original_view.rank > 2 ? original_view.extent(2)
1170 : KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1171 original_view.rank > 3 ? original_view.extent(3)
1172 : KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1173 original_view.rank > 4 ? original_view.extent(4)
1174 : KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1175 original_view.rank > 5 ? original_view.extent(5)
1176 : KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1177 original_view.rank > 6 ? original_view.extent(6)
1178 : KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1179 KOKKOS_IMPL_CTOR_DEFAULT_ARG};
1180 arg_N[internal_view_type::rank - 1] = unique_token.size();
1181 internal_view = internal_view_type(
1182 view_alloc(WithoutInitializing,
1183 std::string(
"duplicated_") + original_view.label(),
1185 arg_N[0], arg_N[1], arg_N[2], arg_N[3], arg_N[4], arg_N[5], arg_N[6],
1190 template <
typename... Dims>
1191 ScatterView(std::string
const& name, Dims... dims)
1192 : ScatterView(view_alloc(execution_space(), name), dims...) {}
1197 template <
typename... P,
typename... Dims>
1198 ScatterView(::Kokkos::Impl::ViewCtorProp<P...>
const& arg_prop,
1200 using ::Kokkos::Impl::Experimental::
1201 check_scatter_view_allocation_properties_argument;
1202 check_scatter_view_allocation_properties_argument(arg_prop);
1204 original_view_type original_view;
1205 size_t arg_N[8] = {original_view.rank > 0 ? original_view.static_extent(0)
1206 : KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1207 original_view.rank > 1 ? original_view.static_extent(1)
1208 : KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1209 original_view.rank > 2 ? original_view.static_extent(2)
1210 : KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1211 original_view.rank > 3 ? original_view.static_extent(3)
1212 : KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1213 original_view.rank > 4 ? original_view.static_extent(4)
1214 : KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1215 original_view.rank > 5 ? original_view.static_extent(5)
1216 : KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1217 original_view.rank > 6 ? original_view.static_extent(6)
1218 : KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1219 KOKKOS_IMPL_CTOR_DEFAULT_ARG};
1220 Kokkos::Impl::Experimental::args_to_array(arg_N, 0, dims...);
1221 arg_N[internal_view_type::rank - 1] = unique_token.size();
1224 static_cast<::Kokkos::Impl::ViewCtorProp<void, std::string> const&
>(
1227 internal_view = internal_view_type(view_alloc(WithoutInitializing, name),
1228 arg_N[0], arg_N[1], arg_N[2], arg_N[3],
1229 arg_N[4], arg_N[5], arg_N[6], arg_N[7]);
1231 auto const exec_space =
1232 static_cast<::Kokkos::Impl::ViewCtorProp<void, execution_space> const&
>(
1238 template <
typename OtherDataType,
typename OtherDeviceType>
1239 KOKKOS_FUNCTION ScatterView(
1241 ScatterDuplicated, Contribution>& other_view)
1242 : unique_token(other_view.unique_token),
1243 internal_view(other_view.internal_view) {}
1245 template <
typename OtherDataType,
typename OtherDeviceType>
1246 KOKKOS_FUNCTION
void operator=(
1248 ScatterDuplicated, Contribution>& other_view) {
1249 unique_token = other_view.unique_token;
1250 internal_view = other_view.internal_view;
1253 template <
typename Overr
ideContribution = Contribution>
1254 KOKKOS_FORCEINLINE_FUNCTION
1256 ScatterDuplicated, Contribution, OverrideContribution>
1259 ScatterDuplicated, Contribution, OverrideContribution>(
1264 internal_view_type::rank,
1265 internal_view_type>::value_type
1267 return Kokkos::Impl::Experimental::Slice<
1269 internal_view_type>::get(internal_view, 0);
1272 KOKKOS_INLINE_FUNCTION constexpr
bool is_allocated()
const {
1273 return internal_view.is_allocated();
1276 template <
typename... RP>
1277 void contribute_into(View<RP...>
const& dest)
const {
1278 contribute_into(execution_space(), dest);
1281 template <
typename... RP>
1282 void contribute_into(execution_space
const& exec_space,
1283 View<RP...>
const& dest)
const {
1284 using dest_type =
View<RP...>;
1286 std::is_same<
typename dest_type::value_type,
1287 typename original_view_type::non_const_value_type>::value,
1288 "ScatterView deep_copy destination has wrong value_type");
1289 static_assert(std::is_same<
typename dest_type::array_layout,
1291 "ScatterView deep_copy destination has different layout");
1294 execution_space,
typename dest_type::memory_space>::accessible,
1295 "ScatterView deep_copy destination memory space not accessible");
1296 auto extent = internal_view.extent(internal_view_type::rank - 1);
1297 bool is_equal = (dest.data() == internal_view.data());
1298 size_t start = is_equal ? 1 : 0;
1299 Kokkos::Impl::Experimental::ReduceDuplicates<execution_space,
1300 original_value_type, Op>(
1301 exec_space, internal_view.data(), dest.data(),
1302 internal_view.stride(internal_view_type::rank - 1), start, extent,
1303 internal_view.label());
1306 void reset(execution_space
const& exec_space = execution_space()) {
1307 Kokkos::Impl::Experimental::ResetDuplicates<execution_space,
1308 original_value_type, Op>(
1309 exec_space, internal_view.data(), internal_view.size(),
1310 internal_view.label());
1313 template <
typename DT,
typename... RP>
1314 void reset_except(View<DT, RP...>
const& view) {
1315 reset_except(execution_space(), view);
1318 template <
typename DT,
typename... RP>
1319 void reset_except(execution_space
const& exec_space,
1320 View<DT, RP...>
const& view) {
1321 if (view.data() != internal_view.data()) {
1325 Kokkos::Impl::Experimental::ResetDuplicates<execution_space,
1326 original_value_type, Op>(
1327 exec_space, internal_view.data() + view.size(),
1328 internal_view.size() - view.size(), internal_view.label());
1331 void resize(
const size_t n0 = 0,
const size_t n1 = 0,
const size_t n2 = 0,
1332 const size_t n3 = 0,
const size_t n4 = 0,
const size_t n5 = 0,
1333 const size_t n6 = 0) {
1334 size_t arg_N[8] = {n0, n1, n2, n3, n4, n5, n6, 0};
1335 const int i = internal_view.rank - 1;
1336 arg_N[i] = unique_token.size();
1338 ::Kokkos::resize(internal_view, arg_N[0], arg_N[1], arg_N[2], arg_N[3],
1339 arg_N[4], arg_N[5], arg_N[6], arg_N[7]);
1342 void realloc(
const size_t n0 = 0,
const size_t n1 = 0,
const size_t n2 = 0,
1343 const size_t n3 = 0,
const size_t n4 = 0,
const size_t n5 = 0,
1344 const size_t n6 = 0) {
1345 size_t arg_N[8] = {n0, n1, n2, n3, n4, n5, n6, 0};
1346 const int i = internal_view.rank - 1;
1347 arg_N[i] = unique_token.size();
1349 ::Kokkos::realloc(internal_view, arg_N[0], arg_N[1], arg_N[2], arg_N[3],
1350 arg_N[4], arg_N[5], arg_N[6], arg_N[7]);
1354 template <
typename... Args>
1355 KOKKOS_FORCEINLINE_FUNCTION original_reference_type at(
int thread_id,
1356 Args... args)
const {
1357 return internal_view(args..., thread_id);
1362 execution_space, Kokkos::Experimental::UniqueTokenScope::Global>;
1364 unique_token_type unique_token;
1365 internal_view_type internal_view;
1378 template <
typename DataType,
typename Op,
typename DeviceType,
typename Layout,
1379 typename Contribution,
typename OverrideContribution>
1380 class ScatterAccess<DataType, Op, DeviceType, Layout, ScatterDuplicated,
1381 Contribution, OverrideContribution> {
1383 using view_type = ScatterView<DataType, Layout, DeviceType, Op,
1384 ScatterDuplicated, Contribution>;
1385 using original_value_type =
typename view_type::original_value_type;
1386 using value_type = Kokkos::Impl::Experimental::ScatterValue<
1387 original_value_type, Op, DeviceType, OverrideContribution>;
1389 KOKKOS_FORCEINLINE_FUNCTION
1390 ScatterAccess(view_type
const& view_in)
1391 : view(view_in), thread_id(view_in.unique_token.acquire()) {}
1393 KOKKOS_FORCEINLINE_FUNCTION
1395 if (thread_id != ~thread_id_type(0)) view.unique_token.release(thread_id);
1398 template <
typename... Args>
1399 KOKKOS_FORCEINLINE_FUNCTION value_type operator()(Args... args)
const {
1400 return view.at(thread_id, args...);
1403 template <
typename Arg>
1404 KOKKOS_FORCEINLINE_FUNCTION
1405 typename std::enable_if<view_type::original_view_type::rank == 1 &&
1406 std::is_integral<Arg>::value,
1408 operator[](Arg arg)
const {
1409 return view.at(thread_id, arg);
1413 view_type
const& view;
1416 ScatterAccess(ScatterAccess
const& other) =
delete;
1417 ScatterAccess& operator=(ScatterAccess
const& other) =
delete;
1418 ScatterAccess& operator=(ScatterAccess&& other) =
delete;
1424 KOKKOS_FORCEINLINE_FUNCTION
1425 ScatterAccess(ScatterAccess&& other)
1426 : view(other.view), thread_id(other.thread_id) {
1427 other.thread_id = ~thread_id_type(0);
1431 using unique_token_type =
typename view_type::unique_token_type;
1432 using thread_id_type =
typename unique_token_type::size_type;
1433 thread_id_type thread_id;
1436 template <
typename Op = Kokkos::Experimental::ScatterSum,
1437 typename Duplication = void,
typename Contribution = void,
1438 typename RT,
typename... RP>
1440 RT,
typename ViewTraits<RT, RP...>::array_layout,
1441 typename ViewTraits<RT, RP...>::device_type, Op,
1443 std::is_same<Duplication, void>::value,
1444 typename Kokkos::Impl::Experimental::DefaultDuplication<
1445 typename ViewTraits<RT, RP...>::execution_space>::type,
1448 std::is_same<Contribution, void>::value,
1449 typename Kokkos::Impl::Experimental::DefaultContribution<
1450 typename ViewTraits<RT, RP...>::execution_space,
1451 typename std::conditional_t<
1452 std::is_same<Duplication, void>::value,
1453 typename Kokkos::Impl::Experimental::DefaultDuplication<
1454 typename ViewTraits<RT, RP...>::execution_space>::type,
1455 Duplication>>::type,
1457 create_scatter_view(View<RT, RP...>
const& original_view) {
1458 return original_view;
1461 template <
typename Op,
typename RT,
typename... RP>
1463 RT,
typename ViewTraits<RT, RP...>::array_layout,
1464 typename ViewTraits<RT, RP...>::device_type, Op,
1465 typename Kokkos::Impl::Experimental::DefaultDuplication<
1466 typename ViewTraits<RT, RP...>::execution_space>::type,
1467 typename Kokkos::Impl::Experimental::DefaultContribution<
1468 typename ViewTraits<RT, RP...>::execution_space,
1469 typename Kokkos::Impl::Experimental::DefaultDuplication<
1470 typename ViewTraits<RT, RP...>::execution_space>::type>::type>
1471 create_scatter_view(Op, View<RT, RP...>
const& original_view) {
1472 return original_view;
1475 template <
typename Op,
typename Duplication,
typename Contribution,
typename RT,
1477 ScatterView<RT,
typename ViewTraits<RT, RP...>::array_layout,
1478 typename ViewTraits<RT, RP...>::device_type, Op, Duplication,
1480 create_scatter_view(Op, Duplication, Contribution,
1481 View<RT, RP...>
const& original_view) {
1482 return original_view;
1491 template <
typename DT1,
typename DT2,
typename LY,
typename ES,
typename OP,
1492 typename CT,
typename DP,
typename... VP>
1494 typename ES::execution_space
const& exec_space, View<DT1, VP...>& dest,
1495 Kokkos::Experimental::ScatterView<DT2, LY, ES, OP, CT, DP>
const& src) {
1496 src.contribute_into(exec_space, dest);
1499 template <
typename DT1,
typename DT2,
typename LY,
typename ES,
typename OP,
1500 typename CT,
typename DP,
typename... VP>
1502 View<DT1, VP...>& dest,
1503 Kokkos::Experimental::ScatterView<DT2, LY, ES, OP, CT, DP>
const& src) {
1504 using execution_space =
typename ES::execution_space;
1505 contribute(execution_space{}, dest, src);
1513 template <
typename DT,
typename LY,
typename ES,
typename OP,
typename CT,
1514 typename DP,
typename... IS>
1516 Kokkos::Experimental::ScatterView<DT, LY, ES, OP, CT, DP>& scatter_view,
1518 scatter_view.realloc(is...);
1521 template <
typename DT,
typename LY,
typename ES,
typename OP,
typename CT,
1522 typename DP,
typename... IS>
1524 Kokkos::Experimental::ScatterView<DT, LY, ES, OP, CT, DP>& scatter_view,
1526 scatter_view.resize(is...);
Memory layout tag indicating left-to-right (Fortran scheme) striding of multi-indices.
Can AccessSpace access MemorySpace ?
class to generate unique ids base on the required amount of concurrency
View to an array of data.
Memory layout tag indicating right-to-left (C or lexigraphical scheme) striding of multi-indices...
void parallel_for(const ExecPolicy &policy, const FunctorType &functor, const std::string &str="", typename std::enable_if< Kokkos::Impl::is_execution_policy< ExecPolicy >::value >::type *=nullptr)
Execute functor in parallel according to the execution policy.