17 #ifndef KOKKOS_OFFSETVIEW_HPP_
18 #define KOKKOS_OFFSETVIEW_HPP_
19 #ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
20 #define KOKKOS_IMPL_PUBLIC_INCLUDE
21 #define KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_OFFSETVIEW
24 #include <Kokkos_Core.hpp>
26 #include <Kokkos_View.hpp>
30 namespace Experimental {
34 template <
class DataType,
class... Properties>
38 struct is_offset_view :
public std::false_type {};
40 template <
class D,
class... P>
41 struct is_offset_view<OffsetView<D, P...>> :
public std::true_type {};
43 template <
class D,
class... P>
44 struct is_offset_view<const OffsetView<D, P...>> :
public std::true_type {};
47 inline constexpr
bool is_offset_view_v = is_offset_view<T>::value;
49 #define KOKKOS_INVALID_OFFSET int64_t(0x7FFFFFFFFFFFFFFFLL)
50 #define KOKKOS_INVALID_INDEX_RANGE \
51 { KOKKOS_INVALID_OFFSET, KOKKOS_INVALID_OFFSET }
53 template <typename iType, std::enable_if_t<std::is_integral<iType>::value &&
54 std::is_signed<iType>::value,
58 using index_list_type = std::initializer_list<int64_t>;
67 template <
class ViewType>
68 struct GetOffsetViewTypeFromViewType {
70 OffsetView<
typename ViewType::data_type,
typename ViewType::array_layout,
71 typename ViewType::device_type,
72 typename ViewType::memory_traits>;
75 template <
unsigned,
class MapType,
class BeginsType>
76 KOKKOS_INLINE_FUNCTION
bool offsetview_verify_operator_bounds(
77 const MapType&,
const BeginsType&) {
81 template <
unsigned R,
class MapType,
class BeginsType,
class iType,
83 KOKKOS_INLINE_FUNCTION
bool offsetview_verify_operator_bounds(
84 const MapType& map,
const BeginsType& begins,
const iType& i,
86 const bool legalIndex =
87 (int64_t(i) >= begins[R]) &&
88 (int64_t(i) <= int64_t(begins[R] + map.extent(R) - 1));
90 offsetview_verify_operator_bounds<R + 1>(map, begins, args...);
92 template <
unsigned,
class MapType,
class BeginsType>
93 inline void offsetview_error_operator_bounds(
char*,
int,
const MapType&,
96 template <
unsigned R,
class MapType,
class BeginsType,
class iType,
98 inline void offsetview_error_operator_bounds(
char* buf,
int len,
100 const BeginsType begins,
101 const iType& i, Args... args) {
102 const int64_t b = begins[R];
103 const int64_t e = b + map.extent(R) - 1;
105 snprintf(buf, len,
" %ld <= %ld <= %ld %c", static_cast<unsigned long>(b),
106 static_cast<unsigned long>(i), static_cast<unsigned long>(e),
107 (
sizeof...(Args) ?
',' :
')'));
108 offsetview_error_operator_bounds<R + 1>(buf + n, len - n, map, begins,
112 template <
class MemorySpace,
class MapType,
class BeginsType,
class... Args>
113 KOKKOS_INLINE_FUNCTION
void offsetview_verify_operator_bounds(
114 Kokkos::Impl::SharedAllocationTracker
const& tracker,
const MapType& map,
115 const BeginsType& begins, Args... args) {
116 if (!offsetview_verify_operator_bounds<0>(map, begins, args...)) {
118 (
enum {LEN = 1024};
char buffer[LEN];
119 const std::string label = tracker.template get_label<MemorySpace>();
120 int n = snprintf(buffer, LEN,
121 "OffsetView bounds error of view labeled %s (",
123 offsetview_error_operator_bounds<0>(buffer + n, LEN - n, map, begins,
125 Kokkos::Impl::throw_runtime_exception(std::string(buffer));))
128 (Kokkos::abort("OffsetView bounds error"); (
void)tracker;))
132 inline
void runtime_check_rank_host(const
size_t rank_dynamic,
134 const index_list_type minIndices,
135 const std::
string& label) {
137 std::string message =
138 "Kokkos::Experimental::OffsetView ERROR: for OffsetView labeled '" +
140 if (rank_dynamic != rank) {
142 "The full rank must be the same as the dynamic rank. full rank = ";
143 message += std::to_string(rank) +
144 " dynamic rank = " + std::to_string(rank_dynamic) +
"\n";
148 size_t numOffsets = 0;
149 for (
size_t i = 0; i < minIndices.size(); ++i) {
150 if (minIndices.begin()[i] != KOKKOS_INVALID_OFFSET) numOffsets++;
152 if (numOffsets != rank_dynamic) {
153 message +=
"The number of offsets provided ( " +
154 std::to_string(numOffsets) +
155 " ) must equal the dynamic rank ( " +
156 std::to_string(rank_dynamic) +
" ).";
160 if (isBad) Kokkos::abort(message.c_str());
163 KOKKOS_INLINE_FUNCTION
164 void runtime_check_rank_device(
const size_t rank_dynamic,
const size_t rank,
165 const index_list_type minIndices) {
166 if (rank_dynamic != rank) {
168 "The full rank of an OffsetView must be the same as the dynamic rank.");
170 size_t numOffsets = 0;
171 for (
size_t i = 0; i < minIndices.size(); ++i) {
172 if (minIndices.begin()[i] != KOKKOS_INVALID_OFFSET) numOffsets++;
174 if (numOffsets != rank) {
176 "The number of offsets provided to an OffsetView constructor must "
177 "equal the dynamic rank.");
182 template <
class DataType,
class... Properties>
183 class OffsetView :
public ViewTraits<DataType, Properties...> {
185 using traits = ViewTraits<DataType, Properties...>;
188 template <
class,
class...>
189 friend class OffsetView;
190 template <
class,
class...>
192 template <
class,
class...>
193 friend class Kokkos::Impl::ViewMapping;
195 using map_type = Kokkos::Impl::ViewMapping<traits, void>;
196 using track_type = Kokkos::Impl::SharedAllocationTracker;
199 enum { Rank = map_type::Rank };
202 template <
typename iType,
203 std::enable_if_t<std::is_integral<iType>::value, iType> = 0>
204 KOKKOS_FUNCTION int64_t begin(
const iType local_dimension)
const {
205 return local_dimension < Rank ? m_begins[local_dimension]
206 : KOKKOS_INVALID_OFFSET;
210 begins_type begins()
const {
return m_begins; }
212 template <
typename iType,
213 std::enable_if_t<std::is_integral<iType>::value, iType> = 0>
214 KOKKOS_FUNCTION int64_t end(
const iType local_dimension)
const {
215 return begin(local_dimension) + m_map.extent(local_dimension);
221 begins_type m_begins;
227 OffsetView<
typename traits::scalar_array_type,
228 typename traits::array_layout,
typename traits::device_type,
229 typename traits::memory_traits>;
233 OffsetView<
typename traits::const_data_type,
234 typename traits::array_layout,
typename traits::device_type,
235 typename traits::memory_traits>;
238 using non_const_type =
239 OffsetView<
typename traits::non_const_data_type,
240 typename traits::array_layout,
typename traits::device_type,
241 typename traits::memory_traits>;
244 using HostMirror = OffsetView<
typename traits::non_const_data_type,
245 typename traits::array_layout,
246 typename traits::host_mirror_space>;
257 template <
typename iType>
258 KOKKOS_FUNCTION constexpr std::enable_if_t<std::is_integral<iType>::value,
260 extent(
const iType& r)
const {
261 return m_map.extent(r);
264 template <
typename iType>
265 KOKKOS_FUNCTION constexpr std::enable_if_t<std::is_integral<iType>::value,
267 extent_int(
const iType& r)
const {
268 return static_cast<int>(m_map.extent(r));
271 KOKKOS_FUNCTION constexpr
typename traits::array_layout layout()
const {
272 return m_map.layout();
275 KOKKOS_FUNCTION constexpr
size_t size()
const {
276 return m_map.dimension_0() * m_map.dimension_1() * m_map.dimension_2() *
277 m_map.dimension_3() * m_map.dimension_4() * m_map.dimension_5() *
278 m_map.dimension_6() * m_map.dimension_7();
281 KOKKOS_FUNCTION constexpr
size_t stride_0()
const {
return m_map.stride_0(); }
282 KOKKOS_FUNCTION constexpr
size_t stride_1()
const {
return m_map.stride_1(); }
283 KOKKOS_FUNCTION constexpr
size_t stride_2()
const {
return m_map.stride_2(); }
284 KOKKOS_FUNCTION constexpr
size_t stride_3()
const {
return m_map.stride_3(); }
285 KOKKOS_FUNCTION constexpr
size_t stride_4()
const {
return m_map.stride_4(); }
286 KOKKOS_FUNCTION constexpr
size_t stride_5()
const {
return m_map.stride_5(); }
287 KOKKOS_FUNCTION constexpr
size_t stride_6()
const {
return m_map.stride_6(); }
288 KOKKOS_FUNCTION constexpr
size_t stride_7()
const {
return m_map.stride_7(); }
290 template <
typename iType>
291 KOKKOS_FUNCTION constexpr std::enable_if_t<std::is_integral<iType>::value,
293 stride(iType r)
const {
309 : m_map.stride_7())))))));
312 template <
typename iType>
313 KOKKOS_FUNCTION
void stride(iType*
const s)
const {
320 using reference_type =
typename map_type::reference_type;
321 using pointer_type =
typename map_type::pointer_type;
324 reference_type_is_lvalue_reference =
325 std::is_lvalue_reference<reference_type>::value
328 KOKKOS_FUNCTION constexpr
size_t span()
const {
return m_map.span(); }
329 KOKKOS_FUNCTION
bool span_is_contiguous()
const {
330 return m_map.span_is_contiguous();
332 KOKKOS_FUNCTION constexpr
bool is_allocated()
const {
333 return m_map.data() !=
nullptr;
335 KOKKOS_FUNCTION constexpr pointer_type data()
const {
return m_map.data(); }
341 const Kokkos::Impl::ViewMapping<traits, void>& implementation_map()
const {
348 static constexpr
bool is_layout_left =
349 std::is_same<typename traits::array_layout, Kokkos::LayoutLeft>::value;
351 static constexpr
bool is_layout_right =
352 std::is_same<typename traits::array_layout, Kokkos::LayoutRight>::value;
354 static constexpr
bool is_layout_stride =
355 std::is_same<typename traits::array_layout, Kokkos::LayoutStride>::value;
357 static constexpr
bool is_default_map =
358 std::is_void<typename traits::specialize>::value &&
359 (is_layout_left || is_layout_right || is_layout_stride);
361 #if defined(KOKKOS_ENABLE_DEBUG_BOUNDS_CHECK)
363 #define KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY(ARG) \
364 Kokkos::Impl::runtime_check_memory_access_violation< \
365 typename traits::memory_space>( \
366 "Kokkos::OffsetView ERROR: attempt to access inaccessible memory " \
368 Kokkos::Experimental::Impl::offsetview_verify_operator_bounds< \
369 typename traits::memory_space> \
374 #define KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY(ARG) \
375 Kokkos::Impl::runtime_check_memory_access_violation< \
376 typename traits::memory_space>( \
377 "Kokkos::OffsetView ERROR: attempt to access inaccessible memory " \
385 KOKKOS_FORCEINLINE_FUNCTION
386 reference_type operator()()
const {
return m_map.reference(); }
390 template <
typename I0>
391 KOKKOS_FORCEINLINE_FUNCTION std::enable_if_t<
392 (Kokkos::Impl::are_integral<I0>::value && (1 == Rank) && !is_default_map),
394 operator()(
const I0& i0)
const {
395 KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY((m_track, m_map, m_begins, i0))
396 const
size_t j0 = i0 - m_begins[0];
397 return m_map.reference(j0);
400 template <typename I0>
401 KOKKOS_FORCEINLINE_FUNCTION
402 std::enable_if_t<(Kokkos::Impl::are_integral<I0>::value && (1 == Rank) &&
403 is_default_map && !is_layout_stride),
405 operator()(const I0& i0)
const {
406 KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY((m_track, m_map, m_begins, i0))
407 const
size_t j0 = i0 - m_begins[0];
408 return m_map.m_impl_handle[j0];
411 template <typename I0>
412 KOKKOS_FORCEINLINE_FUNCTION
413 std::enable_if_t<(Kokkos::Impl::are_integral<I0>::value && (1 == Rank) &&
414 is_default_map && is_layout_stride),
416 operator()(const I0& i0)
const {
417 KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY((m_track, m_map, m_begins, i0))
418 const
size_t j0 = i0 - m_begins[0];
419 return m_map.m_impl_handle[m_map.m_impl_offset.m_stride.S0 * j0];
424 template <typename I0>
425 KOKKOS_FORCEINLINE_FUNCTION std::enable_if_t<
426 (Kokkos::Impl::are_integral<I0>::value && (1 == Rank) && !is_default_map),
428 operator[](const I0& i0)
const {
429 KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY((m_track, m_map, m_begins, i0))
430 const
size_t j0 = i0 - m_begins[0];
431 return m_map.reference(j0);
434 template <typename I0>
435 KOKKOS_FORCEINLINE_FUNCTION
436 std::enable_if_t<(Kokkos::Impl::are_integral<I0>::value && (1 == Rank) &&
437 is_default_map && !is_layout_stride),
439 operator[](const I0& i0)
const {
440 KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY((m_track, m_map, m_begins, i0))
441 const
size_t j0 = i0 - m_begins[0];
442 return m_map.m_impl_handle[j0];
445 template <typename I0>
446 KOKKOS_FORCEINLINE_FUNCTION
447 std::enable_if_t<(Kokkos::Impl::are_integral<I0>::value && (1 == Rank) &&
448 is_default_map && is_layout_stride),
450 operator[](const I0& i0)
const {
451 KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY((m_track, m_map, m_begins, i0))
452 const
size_t j0 = i0 - m_begins[0];
453 return m_map.m_impl_handle[m_map.m_impl_offset.m_stride.S0 * j0];
459 template <typename I0, typename I1>
460 KOKKOS_FORCEINLINE_FUNCTION
461 std::enable_if_t<(Kokkos::Impl::are_integral<I0, I1>::value &&
462 (2 == Rank) && !is_default_map),
464 operator()(const I0& i0, const I1& i1)
const {
465 KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY((m_track, m_map, m_begins, i0, i1))
466 const
size_t j0 = i0 - m_begins[0];
467 const
size_t j1 = i1 - m_begins[1];
468 return m_map.reference(j0, j1);
471 template <typename I0, typename I1>
472 KOKKOS_FORCEINLINE_FUNCTION std::enable_if_t<
473 (Kokkos::Impl::are_integral<I0, I1>::value && (2 == Rank) &&
475 (is_layout_left || is_layout_right || is_layout_stride)),
477 operator()(const I0& i0, const I1& i1)
const {
478 KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY((m_track, m_map, m_begins, i0, i1))
479 const
size_t j0 = i0 - m_begins[0];
480 const
size_t j1 = i1 - m_begins[1];
481 if constexpr (is_layout_left) {
482 if constexpr (traits::rank_dynamic == 0)
483 return m_map.m_impl_handle[j0 + m_map.m_impl_offset.m_dim.N0 * j1];
485 return m_map.m_impl_handle[j0 + m_map.m_impl_offset.m_stride * j1];
486 } else if constexpr (is_layout_right) {
487 if constexpr (traits::rank_dynamic == 0)
488 return m_map.m_impl_handle[j1 + m_map.m_impl_offset.m_dim.N1 * j0];
490 return m_map.m_impl_handle[j1 + m_map.m_impl_offset.m_stride * j0];
492 static_assert(is_layout_stride);
493 return m_map.m_impl_handle[j0 * m_map.m_impl_offset.m_stride.S0 +
494 j1 * m_map.m_impl_offset.m_stride.S1];
496 #if defined(KOKKOS_COMPILER_INTEL)
497 __builtin_unreachable();
504 template <
typename I0,
typename I1,
typename I2>
505 KOKKOS_FORCEINLINE_FUNCTION
506 std::enable_if_t<(Kokkos::Impl::are_integral<I0, I1, I2>::value &&
507 (3 == Rank) && is_default_map),
509 operator()(
const I0& i0,
const I1& i1,
const I2& i2)
const {
510 KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY(
511 (m_track, m_map, m_begins, i0, i1, i2))
512 const
size_t j0 = i0 - m_begins[0];
513 const
size_t j1 = i1 - m_begins[1];
514 const
size_t j2 = i2 - m_begins[2];
515 return m_map.m_impl_handle[m_map.m_impl_offset(j0, j1, j2)];
518 template <typename I0, typename I1, typename I2>
519 KOKKOS_FORCEINLINE_FUNCTION
520 std::enable_if_t<(Kokkos::Impl::are_integral<I0, I1, I2>::value &&
521 (3 == Rank) && !is_default_map),
523 operator()(const I0& i0, const I1& i1, const I2& i2)
const {
524 KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY(
525 (m_track, m_map, m_begins, i0, i1, i2))
526 const
size_t j0 = i0 - m_begins[0];
527 const
size_t j1 = i1 - m_begins[1];
528 const
size_t j2 = i2 - m_begins[2];
529 return m_map.reference(j0, j1, j2);
535 template <typename I0, typename I1, typename I2, typename I3>
536 KOKKOS_FORCEINLINE_FUNCTION
537 std::enable_if_t<(Kokkos::Impl::are_integral<I0, I1, I2, I3>::value &&
538 (4 == Rank) && is_default_map),
540 operator()(const I0& i0, const I1& i1, const I2& i2, const I3& i3)
const {
541 KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY(
542 (m_track, m_map, m_begins, i0, i1, i2, i3))
543 const
size_t j0 = i0 - m_begins[0];
544 const
size_t j1 = i1 - m_begins[1];
545 const
size_t j2 = i2 - m_begins[2];
546 const
size_t j3 = i3 - m_begins[3];
547 return m_map.m_impl_handle[m_map.m_impl_offset(j0, j1, j2, j3)];
550 template <typename I0, typename I1, typename I2, typename I3>
551 KOKKOS_FORCEINLINE_FUNCTION
552 std::enable_if_t<(Kokkos::Impl::are_integral<I0, I1, I2, I3>::value &&
553 (4 == Rank) && !is_default_map),
555 operator()(const I0& i0, const I1& i1, const I2& i2, const I3& i3)
const {
556 KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY(
557 (m_track, m_map, m_begins, i0, i1, i2, i3))
558 const
size_t j0 = i0 - m_begins[0];
559 const
size_t j1 = i1 - m_begins[1];
560 const
size_t j2 = i2 - m_begins[2];
561 const
size_t j3 = i3 - m_begins[3];
562 return m_map.reference(j0, j1, j2, j3);
568 template <typename I0, typename I1, typename I2, typename I3, typename I4>
569 KOKKOS_FORCEINLINE_FUNCTION
570 std::enable_if_t<(Kokkos::Impl::are_integral<I0, I1, I2, I3, I4>::value &&
571 (5 == Rank) && is_default_map),
573 operator()(const I0& i0, const I1& i1, const I2& i2, const I3& i3,
574 const I4& i4)
const {
575 KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY(
576 (m_track, m_map, m_begins, i0, i1, i2, i3, i4))
577 const
size_t j0 = i0 - m_begins[0];
578 const
size_t j1 = i1 - m_begins[1];
579 const
size_t j2 = i2 - m_begins[2];
580 const
size_t j3 = i3 - m_begins[3];
581 const
size_t j4 = i4 - m_begins[4];
582 return m_map.m_impl_handle[m_map.m_impl_offset(j0, j1, j2, j3, j4)];
585 template <typename I0, typename I1, typename I2, typename I3, typename I4>
586 KOKKOS_FORCEINLINE_FUNCTION
587 std::enable_if_t<(Kokkos::Impl::are_integral<I0, I1, I2, I3, I4>::value &&
588 (5 == Rank) && !is_default_map),
590 operator()(const I0& i0, const I1& i1, const I2& i2, const I3& i3,
591 const I4& i4)
const {
592 KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY(
593 (m_track, m_map, m_begins, i0, i1, i2, i3, i4))
594 const
size_t j0 = i0 - m_begins[0];
595 const
size_t j1 = i1 - m_begins[1];
596 const
size_t j2 = i2 - m_begins[2];
597 const
size_t j3 = i3 - m_begins[3];
598 const
size_t j4 = i4 - m_begins[4];
599 return m_map.reference(j0, j1, j2, j3, j4);
605 template <typename I0, typename I1, typename I2, typename I3, typename I4,
607 KOKKOS_FORCEINLINE_FUNCTION std::enable_if_t<
608 (Kokkos::Impl::are_integral<I0, I1, I2, I3, I4, I5>::value &&
609 (6 == Rank) && is_default_map),
611 operator()(const I0& i0, const I1& i1, const I2& i2, const I3& i3,
612 const I4& i4, const I5& i5)
const {
613 KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY(
614 (m_track, m_map, m_begins, i0, i1, i2, i3, i4, i5))
615 const
size_t j0 = i0 - m_begins[0];
616 const
size_t j1 = i1 - m_begins[1];
617 const
size_t j2 = i2 - m_begins[2];
618 const
size_t j3 = i3 - m_begins[3];
619 const
size_t j4 = i4 - m_begins[4];
620 const
size_t j5 = i5 - m_begins[5];
621 return m_map.m_impl_handle[m_map.m_impl_offset(j0, j1, j2, j3, j4, j5)];
624 template <typename I0, typename I1, typename I2, typename I3, typename I4,
626 KOKKOS_FORCEINLINE_FUNCTION std::enable_if_t<
627 (Kokkos::Impl::are_integral<I0, I1, I2, I3, I4, I5>::value &&
628 (6 == Rank) && !is_default_map),
630 operator()(const I0& i0, const I1& i1, const I2& i2, const I3& i3,
631 const I4& i4, const I5& i5)
const {
632 KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY(
633 (m_track, m_map, m_begins, i0, i1, i2, i3, i4, i5))
634 const
size_t j0 = i0 - m_begins[0];
635 const
size_t j1 = i1 - m_begins[1];
636 const
size_t j2 = i2 - m_begins[2];
637 const
size_t j3 = i3 - m_begins[3];
638 const
size_t j4 = i4 - m_begins[4];
639 const
size_t j5 = i5 - m_begins[5];
640 return m_map.reference(j0, j1, j2, j3, j4, j5);
646 template <typename I0, typename I1, typename I2, typename I3, typename I4,
647 typename I5, typename I6>
648 KOKKOS_FORCEINLINE_FUNCTION std::enable_if_t<
649 (Kokkos::Impl::are_integral<I0, I1, I2, I3, I4, I5, I6>::value &&
650 (7 == Rank) && is_default_map),
652 operator()(const I0& i0, const I1& i1, const I2& i2, const I3& i3,
653 const I4& i4, const I5& i5, const I6& i6)
const {
654 KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY(
655 (m_track, m_map, m_begins, i0, i1, i2, i3, i4, i5, i6))
656 const
size_t j0 = i0 - m_begins[0];
657 const
size_t j1 = i1 - m_begins[1];
658 const
size_t j2 = i2 - m_begins[2];
659 const
size_t j3 = i3 - m_begins[3];
660 const
size_t j4 = i4 - m_begins[4];
661 const
size_t j5 = i5 - m_begins[5];
662 const
size_t j6 = i6 - m_begins[6];
663 return m_map.m_impl_handle[m_map.m_impl_offset(j0, j1, j2, j3, j4, j5, j6)];
666 template <typename I0, typename I1, typename I2, typename I3, typename I4,
667 typename I5, typename I6>
668 KOKKOS_FORCEINLINE_FUNCTION std::enable_if_t<
669 (Kokkos::Impl::are_integral<I0, I1, I2, I3, I4, I5, I6>::value &&
670 (7 == Rank) && !is_default_map),
672 operator()(const I0& i0, const I1& i1, const I2& i2, const I3& i3,
673 const I4& i4, const I5& i5, const I6& i6)
const {
674 KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY(
675 (m_track, m_map, m_begins, i0, i1, i2, i3, i4, i5, i6))
676 const
size_t j0 = i0 - m_begins[0];
677 const
size_t j1 = i1 - m_begins[1];
678 const
size_t j2 = i2 - m_begins[2];
679 const
size_t j3 = i3 - m_begins[3];
680 const
size_t j4 = i4 - m_begins[4];
681 const
size_t j5 = i5 - m_begins[5];
682 const
size_t j6 = i6 - m_begins[6];
683 return m_map.reference(j0, j1, j2, j3, j4, j5, j6);
689 template <typename I0, typename I1, typename I2, typename I3, typename I4,
690 typename I5, typename I6, typename I7>
691 KOKKOS_FORCEINLINE_FUNCTION std::enable_if_t<
692 (Kokkos::Impl::are_integral<I0, I1, I2, I3, I4, I5, I6, I7>::value &&
693 (8 == Rank) && is_default_map),
695 operator()(const I0& i0, const I1& i1, const I2& i2, const I3& i3,
696 const I4& i4, const I5& i5, const I6& i6, const I7& i7)
const {
697 KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY(
698 (m_track, m_map, m_begins, i0, i1, i2, i3, i4, i5, i6, i7))
699 const
size_t j0 = i0 - m_begins[0];
700 const
size_t j1 = i1 - m_begins[1];
701 const
size_t j2 = i2 - m_begins[2];
702 const
size_t j3 = i3 - m_begins[3];
703 const
size_t j4 = i4 - m_begins[4];
704 const
size_t j5 = i5 - m_begins[5];
705 const
size_t j6 = i6 - m_begins[6];
706 const
size_t j7 = i7 - m_begins[7];
708 .m_impl_handle[m_map.m_impl_offset(j0, j1, j2, j3, j4, j5, j6, j7)];
711 template <typename I0, typename I1, typename I2, typename I3, typename I4,
712 typename I5, typename I6, typename I7>
713 KOKKOS_FORCEINLINE_FUNCTION std::enable_if_t<
714 (Kokkos::Impl::are_integral<I0, I1, I2, I3, I4, I5, I6, I7>::value &&
715 (8 == Rank) && !is_default_map),
717 operator()(const I0& i0, const I1& i1, const I2& i2, const I3& i3,
718 const I4& i4, const I5& i5, const I6& i6, const I7& i7)
const {
719 KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY(
720 (m_track, m_map, m_begins, i0, i1, i2, i3, i4, i5, i6, i7))
721 const
size_t j0 = i0 - m_begins[0];
722 const
size_t j1 = i1 - m_begins[1];
723 const
size_t j2 = i2 - m_begins[2];
724 const
size_t j3 = i3 - m_begins[3];
725 const
size_t j4 = i4 - m_begins[4];
726 const
size_t j5 = i5 - m_begins[5];
727 const
size_t j6 = i6 - m_begins[6];
728 const
size_t j7 = i7 - m_begins[7];
729 return m_map.reference(j0, j1, j2, j3, j4, j5, j6, j7);
732 #undef KOKKOS_IMPL_OFFSETVIEW_OPERATOR_VERIFY
737 KOKKOS_DEFAULTED_FUNCTION
738 ~OffsetView() =
default;
741 OffsetView() : m_track(), m_map() {
742 for (
size_t i = 0; i < Rank; ++i) m_begins[i] = KOKKOS_INVALID_OFFSET;
746 OffsetView(
const OffsetView& rhs)
747 : m_track(rhs.m_track, traits::is_managed),
749 m_begins(rhs.m_begins) {}
752 OffsetView(OffsetView&& rhs)
753 : m_track(std::move(rhs.m_track)),
754 m_map(std::move(rhs.m_map)),
755 m_begins(std::move(rhs.m_begins)) {}
758 OffsetView& operator=(
const OffsetView& rhs) {
759 m_track = rhs.m_track;
761 m_begins = rhs.m_begins;
766 OffsetView& operator=(OffsetView&& rhs) {
767 m_track = std::move(rhs.m_track);
768 m_map = std::move(rhs.m_map);
769 m_begins = std::move(rhs.m_begins);
776 View<
typename traits::scalar_array_type,
typename traits::array_layout,
777 typename traits::device_type,
typename traits::memory_traits>;
781 view_type view()
const {
782 view_type v(m_track, m_map);
786 template <
class RT,
class... RP>
787 KOKKOS_FUNCTION OffsetView(
const View<RT, RP...>& aview)
788 : m_track(aview.impl_track()), m_map() {
789 using SrcTraits =
typename OffsetView<RT, RP...>::traits;
790 using Mapping = Kokkos::Impl::ViewMapping<traits, SrcTraits, void>;
791 static_assert(Mapping::is_assignable,
792 "Incompatible OffsetView copy construction");
793 Mapping::assign(m_map, aview.impl_map(), m_track);
795 for (
size_t i = 0; i < View<RT, RP...>::rank(); ++i) {
800 template <
class RT,
class... RP>
801 KOKKOS_FUNCTION OffsetView(
const View<RT, RP...>& aview,
802 const index_list_type& minIndices)
803 : m_track(aview.impl_track()), m_map() {
804 using SrcTraits =
typename OffsetView<RT, RP...>::traits;
805 using Mapping = Kokkos::Impl::ViewMapping<traits, SrcTraits, void>;
806 static_assert(Mapping::is_assignable,
807 "Incompatible OffsetView copy construction");
808 Mapping::assign(m_map, aview.impl_map(), m_track);
810 KOKKOS_IF_ON_HOST((Kokkos::Experimental::Impl::runtime_check_rank_host(
811 traits::rank_dynamic, Rank, minIndices, label());))
813 KOKKOS_IF_ON_DEVICE((Kokkos::Experimental::Impl::runtime_check_rank_device(
814 traits::rank_dynamic, Rank, minIndices);))
816 for (
size_t i = 0; i < minIndices.size(); ++i) {
817 m_begins[i] = minIndices.begin()[i];
820 template <
class RT,
class... RP>
821 KOKKOS_FUNCTION OffsetView(
const View<RT, RP...>& aview,
822 const begins_type& beg)
823 : m_track(aview.impl_track()), m_map(), m_begins(beg) {
824 using SrcTraits =
typename OffsetView<RT, RP...>::traits;
825 using Mapping = Kokkos::Impl::ViewMapping<traits, SrcTraits, void>;
826 static_assert(Mapping::is_assignable,
827 "Incompatible OffsetView copy construction");
828 Mapping::assign(m_map, aview.impl_map(), m_track);
833 template <
class RT,
class... RP>
834 KOKKOS_FUNCTION OffsetView(
const OffsetView<RT, RP...>& rhs)
835 : m_track(rhs.m_track, traits::is_managed),
837 m_begins(rhs.m_begins) {
838 using SrcTraits =
typename OffsetView<RT, RP...>::traits;
839 using Mapping = Kokkos::Impl::ViewMapping<traits, SrcTraits, void>;
840 static_assert(Mapping::is_assignable,
841 "Incompatible OffsetView copy construction");
842 Mapping::assign(m_map, rhs.m_map, rhs.m_track);
846 enum class subtraction_failure {
853 KOKKOS_FUNCTION
static subtraction_failure check_subtraction(int64_t lhs,
855 if (lhs < rhs)
return subtraction_failure::negative;
857 if (static_cast<uint64_t>(-1) / static_cast<uint64_t>(2) <
858 static_cast<uint64_t>(lhs) - static_cast<uint64_t>(rhs))
859 return subtraction_failure::overflow;
861 return subtraction_failure::none;
869 static int64_t at(
const begins_type& a,
size_t pos) {
return a[pos]; }
872 static int64_t at(index_list_type a,
size_t pos) {
873 return *(a.begin() + pos);
878 template <
typename B,
typename E>
879 static subtraction_failure runtime_check_begins_ends_host(
const B& begins,
882 if (begins.size() != Rank)
886 std::to_string(begins.size()) +
890 std::to_string(Rank) +
894 if (ends.size() != Rank)
898 std::to_string(begins.size()) +
902 std::to_string(Rank) +
908 size_t arg_rank = begins.size() < ends.size() ? begins.size() : ends.size();
909 for (
size_t i = 0; i != arg_rank; ++i) {
910 subtraction_failure sf = check_subtraction(at(ends, i), at(begins, i));
911 if (sf != subtraction_failure::none) {
919 std::to_string(at(ends, i)) +
927 std::to_string(at(begins, i)) +
931 case subtraction_failure::negative:
932 message +=
" must be non-negative\n";
934 case subtraction_failure::overflow: message +=
" overflows\n";
break;
940 if (!message.empty()) {
942 "Kokkos::Experimental::OffsetView ERROR: for unmanaged OffsetView\n" +
944 Kokkos::Impl::throw_runtime_exception(message);
947 return subtraction_failure::none;
951 template <
typename B,
typename E>
952 KOKKOS_FUNCTION
static subtraction_failure runtime_check_begins_ends_device(
953 const B& begins,
const E& ends) {
954 if (begins.size() != Rank)
956 "Kokkos::Experimental::OffsetView ERROR: for unmanaged "
957 "OffsetView: begins has bad Rank");
958 if (ends.size() != Rank)
960 "Kokkos::Experimental::OffsetView ERROR: for unmanaged "
961 "OffsetView: ends has bad Rank");
963 for (
size_t i = 0; i != begins.size(); ++i) {
964 switch (check_subtraction(at(ends, i), at(begins, i))) {
965 case subtraction_failure::negative:
967 "Kokkos::Experimental::OffsetView ERROR: for unmanaged "
968 "OffsetView: bad range");
970 case subtraction_failure::overflow:
972 "Kokkos::Experimental::OffsetView ERROR: for unmanaged "
973 "OffsetView: range overflows");
979 return subtraction_failure::none;
982 template <
typename B,
typename E>
983 KOKKOS_FUNCTION
static subtraction_failure runtime_check_begins_ends(
984 const B& begins,
const E& ends) {
985 KOKKOS_IF_ON_HOST((
return runtime_check_begins_ends_host(begins, ends);))
987 (return runtime_check_begins_ends_device(begins, ends);))
994 template <typename B, typename E>
995 KOKKOS_FUNCTION OffsetView(const pointer_type& p, const B& begins_,
1000 m_map(Kokkos::Impl::ViewCtorProp<pointer_type>(p),
1001 typename traits::array_layout(
1002 Rank > 0 ? at(ends_, 0) - at(begins_, 0) : 0,
1003 Rank > 1 ? at(ends_, 1) - at(begins_, 1) : 0,
1004 Rank > 2 ? at(ends_, 2) - at(begins_, 2) : 0,
1005 Rank > 3 ? at(ends_, 3) - at(begins_, 3) : 0,
1006 Rank > 4 ? at(ends_, 4) - at(begins_, 4) : 0,
1007 Rank > 5 ? at(ends_, 5) - at(begins_, 5) : 0,
1008 Rank > 6 ? at(ends_, 6) - at(begins_, 6) : 0,
1009 Rank > 7 ? at(ends_, 7) - at(begins_, 7) : 0)) {
1010 for (
size_t i = 0; i != m_begins.size(); ++i) {
1011 m_begins[i] = at(begins_, i);
1020 OffsetView(
const pointer_type& p,
const begins_type& begins_,
1021 const begins_type& ends_)
1022 : OffsetView(p, begins_, ends_,
1023 runtime_check_begins_ends(begins_, ends_)) {}
1026 OffsetView(
const pointer_type& p,
const begins_type& begins_,
1027 index_list_type ends_)
1028 : OffsetView(p, begins_, ends_,
1029 runtime_check_begins_ends(begins_, ends_)) {}
1032 OffsetView(
const pointer_type& p, index_list_type begins_,
1033 const begins_type& ends_)
1034 : OffsetView(p, begins_, ends_,
1035 runtime_check_begins_ends(begins_, ends_)) {}
1038 OffsetView(
const pointer_type& p, index_list_type begins_,
1039 index_list_type ends_)
1040 : OffsetView(p, begins_, ends_,
1041 runtime_check_begins_ends(begins_, ends_)) {}
1046 int use_count()
const {
return m_track.use_count(); }
1048 const std::string label()
const {
1049 return m_track.template get_label<typename traits::memory_space>();
1058 template <
typename Label>
1059 explicit OffsetView(
1060 const Label& arg_label,
1061 std::enable_if_t<Kokkos::Impl::is_view_label<Label>::value,
1062 const std::pair<int64_t, int64_t>>
1064 const std::pair<int64_t, int64_t> range1 = KOKKOS_INVALID_INDEX_RANGE,
1065 const std::pair<int64_t, int64_t> range2 = KOKKOS_INVALID_INDEX_RANGE,
1066 const std::pair<int64_t, int64_t> range3 = KOKKOS_INVALID_INDEX_RANGE,
1067 const std::pair<int64_t, int64_t> range4 = KOKKOS_INVALID_INDEX_RANGE,
1068 const std::pair<int64_t, int64_t> range5 = KOKKOS_INVALID_INDEX_RANGE,
1069 const std::pair<int64_t, int64_t> range6 = KOKKOS_INVALID_INDEX_RANGE,
1070 const std::pair<int64_t, int64_t> range7 = KOKKOS_INVALID_INDEX_RANGE
1074 Kokkos::Impl::ViewCtorProp<std::string>(arg_label),
1075 typename traits::array_layout(range0.second - range0.first + 1,
1076 range1.second - range1.first + 1,
1077 range2.second - range2.first + 1,
1078 range3.second - range3.first + 1,
1079 range4.second - range4.first + 1,
1080 range5.second - range5.first + 1,
1081 range6.second - range6.first + 1,
1082 range7.second - range7.first + 1),
1083 {range0.first, range1.first, range2.first, range3.first,
1084 range4.first, range5.first, range6.first, range7.first}) {}
1086 template <
class... P>
1087 explicit OffsetView(
1088 const Kokkos::Impl::ViewCtorProp<P...>& arg_prop,
1089 const std::pair<int64_t, int64_t> range0 = KOKKOS_INVALID_INDEX_RANGE,
1090 const std::pair<int64_t, int64_t> range1 = KOKKOS_INVALID_INDEX_RANGE,
1091 const std::pair<int64_t, int64_t> range2 = KOKKOS_INVALID_INDEX_RANGE,
1092 const std::pair<int64_t, int64_t> range3 = KOKKOS_INVALID_INDEX_RANGE,
1093 const std::pair<int64_t, int64_t> range4 = KOKKOS_INVALID_INDEX_RANGE,
1094 const std::pair<int64_t, int64_t> range5 = KOKKOS_INVALID_INDEX_RANGE,
1095 const std::pair<int64_t, int64_t> range6 = KOKKOS_INVALID_INDEX_RANGE,
1096 const std::pair<int64_t, int64_t> range7 = KOKKOS_INVALID_INDEX_RANGE)
1099 typename traits::array_layout(range0.second - range0.first + 1,
1100 range1.second - range1.first + 1,
1101 range2.second - range2.first + 1,
1102 range3.second - range3.first + 1,
1103 range4.second - range4.first + 1,
1104 range5.second - range5.first + 1,
1105 range6.second - range6.first + 1,
1106 range7.second - range7.first + 1),
1107 {range0.first, range1.first, range2.first, range3.first,
1108 range4.first, range5.first, range6.first, range7.first}) {}
1110 template <
class... P>
1111 explicit KOKKOS_FUNCTION OffsetView(
1112 const Kokkos::Impl::ViewCtorProp<P...>& arg_prop,
1113 std::enable_if_t<Kokkos::Impl::ViewCtorProp<P...>::has_pointer,
1114 typename traits::array_layout>
const& arg_layout,
1115 const index_list_type minIndices)
1118 m_map(arg_prop, arg_layout) {
1119 for (
size_t i = 0; i < minIndices.size(); ++i) {
1120 m_begins[i] = minIndices.begin()[i];
1123 std::is_same<pointer_type,
typename Kokkos::Impl::ViewCtorProp<
1124 P...>::pointer_type>::value,
1125 "When constructing OffsetView to wrap user memory, you must supply "
1126 "matching pointer type");
1129 template <
class... P>
1130 explicit OffsetView(
1131 const Kokkos::Impl::ViewCtorProp<P...>& arg_prop,
1132 std::enable_if_t<!Kokkos::Impl::ViewCtorProp<P...>::has_pointer,
1133 typename traits::array_layout>
const& arg_layout,
1134 const index_list_type minIndices)
1139 for (
size_t i = 0; i < Rank; ++i) m_begins[i] = minIndices.begin()[i];
1142 auto prop_copy = Kokkos::Impl::with_properties_if_unset(
1143 arg_prop, std::string{},
typename traits::device_type::memory_space{},
1144 typename traits::device_type::execution_space{});
1145 using alloc_prop = decltype(prop_copy);
1147 static_assert(traits::is_managed,
1148 "OffsetView allocation constructor requires managed memory");
1150 if (alloc_prop::initialize &&
1151 !alloc_prop::execution_space::impl_is_initialized()) {
1154 Kokkos::Impl::throw_runtime_exception(
1155 "Constructing OffsetView and initializing data with uninitialized "
1159 Kokkos::Impl::SharedAllocationRecord<>* record = m_map.allocate_shared(
1160 prop_copy, arg_layout,
1161 Kokkos::Impl::ViewCtorProp<P...>::has_execution_space);
1164 m_track.assign_allocated_record_to_uninitialized(record);
1166 KOKKOS_IF_ON_HOST((Kokkos::Experimental::Impl::runtime_check_rank_host(
1167 traits::rank_dynamic, Rank, minIndices, label());))
1169 KOKKOS_IF_ON_DEVICE((Kokkos::Experimental::Impl::runtime_check_rank_device(
1170 traits::rank_dynamic, Rank, minIndices);))
1178 template <typename D, class... P>
1179 KOKKOS_INLINE_FUNCTION constexpr
unsigned rank(const OffsetView<D, P...>& V) {
1188 KOKKOS_INLINE_FUNCTION std::enable_if_t<std::is_integral<T>::value, T>
1189 shift_input(
const T arg,
const int64_t offset) {
1190 return arg - offset;
1193 KOKKOS_INLINE_FUNCTION
1194 Kokkos::ALL_t shift_input(
const Kokkos::ALL_t arg,
const int64_t ) {
1199 KOKKOS_INLINE_FUNCTION
1202 return Kokkos::make_pair<T, T>(arg.
first - offset, arg.
second - offset);
1205 inline std::enable_if_t<std::is_integral<T>::value, std::pair<T, T>>
1206 shift_input(
const std::pair<T, T> arg,
const int64_t offset) {
1207 return std::make_pair<T, T>(arg.first - offset, arg.second - offset);
1210 template <
size_t N,
class Arg,
class A>
1211 KOKKOS_INLINE_FUNCTION
void map_arg_to_new_begin(
1213 std::enable_if_t<N != 0, const Arg> shiftedArg,
const Arg arg,
1214 const A viewBegins,
size_t& counter) {
1215 if (!std::is_integral<Arg>::value) {
1216 subviewBegins[counter] = shiftedArg == arg ? viewBegins[i] : 0;
1221 template <
size_t N,
class Arg,
class A>
1222 KOKKOS_INLINE_FUNCTION
void map_arg_to_new_begin(
1224 std::enable_if_t<N == 0, const Arg> ,
const Arg ,
1225 const A ,
size_t& ) {}
1227 template <
class D,
class... P,
class T>
1228 KOKKOS_INLINE_FUNCTION
1229 typename Kokkos::Experimental::Impl::GetOffsetViewTypeFromViewType<
1230 typename Kokkos::Impl::ViewMapping<
void
1233 ViewTraits<D, P...>, T>::type>::type
1234 subview_offset(
const OffsetView<D, P...>& src, T arg) {
1235 auto theView = src.view();
1236 auto begins = src.begins();
1238 T shiftedArg = shift_input(arg, begins[0]);
1240 constexpr
size_t rank =
1241 Kokkos::Impl::ViewMapping<
void
1244 ViewTraits<D, P...>, T>::type::rank;
1246 auto theSubview = Kokkos::subview(theView, shiftedArg);
1250 Kokkos::Experimental::Impl::map_arg_to_new_begin(0, subviewBegins, shiftedArg,
1251 arg, begins, counter);
1253 typename Kokkos::Experimental::Impl::GetOffsetViewTypeFromViewType<
1254 typename Kokkos::Impl::ViewMapping<
void
1257 ViewTraits<D, P...>, T>::type>::type
1258 offsetView(theSubview, subviewBegins);
1263 template <
class D,
class... P,
class T0,
class T1>
1264 KOKKOS_INLINE_FUNCTION
1265 typename Kokkos::Experimental::Impl::GetOffsetViewTypeFromViewType<
1266 typename Kokkos::Impl::ViewMapping<
1269 ViewTraits<D, P...>, T0, T1>::type>::type
1270 subview_offset(
const Kokkos::Experimental::OffsetView<D, P...>& src,
1272 auto theView = src.view();
1273 auto begins = src.begins();
1275 T0 shiftedArg0 = shift_input(arg0, begins[0]);
1276 T1 shiftedArg1 = shift_input(arg1, begins[1]);
1278 auto theSubview = Kokkos::subview(theView, shiftedArg0, shiftedArg1);
1279 constexpr
size_t rank =
1280 Kokkos::Impl::ViewMapping<
void
1283 ViewTraits<D, P...>, T0, T1>::type::rank;
1287 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1288 0, subviewBegins, shiftedArg0, arg0, begins, counter);
1289 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1290 1, subviewBegins, shiftedArg1, arg1, begins, counter);
1292 typename Kokkos::Experimental::Impl::GetOffsetViewTypeFromViewType<
1293 typename Kokkos::Impl::ViewMapping<
1296 ViewTraits<D, P...>, T0, T1>::type>::type offsetView(theSubview,
1302 template <
class D,
class... P,
class T0,
class T1,
class T2>
1303 KOKKOS_INLINE_FUNCTION
1304 typename Kokkos::Experimental::Impl::GetOffsetViewTypeFromViewType<
1305 typename Kokkos::Impl::ViewMapping<
1308 ViewTraits<D, P...>, T0, T1, T2>::type>::type
1309 subview_offset(
const OffsetView<D, P...>& src, T0 arg0, T1 arg1, T2 arg2) {
1310 auto theView = src.view();
1311 auto begins = src.begins();
1313 T0 shiftedArg0 = shift_input(arg0, begins[0]);
1314 T1 shiftedArg1 = shift_input(arg1, begins[1]);
1315 T2 shiftedArg2 = shift_input(arg2, begins[2]);
1318 Kokkos::subview(theView, shiftedArg0, shiftedArg1, shiftedArg2);
1320 constexpr
size_t rank =
1321 Kokkos::Impl::ViewMapping<
void
1324 ViewTraits<D, P...>, T0, T1, T2>::type::rank;
1329 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1330 0, subviewBegins, shiftedArg0, arg0, begins, counter);
1331 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1332 1, subviewBegins, shiftedArg1, arg1, begins, counter);
1333 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1334 2, subviewBegins, shiftedArg2, arg2, begins, counter);
1336 typename Kokkos::Experimental::Impl::GetOffsetViewTypeFromViewType<
1337 typename Kokkos::Impl::ViewMapping<
1340 ViewTraits<D, P...>, T0, T1, T2>::type>::type
1341 offsetView(theSubview, subviewBegins);
1346 template <
class D,
class... P,
class T0,
class T1,
class T2,
class T3>
1347 KOKKOS_INLINE_FUNCTION
1348 typename Kokkos::Experimental::Impl::GetOffsetViewTypeFromViewType<
1349 typename Kokkos::Impl::ViewMapping<
1352 ViewTraits<D, P...>, T0, T1, T2, T3>::type>::type
1353 subview_offset(
const OffsetView<D, P...>& src, T0 arg0, T1 arg1, T2 arg2,
1355 auto theView = src.view();
1356 auto begins = src.begins();
1358 T0 shiftedArg0 = shift_input(arg0, begins[0]);
1359 T1 shiftedArg1 = shift_input(arg1, begins[1]);
1360 T2 shiftedArg2 = shift_input(arg2, begins[2]);
1361 T3 shiftedArg3 = shift_input(arg3, begins[3]);
1363 auto theSubview = Kokkos::subview(theView, shiftedArg0, shiftedArg1,
1364 shiftedArg2, shiftedArg3);
1366 constexpr
size_t rank = Kokkos::Impl::ViewMapping<
1369 ViewTraits<D, P...>, T0, T1, T2, T3>::type::rank;
1373 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1374 0, subviewBegins, shiftedArg0, arg0, begins, counter);
1375 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1376 1, subviewBegins, shiftedArg1, arg1, begins, counter);
1377 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1378 2, subviewBegins, shiftedArg2, arg2, begins, counter);
1379 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1380 3, subviewBegins, shiftedArg3, arg3, begins, counter);
1382 typename Kokkos::Experimental::Impl::GetOffsetViewTypeFromViewType<
1383 typename Kokkos::Impl::ViewMapping<
1386 ViewTraits<D, P...>, T0, T1, T2, T3>::type>::type
1387 offsetView(theSubview, subviewBegins);
1392 template <
class D,
class... P,
class T0,
class T1,
class T2,
class T3,
class T4>
1393 KOKKOS_INLINE_FUNCTION
1394 typename Kokkos::Experimental::Impl::GetOffsetViewTypeFromViewType<
1395 typename Kokkos::Impl::ViewMapping<
1398 ViewTraits<D, P...>, T0, T1, T2, T3, T4>::type>::type
1399 subview_offset(
const OffsetView<D, P...>& src, T0 arg0, T1 arg1, T2 arg2,
1401 auto theView = src.view();
1402 auto begins = src.begins();
1404 T0 shiftedArg0 = shift_input(arg0, begins[0]);
1405 T1 shiftedArg1 = shift_input(arg1, begins[1]);
1406 T2 shiftedArg2 = shift_input(arg2, begins[2]);
1407 T3 shiftedArg3 = shift_input(arg3, begins[3]);
1408 T4 shiftedArg4 = shift_input(arg4, begins[4]);
1410 auto theSubview = Kokkos::subview(theView, shiftedArg0, shiftedArg1,
1411 shiftedArg2, shiftedArg3, shiftedArg4);
1413 constexpr
size_t rank = Kokkos::Impl::ViewMapping<
1416 ViewTraits<D, P...>, T0, T1, T2, T3, T4>::type::rank;
1420 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1421 0, subviewBegins, shiftedArg0, arg0, begins, counter);
1422 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1423 1, subviewBegins, shiftedArg1, arg1, begins, counter);
1424 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1425 2, subviewBegins, shiftedArg2, arg2, begins, counter);
1426 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1427 3, subviewBegins, shiftedArg3, arg3, begins, counter);
1428 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1429 4, subviewBegins, shiftedArg4, arg4, begins, counter);
1431 typename Kokkos::Experimental::Impl::GetOffsetViewTypeFromViewType<
1432 typename Kokkos::Impl::ViewMapping<
1435 ViewTraits<D, P...>, T0, T1, T2, T3, T4>::type>::type
1436 offsetView(theSubview, subviewBegins);
1441 template <
class D,
class... P,
class T0,
class T1,
class T2,
class T3,
class T4,
1443 KOKKOS_INLINE_FUNCTION
1444 typename Kokkos::Experimental::Impl::GetOffsetViewTypeFromViewType<
1445 typename Kokkos::Impl::ViewMapping<
1448 ViewTraits<D, P...>, T0, T1, T2, T3, T4, T5>::type>::type
1449 subview_offset(
const OffsetView<D, P...>& src, T0 arg0, T1 arg1, T2 arg2,
1450 T3 arg3, T4 arg4, T5 arg5) {
1451 auto theView = src.view();
1452 auto begins = src.begins();
1454 T0 shiftedArg0 = shift_input(arg0, begins[0]);
1455 T1 shiftedArg1 = shift_input(arg1, begins[1]);
1456 T2 shiftedArg2 = shift_input(arg2, begins[2]);
1457 T3 shiftedArg3 = shift_input(arg3, begins[3]);
1458 T4 shiftedArg4 = shift_input(arg4, begins[4]);
1459 T5 shiftedArg5 = shift_input(arg5, begins[5]);
1462 Kokkos::subview(theView, shiftedArg0, shiftedArg1, shiftedArg2,
1463 shiftedArg3, shiftedArg4, shiftedArg5);
1465 constexpr
size_t rank = Kokkos::Impl::ViewMapping<
1468 ViewTraits<D, P...>, T0, T1, T2, T3, T4, T5>::type::rank;
1473 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1474 0, subviewBegins, shiftedArg0, arg0, begins, counter);
1475 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1476 1, subviewBegins, shiftedArg1, arg1, begins, counter);
1477 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1478 2, subviewBegins, shiftedArg2, arg2, begins, counter);
1479 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1480 3, subviewBegins, shiftedArg3, arg3, begins, counter);
1481 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1482 4, subviewBegins, shiftedArg4, arg4, begins, counter);
1483 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1484 5, subviewBegins, shiftedArg5, arg5, begins, counter);
1486 typename Kokkos::Experimental::Impl::GetOffsetViewTypeFromViewType<
1487 typename Kokkos::Impl::ViewMapping<
1490 ViewTraits<D, P...>, T0, T1, T2, T3, T4, T5>::type>::type
1491 offsetView(theSubview, subviewBegins);
1495 template <
class D,
class... P,
class T0,
class T1,
class T2,
class T3,
class T4,
1497 KOKKOS_INLINE_FUNCTION
1498 typename Kokkos::Experimental::Impl::GetOffsetViewTypeFromViewType<
1499 typename Kokkos::Impl::ViewMapping<
1502 ViewTraits<D, P...>, T0, T1, T2, T3, T4, T5, T6>::type>::type
1503 subview_offset(
const OffsetView<D, P...>& src, T0 arg0, T1 arg1, T2 arg2,
1504 T3 arg3, T4 arg4, T5 arg5, T6 arg6) {
1505 auto theView = src.view();
1506 auto begins = src.begins();
1508 T0 shiftedArg0 = shift_input(arg0, begins[0]);
1509 T1 shiftedArg1 = shift_input(arg1, begins[1]);
1510 T2 shiftedArg2 = shift_input(arg2, begins[2]);
1511 T3 shiftedArg3 = shift_input(arg3, begins[3]);
1512 T4 shiftedArg4 = shift_input(arg4, begins[4]);
1513 T5 shiftedArg5 = shift_input(arg5, begins[5]);
1514 T6 shiftedArg6 = shift_input(arg6, begins[6]);
1517 Kokkos::subview(theView, shiftedArg0, shiftedArg1, shiftedArg2,
1518 shiftedArg3, shiftedArg4, shiftedArg5, shiftedArg6);
1520 constexpr
size_t rank = Kokkos::Impl::ViewMapping<
1523 ViewTraits<D, P...>, T0, T1, T2, T3, T4, T5, T6>::type::rank;
1528 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1529 0, subviewBegins, shiftedArg0, arg0, begins, counter);
1530 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1531 1, subviewBegins, shiftedArg1, arg1, begins, counter);
1532 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1533 2, subviewBegins, shiftedArg2, arg2, begins, counter);
1534 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1535 3, subviewBegins, shiftedArg3, arg3, begins, counter);
1536 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1537 4, subviewBegins, shiftedArg4, arg4, begins, counter);
1538 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1539 5, subviewBegins, shiftedArg5, arg5, begins, counter);
1540 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1541 6, subviewBegins, shiftedArg6, arg6, begins, counter);
1543 typename Kokkos::Experimental::Impl::GetOffsetViewTypeFromViewType<
1544 typename Kokkos::Impl::ViewMapping<
1547 ViewTraits<D, P...>, T0, T1, T2, T3, T4, T5, T6>::type>::type
1548 offsetView(theSubview, subviewBegins);
1553 template <
class D,
class... P,
class T0,
class T1,
class T2,
class T3,
class T4,
1554 class T5,
class T6,
class T7>
1555 KOKKOS_INLINE_FUNCTION
1556 typename Kokkos::Experimental::Impl::GetOffsetViewTypeFromViewType<
1557 typename Kokkos::Impl::ViewMapping<
1560 ViewTraits<D, P...>, T0, T1, T2, T3, T4, T5, T6, T7>::type>::type
1561 subview_offset(
const OffsetView<D, P...>& src, T0 arg0, T1 arg1, T2 arg2,
1562 T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7) {
1563 auto theView = src.view();
1564 auto begins = src.begins();
1566 T0 shiftedArg0 = shift_input(arg0, begins[0]);
1567 T1 shiftedArg1 = shift_input(arg1, begins[1]);
1568 T2 shiftedArg2 = shift_input(arg2, begins[2]);
1569 T3 shiftedArg3 = shift_input(arg3, begins[3]);
1570 T4 shiftedArg4 = shift_input(arg4, begins[4]);
1571 T5 shiftedArg5 = shift_input(arg5, begins[5]);
1572 T6 shiftedArg6 = shift_input(arg6, begins[6]);
1573 T7 shiftedArg7 = shift_input(arg7, begins[7]);
1575 auto theSubview = Kokkos::subview(theView, shiftedArg0, shiftedArg1,
1576 shiftedArg2, shiftedArg3, shiftedArg4,
1577 shiftedArg5, shiftedArg6, shiftedArg7);
1579 constexpr
size_t rank = Kokkos::Impl::ViewMapping<
1582 ViewTraits<D, P...>, T0, T1, T2, T3, T4, T5, T6, T7>::type::rank;
1587 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1588 0, subviewBegins, shiftedArg0, arg0, begins, counter);
1589 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1590 1, subviewBegins, shiftedArg1, arg1, begins, counter);
1591 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1592 2, subviewBegins, shiftedArg2, arg2, begins, counter);
1593 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1594 3, subviewBegins, shiftedArg3, arg3, begins, counter);
1595 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1596 4, subviewBegins, shiftedArg4, arg4, begins, counter);
1597 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1598 5, subviewBegins, shiftedArg5, arg5, begins, counter);
1599 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1600 6, subviewBegins, shiftedArg6, arg6, begins, counter);
1601 Kokkos::Experimental::Impl::map_arg_to_new_begin(
1602 7, subviewBegins, shiftedArg7, arg7, begins, counter);
1604 typename Kokkos::Experimental::Impl::GetOffsetViewTypeFromViewType<
1605 typename Kokkos::Impl::ViewMapping<
1608 ViewTraits<D, P...>, T0, T1, T2, T3, T4, T5, T6, T7>::type>::type
1609 offsetView(theSubview, subviewBegins);
1615 template <
class D,
class... P,
class... Args>
1616 KOKKOS_INLINE_FUNCTION
1617 typename Kokkos::Experimental::Impl::GetOffsetViewTypeFromViewType<
1618 typename Kokkos::Impl::ViewMapping<
1621 ViewTraits<D, P...>, Args...>::type>::type
1622 subview(
const OffsetView<D, P...>& src, Args... args) {
1624 OffsetView<D, P...>::Rank ==
sizeof...(Args),
1625 "subview requires one argument for each source OffsetView rank");
1627 return Kokkos::Experimental::Impl::subview_offset(src, args...);
1636 namespace Experimental {
1637 template <
class LT,
class... LP,
class RT,
class... RP>
1638 KOKKOS_INLINE_FUNCTION
bool operator==(
const OffsetView<LT, LP...>& lhs,
1639 const OffsetView<RT, RP...>& rhs) {
1641 using lhs_traits = ViewTraits<LT, LP...>;
1642 using rhs_traits = ViewTraits<RT, RP...>;
1644 return std::is_same<
typename lhs_traits::const_value_type,
1645 typename rhs_traits::const_value_type>::value &&
1646 std::is_same<
typename lhs_traits::array_layout,
1647 typename rhs_traits::array_layout>::value &&
1648 std::is_same<
typename lhs_traits::memory_space,
1649 typename rhs_traits::memory_space>::value &&
1650 unsigned(lhs_traits::rank) == unsigned(rhs_traits::rank) &&
1651 lhs.data() == rhs.data() && lhs.span() == rhs.span() &&
1652 lhs.extent(0) == rhs.extent(0) && lhs.extent(1) == rhs.extent(1) &&
1653 lhs.extent(2) == rhs.extent(2) && lhs.extent(3) == rhs.extent(3) &&
1654 lhs.extent(4) == rhs.extent(4) && lhs.extent(5) == rhs.extent(5) &&
1655 lhs.extent(6) == rhs.extent(6) && lhs.extent(7) == rhs.extent(7) &&
1656 lhs.begin(0) == rhs.begin(0) && lhs.begin(1) == rhs.begin(1) &&
1657 lhs.begin(2) == rhs.begin(2) && lhs.begin(3) == rhs.begin(3) &&
1658 lhs.begin(4) == rhs.begin(4) && lhs.begin(5) == rhs.begin(5) &&
1659 lhs.begin(6) == rhs.begin(6) && lhs.begin(7) == rhs.begin(7);
1662 template <
class LT,
class... LP,
class RT,
class... RP>
1663 KOKKOS_INLINE_FUNCTION
bool operator!=(
const OffsetView<LT, LP...>& lhs,
1664 const OffsetView<RT, RP...>& rhs) {
1665 return !(operator==(lhs, rhs));
1668 template <
class LT,
class... LP,
class RT,
class... RP>
1669 KOKKOS_INLINE_FUNCTION
bool operator==(
const View<LT, LP...>& lhs,
1670 const OffsetView<RT, RP...>& rhs) {
1672 using lhs_traits = ViewTraits<LT, LP...>;
1673 using rhs_traits = ViewTraits<RT, RP...>;
1675 return std::is_same<
typename lhs_traits::const_value_type,
1676 typename rhs_traits::const_value_type>::value &&
1677 std::is_same<
typename lhs_traits::array_layout,
1678 typename rhs_traits::array_layout>::value &&
1679 std::is_same<
typename lhs_traits::memory_space,
1680 typename rhs_traits::memory_space>::value &&
1681 unsigned(lhs_traits::rank) == unsigned(rhs_traits::rank) &&
1682 lhs.data() == rhs.data() && lhs.span() == rhs.span() &&
1683 lhs.extent(0) == rhs.extent(0) && lhs.extent(1) == rhs.extent(1) &&
1684 lhs.extent(2) == rhs.extent(2) && lhs.extent(3) == rhs.extent(3) &&
1685 lhs.extent(4) == rhs.extent(4) && lhs.extent(5) == rhs.extent(5) &&
1686 lhs.extent(6) == rhs.extent(6) && lhs.extent(7) == rhs.extent(7);
1689 template <
class LT,
class... LP,
class RT,
class... RP>
1690 KOKKOS_INLINE_FUNCTION
bool operator==(
const OffsetView<LT, LP...>& lhs,
1691 const View<RT, RP...>& rhs) {
1703 template <
class DT,
class... DP>
1704 inline void deep_copy(
1705 const Experimental::OffsetView<DT, DP...>& dst,
1706 typename ViewTraits<DT, DP...>::const_value_type& value,
1707 std::enable_if_t<std::is_same<
typename ViewTraits<DT, DP...>::specialize,
1708 void>::value>* =
nullptr) {
1710 std::is_same<
typename ViewTraits<DT, DP...>::non_const_value_type,
1711 typename ViewTraits<DT, DP...>::value_type>::value,
1712 "deep_copy requires non-const type");
1714 auto dstView = dst.view();
1715 Kokkos::deep_copy(dstView, value);
1718 template <
class DT,
class... DP,
class ST,
class... SP>
1719 inline void deep_copy(
1720 const Experimental::OffsetView<DT, DP...>& dst,
1721 const Experimental::OffsetView<ST, SP...>& value,
1722 std::enable_if_t<std::is_same<
typename ViewTraits<DT, DP...>::specialize,
1723 void>::value>* =
nullptr) {
1725 std::is_same<
typename ViewTraits<DT, DP...>::value_type,
1726 typename ViewTraits<ST, SP...>::non_const_value_type>::value,
1727 "deep_copy requires matching non-const destination type");
1729 auto dstView = dst.view();
1730 Kokkos::deep_copy(dstView, value.view());
1732 template <
class DT,
class... DP,
class ST,
class... SP>
1733 inline void deep_copy(
1734 const Experimental::OffsetView<DT, DP...>& dst,
1735 const View<ST, SP...>& value,
1736 std::enable_if_t<std::is_same<
typename ViewTraits<DT, DP...>::specialize,
1737 void>::value>* =
nullptr) {
1739 std::is_same<
typename ViewTraits<DT, DP...>::value_type,
1740 typename ViewTraits<ST, SP...>::non_const_value_type>::value,
1741 "deep_copy requires matching non-const destination type");
1743 auto dstView = dst.view();
1744 Kokkos::deep_copy(dstView, value);
1747 template <
class DT,
class... DP,
class ST,
class... SP>
1748 inline void deep_copy(
1749 const View<DT, DP...>& dst,
1750 const Experimental::OffsetView<ST, SP...>& value,
1751 std::enable_if_t<std::is_same<
typename ViewTraits<DT, DP...>::specialize,
1752 void>::value>* =
nullptr) {
1754 std::is_same<
typename ViewTraits<DT, DP...>::value_type,
1755 typename ViewTraits<ST, SP...>::non_const_value_type>::value,
1756 "deep_copy requires matching non-const destination type");
1758 Kokkos::deep_copy(dst, value.view());
1764 template <
class Space,
class T,
class... P>
1765 struct MirrorOffsetViewType {
1767 using src_view_type =
typename Kokkos::Experimental::OffsetView<T, P...>;
1769 using memory_space =
typename Space::memory_space;
1773 std::is_same<memory_space, typename src_view_type::memory_space>::value
1776 using array_layout =
typename src_view_type::array_layout;
1779 using data_type =
typename src_view_type::non_const_data_type;
1781 using dest_view_type =
1782 Kokkos::Experimental::OffsetView<data_type, array_layout, Space>;
1786 std::conditional_t<is_same_memspace, src_view_type, dest_view_type>;
1789 template <
class Space,
class T,
class... P>
1790 struct MirrorOffsetType {
1792 using src_view_type =
typename Kokkos::Experimental::OffsetView<T, P...>;
1794 using memory_space =
typename Space::memory_space;
1798 std::is_same<memory_space, typename src_view_type::memory_space>::value
1801 using array_layout =
typename src_view_type::array_layout;
1804 using data_type =
typename src_view_type::non_const_data_type;
1807 Kokkos::Experimental::OffsetView<data_type, array_layout, Space>;
1817 template <
class T,
class... P,
class... ViewCtorArgs>
1818 inline auto create_mirror(
const Kokkos::Experimental::OffsetView<T, P...>& src,
1819 const Impl::ViewCtorProp<ViewCtorArgs...>& arg_prop) {
1820 check_view_ctor_args_create_mirror<ViewCtorArgs...>();
1822 if constexpr (Impl::ViewCtorProp<ViewCtorArgs...>::has_memory_space) {
1823 using Space =
typename Impl::ViewCtorProp<ViewCtorArgs...>::memory_space;
1825 auto prop_copy = Impl::with_properties_if_unset(
1826 arg_prop, std::string(src.label()).append(
"_mirror"));
1828 return typename Kokkos::Impl::MirrorOffsetType<Space, T, P...>::view_type(
1829 prop_copy, src.layout(),
1830 {src.begin(0), src.begin(1), src.begin(2), src.begin(3), src.begin(4),
1831 src.begin(5), src.begin(6), src.begin(7)});
1833 return typename Kokkos::Experimental::OffsetView<T, P...>::HostMirror(
1834 Kokkos::create_mirror(arg_prop, src.view()), src.begins());
1836 #if defined(KOKKOS_COMPILER_INTEL) || \
1837 (defined(KOKKOS_COMPILER_NVCC) && KOKKOS_COMPILER_NVCC >= 1130 && \
1838 !defined(KOKKOS_COMPILER_MSVC))
1839 __builtin_unreachable();
1846 template <
class T,
class... P,
1847 typename = std::enable_if_t<
1848 std::is_void_v<
typename ViewTraits<T, P...>::specialize>>>
1849 inline auto create_mirror(
1850 const Kokkos::Experimental::OffsetView<T, P...>& src) {
1851 return Impl::create_mirror(src, Impl::ViewCtorProp<>{});
1855 template <
class T,
class... P,
1856 typename = std::enable_if_t<
1857 std::is_void_v<
typename ViewTraits<T, P...>::specialize>>>
1858 inline auto create_mirror(
1859 Kokkos::Impl::WithoutInitializing_t wi,
1860 const Kokkos::Experimental::OffsetView<T, P...>& src) {
1861 return Impl::create_mirror(src, Kokkos::view_alloc(wi));
1865 template <
class Space,
class T,
class... P,
1866 typename Enable = std::enable_if_t<
1867 Kokkos::is_space<Space>::value &&
1868 std::is_void_v<
typename ViewTraits<T, P...>::specialize>>>
1869 inline auto create_mirror(
1870 const Space&,
const Kokkos::Experimental::OffsetView<T, P...>& src) {
1871 return Impl::create_mirror(
1872 src, Kokkos::view_alloc(
typename Space::memory_space{}));
1876 template <
class Space,
class T,
class... P,
1877 typename Enable = std::enable_if_t<
1878 Kokkos::is_space<Space>::value &&
1879 std::is_void_v<
typename ViewTraits<T, P...>::specialize>>>
1880 typename Kokkos::Impl::MirrorOffsetType<Space, T, P...>::view_type
1881 create_mirror(Kokkos::Impl::WithoutInitializing_t wi,
const Space&,
1882 const Kokkos::Experimental::OffsetView<T, P...>& src) {
1883 return Impl::create_mirror(
1884 src, Kokkos::view_alloc(
typename Space::memory_space{}, wi));
1889 template <
class T,
class... P,
class... ViewCtorArgs,
1890 typename = std::enable_if_t<
1891 std::is_void_v<
typename ViewTraits<T, P...>::specialize>>>
1892 inline auto create_mirror(
1893 const Impl::ViewCtorProp<ViewCtorArgs...>& arg_prop,
1894 const Kokkos::Experimental::OffsetView<T, P...>& src) {
1895 return Impl::create_mirror(src, arg_prop);
1903 template <
class T,
class... P,
class... ViewCtorArgs>
1904 inline auto create_mirror_view(
1905 const Kokkos::Experimental::OffsetView<T, P...>& src,
1906 [[maybe_unused]]
const Impl::ViewCtorProp<ViewCtorArgs...>& arg_prop) {
1907 if constexpr (!Impl::ViewCtorProp<ViewCtorArgs...>::has_memory_space) {
1908 if constexpr (std::is_same<
typename Kokkos::Experimental::OffsetView<
1909 T, P...>::memory_space,
1910 typename Kokkos::Experimental::OffsetView<
1911 T, P...>::HostMirror::memory_space>::value &&
1912 std::is_same<
typename Kokkos::Experimental::OffsetView<
1913 T, P...>::data_type,
1914 typename Kokkos::Experimental::OffsetView<
1915 T, P...>::HostMirror::data_type>::value) {
1917 typename Kokkos::Experimental::OffsetView<T, P...>::HostMirror(src);
1919 return Kokkos::Impl::choose_create_mirror(src, arg_prop);
1922 if constexpr (Impl::MirrorOffsetViewType<
typename Impl::ViewCtorProp<
1923 ViewCtorArgs...>::memory_space,
1924 T, P...>::is_same_memspace) {
1925 return typename Impl::MirrorOffsetViewType<
1926 typename Impl::ViewCtorProp<ViewCtorArgs...>::memory_space, T,
1927 P...>::view_type(src);
1929 return Kokkos::Impl::choose_create_mirror(src, arg_prop);
1932 #if defined(KOKKOS_COMPILER_INTEL) || \
1933 (defined(KOKKOS_COMPILER_NVCC) && KOKKOS_COMPILER_NVCC >= 1130 && \
1934 !defined(KOKKOS_COMPILER_MSVC))
1935 __builtin_unreachable();
1942 template <
class T,
class... P>
1943 inline auto create_mirror_view(
1944 const typename Kokkos::Experimental::OffsetView<T, P...>& src) {
1945 return Impl::create_mirror_view(src, Impl::ViewCtorProp<>{});
1949 template <
class T,
class... P>
1950 inline auto create_mirror_view(
1951 Kokkos::Impl::WithoutInitializing_t wi,
1952 const typename Kokkos::Experimental::OffsetView<T, P...>& src) {
1953 return Impl::create_mirror_view(src, Kokkos::view_alloc(wi));
1957 template <
class Space,
class T,
class... P,
1958 typename Enable = std::enable_if_t<Kokkos::is_space<Space>::value>>
1959 inline auto create_mirror_view(
1960 const Space&,
const Kokkos::Experimental::OffsetView<T, P...>& src) {
1961 return Impl::create_mirror_view(
1962 src, Kokkos::view_alloc(
typename Space::memory_space{}));
1966 template <
class Space,
class T,
class... P,
1967 typename Enable = std::enable_if_t<Kokkos::is_space<Space>::value>>
1968 inline auto create_mirror_view(
1969 Kokkos::Impl::WithoutInitializing_t wi,
const Space&,
1970 const Kokkos::Experimental::OffsetView<T, P...>& src) {
1971 return Impl::create_mirror_view(
1972 src, Kokkos::view_alloc(
typename Space::memory_space{}, wi));
1977 template <
class T,
class... P,
class... ViewCtorArgs>
1978 inline auto create_mirror_view(
1979 const Impl::ViewCtorProp<ViewCtorArgs...>& arg_prop,
1980 const Kokkos::Experimental::OffsetView<T, P...>& src) {
1981 return Impl::create_mirror_view(src, arg_prop);
1987 template <
class... ViewCtorArgs,
class T,
class... P>
1988 typename Kokkos::Impl::MirrorOffsetViewType<
1989 typename Impl::ViewCtorProp<ViewCtorArgs...>::memory_space, T,
1991 create_mirror_view_and_copy(
1992 const Impl::ViewCtorProp<ViewCtorArgs...>& arg_prop,
1993 const Kokkos::Experimental::OffsetView<T, P...>& src) {
1994 return {create_mirror_view_and_copy(arg_prop, src.view()), src.begins()};
1997 template <
class Space,
class T,
class... P>
1998 typename Kokkos::Impl::MirrorOffsetViewType<Space, T, P...>::view_type
1999 create_mirror_view_and_copy(
2000 const Space& space,
const Kokkos::Experimental::OffsetView<T, P...>& src,
2001 std::string
const& name =
"") {
2002 return {create_mirror_view_and_copy(space, src.view(), name), src.begins()};
2009 #ifdef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_OFFSETVIEW
2010 #undef KOKKOS_IMPL_PUBLIC_INCLUDE
2011 #undef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_OFFSETVIEW
Derived from the C++17 'std::array'. Dropping the iterator interface.
Replacement for std::pair that works on CUDA devices.
first_type first
The first element of the pair.
second_type second
The second element of the pair.