17 #ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
18 #include <Kokkos_Macros.hpp>
20 "Including non-public Kokkos header files is not allowed.");
22 #ifndef KOKKOS_KOKKOS_EXTENTS_HPP
23 #define KOKKOS_KOKKOS_EXTENTS_HPP
26 #include <type_traits>
27 #include <Kokkos_Macros.hpp>
28 #ifdef KOKKOS_ENABLE_IMPL_MDSPAN
29 #include <mdspan/mdspan.hpp>
36 #ifndef KOKKOS_ENABLE_IMPL_MDSPAN
37 constexpr
size_t dynamic_extent = std::numeric_limits<size_t>::max();
40 namespace Experimental {
42 template <
size_t... ExtentSpecs>
47 template <
class Exts,
size_t NewExtent>
50 template <
size_t... Exts,
size_t NewExtent>
51 struct PrependExtent<Extents<Exts...>, NewExtent> {
52 using type = Extents<NewExtent, Exts...>;
55 template <
class Exts,
size_t NewExtent>
58 template <
size_t... Exts,
size_t NewExtent>
59 struct AppendExtent<Extents<Exts...>, NewExtent> {
60 using type = Extents<Exts..., NewExtent>;
66 namespace _parse_view_extents_impl {
69 struct _all_remaining_extents_dynamic : std::true_type {};
72 struct _all_remaining_extents_dynamic<T*> : _all_remaining_extents_dynamic<T> {
75 template <
class T,
unsigned N>
76 struct _all_remaining_extents_dynamic<T[N]> : std::false_type {};
78 template <
class T,
class Result,
class =
void>
85 template <
class T,
size_t... ExtentSpec>
86 struct _parse_impl<T*, Kokkos::Experimental::Extents<ExtentSpec...>,
87 std::enable_if_t<_all_remaining_extents_dynamic<T>::value>>
88 : _parse_impl<T, Kokkos::Experimental::Extents<Kokkos::dynamic_extent,
92 template <
class T,
size_t... ExtentSpec>
94 T*, Kokkos::Experimental::Extents<ExtentSpec...>,
95 std::enable_if_t<!_all_remaining_extents_dynamic<T>::value>> {
96 using _next = Kokkos::Experimental::AppendExtent<
97 typename _parse_impl<T, Kokkos::Experimental::Extents<ExtentSpec...>,
99 Kokkos::dynamic_extent>;
100 using type =
typename _next::type;
103 template <
class T,
size_t... ExtentSpec,
unsigned N>
104 struct _parse_impl<T[N], Kokkos::Experimental::Extents<ExtentSpec...>, void>
106 Kokkos::Experimental::Extents<ExtentSpec...,
114 template <
class DataType>
115 struct ParseViewExtents {
116 using type =
typename _parse_view_extents_impl ::_parse_impl<
117 DataType, Kokkos::Experimental::Extents<>>::type;
120 template <
class ValueType,
size_t Ext>
122 using type = ValueType[Ext];
125 template <
class ValueType>
126 struct ApplyExtent<ValueType, Kokkos::dynamic_extent> {
127 using type = ValueType*;
130 template <
class ValueType,
unsigned N,
size_t Ext>
131 struct ApplyExtent<ValueType[N], Ext> {
132 using type =
typename ApplyExtent<ValueType, Ext>::type[N];
135 template <
class ValueType,
size_t Ext>
136 struct ApplyExtent<ValueType*, Ext> {
137 using type = ValueType* [Ext];
140 template <
class ValueType>
141 struct ApplyExtent<ValueType*, dynamic_extent> {
142 using type =
typename ApplyExtent<ValueType, dynamic_extent>::type*;
145 template <
class ValueType,
unsigned N>
146 struct ApplyExtent<ValueType[N], dynamic_extent> {
147 using type =
typename ApplyExtent<ValueType, dynamic_extent>::type[N];
154 #endif // KOKKOS_KOKKOS_EXTENTS_HPP