Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Kokkos_LayoutNatural.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Sacado Package
4 //
5 // Copyright 2006 NTESS and the Sacado contributors.
6 // SPDX-License-Identifier: LGPL-2.1-or-later
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef KOKKOS_LAYOUT_NATURAL_HPP
11 #define KOKKOS_LAYOUT_NATURAL_HPP
12 
13 // We are hooking into Kokkos Core internals here
14 // Need to define this macro since we include non-public headers
15 #ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
16 #define KOKKOS_IMPL_PUBLIC_INCLUDE
17 #define KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE
18 #endif
19 #include "Kokkos_Core_fwd.hpp"
20 #include "Kokkos_Layout.hpp"
21 #include "Kokkos_LayoutContiguous.hpp" // for inner_layout<>
22 #ifdef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE
23 #undef KOKKOS_IMPL_PUBLIC_INCLUDE
24 #undef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE
25 #endif
26 
27 namespace Kokkos {
28 
29 // Natural layout for scalar types -- equivalent to the wrapped
30 // layout type
31 template <typename Layout>
32 struct LayoutNatural : public Layout {
33 
36 
37  LayoutNatural( LayoutNatural const & ) = default ;
38  LayoutNatural( LayoutNatural && ) = default ;
39  LayoutNatural & operator = ( LayoutNatural const & ) = default ;
40  LayoutNatural & operator = ( LayoutNatural && ) = default ;
41 
42  KOKKOS_INLINE_FUNCTION
43  constexpr LayoutNatural(
44  size_t N0 = 0 , size_t N1 = 0 , size_t N2 = 0 , size_t N3 = 0
45  , size_t N4 = 0 , size_t N5 = 0 , size_t N6 = 0 , size_t N7 = 0 )
46  : Layout( N0 , N1 , N2 , N3 , N4 , N5 , N6 , N7 ) {}
47 };
48 
49 // Is Layout == LayoutNatural<L> for some L
50 template <class Layout>
52  static const bool value = false;
53 };
54 
55 template <class Layout>
56 struct is_layout_natural< LayoutNatural<Layout> > {
57  static const bool value = true;
58 };
59 
60 template <class Layout>
61 struct inner_layout< LayoutNatural<Layout> > {
62  typedef Layout type;
63 };
64 
65 } // namespace Kokkos
66 
67 // Make LayoutNatural<Layout> equivalent to Layout
68 namespace std {
69 
70  template <class Layout>
71  struct is_same< Kokkos::LayoutNatural<Layout>, Layout> {
72  static const bool value = true;
73  };
74 
75  template <class Layout>
76  struct is_same< Layout, Kokkos::LayoutNatural<Layout> > {
77  static const bool value = true;
78  };
79 
80 }
81 
82 #if KOKKOS_VERSION >= 40499
83 #include "View/Kokkos_ViewMapping.hpp"
84 #else
85 #include "impl/Kokkos_ViewMapping.hpp"
86 #endif
87 
88 namespace Kokkos {
89 namespace Impl {
90 
91 // Implement ViewOffset for LayoutNatural
92 template < class Dimension , class Layout >
93 struct ViewOffset<Dimension, LayoutNatural<Layout>, void>
94  : public ViewOffset<Dimension,Layout> {
95 public:
96 
97  // Would like to use inherited constructors, but gcc 4.7 doesn't support it
98  //using ViewOffset<Dimension,Layout>::ViewOffset;
99 
100  typedef ViewOffset<Dimension,Layout> Base;
101 
102  ViewOffset() = default ;
103  ViewOffset( const ViewOffset & ) = default ;
104  ViewOffset & operator = ( const ViewOffset & ) = default ;
105 
106  // All constructors take one or two arguments
107 
108  template <typename Arg1>
109  KOKKOS_INLINE_FUNCTION
110  constexpr ViewOffset(const Arg1& arg1) : Base(arg1) {}
111 
112  template <typename Arg1, typename Arg2>
113  KOKKOS_INLINE_FUNCTION
114  constexpr ViewOffset(const Arg1& arg1, const Arg2& arg2) : Base(arg1,arg2) {}
115 };
116 
117 } // namespace Impl
118 } // namespace Kokkos
119 
120 #endif // #ifndef KOKKOS_LAYOUT_NATURAL_HPP
LayoutNatural & operator=(LayoutNatural const &)=default
KOKKOS_INLINE_FUNCTION constexpr LayoutNatural(size_t N0=0, size_t N1=0, size_t N2=0, size_t N3=0, size_t N4=0, size_t N5=0, size_t N6=0, size_t N7=0)
LayoutNatural array_layout
Tag this class as a kokkos array layout.
void
Definition: uninit.c:105
int value
KOKKOS_INLINE_FUNCTION constexpr ViewOffset(const Arg1 &arg1, const Arg2 &arg2)
KOKKOS_INLINE_FUNCTION constexpr ViewOffset(const Arg1 &arg1)
LayoutNatural(LayoutNatural const &)=default