20 #ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
21 #include <Kokkos_Macros.hpp>
23 "Including non-public Kokkos header files is not allowed.");
25 #ifndef KOKKOS_LAYOUT_HPP
26 #define KOKKOS_LAYOUT_HPP
29 #include <impl/Kokkos_Traits.hpp>
33 enum { ARRAY_LAYOUT_MAX_RANK = 8 };
54 size_t dimension[ARRAY_LAYOUT_MAX_RANK];
56 enum :
bool { is_extent_constructible =
true };
63 KOKKOS_INLINE_FUNCTION
64 explicit constexpr
LayoutLeft(
size_t N0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
65 size_t N1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
66 size_t N2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
67 size_t N3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
68 size_t N4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
69 size_t N5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
70 size_t N6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
71 size_t N7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG)
72 : dimension{N0, N1, N2, N3, N4, N5, N6, N7} {}
74 friend bool operator==(
const LayoutLeft& left,
const LayoutLeft& right) {
75 for (
unsigned int rank = 0; rank < ARRAY_LAYOUT_MAX_RANK; ++rank)
76 if (left.dimension[rank] != right.dimension[rank])
return false;
80 friend bool operator!=(
const LayoutLeft& left,
const LayoutLeft& right) {
81 return !(left == right);
103 size_t dimension[ARRAY_LAYOUT_MAX_RANK];
105 enum :
bool { is_extent_constructible =
true };
112 KOKKOS_INLINE_FUNCTION
113 explicit constexpr
LayoutRight(
size_t N0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
114 size_t N1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
115 size_t N2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
116 size_t N3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
117 size_t N4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
118 size_t N5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
119 size_t N6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
120 size_t N7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG)
121 : dimension{N0, N1, N2, N3, N4, N5, N6, N7} {}
123 friend bool operator==(
const LayoutRight& left,
const LayoutRight& right) {
124 for (
unsigned int rank = 0; rank < ARRAY_LAYOUT_MAX_RANK; ++rank)
125 if (left.dimension[rank] != right.dimension[rank])
return false;
129 friend bool operator!=(
const LayoutRight& left,
const LayoutRight& right) {
130 return !(left == right);
142 size_t dimension[ARRAY_LAYOUT_MAX_RANK];
143 size_t stride[ARRAY_LAYOUT_MAX_RANK];
145 enum :
bool { is_extent_constructible =
false };
159 template <
typename iTypeOrder,
typename iTypeDimen>
161 int const rank, iTypeOrder
const*
const order,
162 iTypeDimen
const*
const dimen) {
165 int check_input = ARRAY_LAYOUT_MAX_RANK < rank ? 0 : int(1 << rank) - 1;
166 for (
int r = 0; r < ARRAY_LAYOUT_MAX_RANK; ++r) {
167 tmp.dimension[r] = KOKKOS_IMPL_CTOR_DEFAULT_ARG;
170 for (
int r = 0; r < rank; ++r) {
171 check_input &= ~int(1 << order[r]);
173 if (0 == check_input) {
175 for (
int r = 0; r < rank; ++r) {
176 tmp.stride[order[r]] = n;
177 n *= (dimen[order[r]]);
178 tmp.dimension[r] = dimen[r];
184 KOKKOS_INLINE_FUNCTION
186 size_t N0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
size_t S0 = 0,
187 size_t N1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
size_t S1 = 0,
188 size_t N2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
size_t S2 = 0,
189 size_t N3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
size_t S3 = 0,
190 size_t N4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
size_t S4 = 0,
191 size_t N5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
size_t S5 = 0,
192 size_t N6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
size_t S6 = 0,
193 size_t N7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
size_t S7 = 0)
194 : dimension{N0, N1, N2, N3, N4, N5, N6, N7}, stride{S0, S1, S2, S3,
197 friend bool operator==(
const LayoutStride& left,
const LayoutStride& right) {
198 for (
unsigned int rank = 0; rank < ARRAY_LAYOUT_MAX_RANK; ++rank)
199 if (left.dimension[rank] != right.dimension[rank] ||
200 left.stride[rank] != right.stride[rank])
205 friend bool operator!=(
const LayoutStride& left,
const LayoutStride& right) {
206 return !(left == right);
220 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4
221 template <
typename Layout,
class Enable =
void>
222 struct KOKKOS_DEPRECATED is_layouttiled : std::false_type {};
227 template <
typename... Layout>
228 struct layout_iterate_type_selector {
229 static const Kokkos::Iterate outer_iteration_pattern =
230 Kokkos::Iterate::Default;
231 static const Kokkos::Iterate inner_iteration_pattern =
232 Kokkos::Iterate::Default;
236 struct layout_iterate_type_selector<Kokkos::LayoutRight> {
237 static const Kokkos::Iterate outer_iteration_pattern = Kokkos::Iterate::Right;
238 static const Kokkos::Iterate inner_iteration_pattern = Kokkos::Iterate::Right;
242 struct layout_iterate_type_selector<Kokkos::LayoutLeft> {
243 static const Kokkos::Iterate outer_iteration_pattern = Kokkos::Iterate::Left;
244 static const Kokkos::Iterate inner_iteration_pattern = Kokkos::Iterate::Left;
248 struct layout_iterate_type_selector<Kokkos::LayoutStride> {
249 static const Kokkos::Iterate outer_iteration_pattern =
250 Kokkos::Iterate::Default;
251 static const Kokkos::Iterate inner_iteration_pattern =
252 Kokkos::Iterate::Default;
256 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4
257 template <
typename... Layout>
258 using layout_iterate_type_selector KOKKOS_DEPRECATED =
259 Impl::layout_iterate_type_selector<Layout...>;
264 #endif // #ifndef KOKKOS_LAYOUT_HPP
Memory layout tag indicating left-to-right (Fortran scheme) striding of multi-indices.
Memory layout tag indicated arbitrarily strided multi-index mapping into contiguous memory...
Memory layout tag indicating right-to-left (C or lexigraphical scheme) striding of multi-indices...
static KOKKOS_INLINE_FUNCTION LayoutStride order_dimensions(int const rank, iTypeOrder const *const order, iTypeDimen const *const dimen)
Compute strides from ordered dimensions.