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 //
4 // Sacado Package
5 // Copyright (2006) Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // This library is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as
12 // published by the Free Software Foundation; either version 2.1 of the
13 // License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23 // USA
24 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
25 // (etphipp@sandia.gov).
26 //
27 // ***********************************************************************
28 // @HEADER
29 
30 #ifndef KOKKOS_LAYOUT_NATURAL_HPP
31 #define KOKKOS_LAYOUT_NATURAL_HPP
32 
33 #include "Kokkos_Core_fwd.hpp"
34 #include "Kokkos_Layout.hpp"
35 #include "Kokkos_LayoutContiguous.hpp" // for inner_layout<>
36 
37 namespace Kokkos {
38 
39 // Natural layout for scalar types -- equivalent to the wrapped
40 // layout type
41 template <typename Layout>
42 struct LayoutNatural : public Layout {
43 
46 
47  LayoutNatural( LayoutNatural const & ) = default ;
48  LayoutNatural( LayoutNatural && ) = default ;
49  LayoutNatural & operator = ( LayoutNatural const & ) = default ;
50  LayoutNatural & operator = ( LayoutNatural && ) = default ;
51 
53  constexpr LayoutNatural(
54  size_t N0 = 0 , size_t N1 = 0 , size_t N2 = 0 , size_t N3 = 0
55  , size_t N4 = 0 , size_t N5 = 0 , size_t N6 = 0 , size_t N7 = 0 )
56  : Layout( N0 , N1 , N2 , N3 , N4 , N5 , N6 , N7 ) {}
57 };
58 
59 // Is Layout == LayoutNatural<L> for some L
60 template <class Layout>
62  static const bool value = false;
63 };
64 
65 template <class Layout>
66 struct is_layout_natural< LayoutNatural<Layout> > {
67  static const bool value = true;
68 };
69 
70 template <class Layout>
71 struct inner_layout< LayoutNatural<Layout> > {
72  typedef Layout type;
73 };
74 
75 } // namespace Kokkos
76 
77 // Make LayoutNatural<Layout> equivalent to Layout
78 namespace std {
79 
80  template <class Layout>
81  struct is_same< Kokkos::LayoutNatural<Layout>, Layout> {
82  static const bool value = true;
83  };
84 
85  template <class Layout>
86  struct is_same< Layout, Kokkos::LayoutNatural<Layout> > {
87  static const bool value = true;
88  };
89 
90 }
91 
92 #include "impl/Kokkos_ViewMapping.hpp"
93 
94 namespace Kokkos {
95 namespace Impl {
96 
97 // Implement ViewOffset for LayoutNatural
98 template < class Dimension , class Layout >
99 struct ViewOffset<Dimension, LayoutNatural<Layout>, void>
100  : public ViewOffset<Dimension,Layout> {
101 public:
102 
103  // Would like to use inherited constructors, but gcc 4.7 doesn't support it
104  //using ViewOffset<Dimension,Layout>::ViewOffset;
105 
106  typedef ViewOffset<Dimension,Layout> Base;
107 
108  ViewOffset() = default ;
109  ViewOffset( const ViewOffset & ) = default ;
110  ViewOffset & operator = ( const ViewOffset & ) = default ;
111 
112  // All constructors take one or two arguments
113 
114  template <typename Arg1>
116  constexpr ViewOffset(const Arg1& arg1) : Base(arg1) {}
117 
118  template <typename Arg1, typename Arg2>
120  constexpr ViewOffset(const Arg1& arg1, const Arg2& arg2) : Base(arg1,arg2) {}
121 };
122 
123 } // namespace Impl
124 } // namespace Kokkos
125 
126 #endif // #ifndef KOKKOS_LAYOUT_NATURAL_HPP
LayoutNatural & operator=(LayoutNatural const &)=default
#define KOKKOS_INLINE_FUNCTION
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:96
KOKKOS_INLINE_FUNCTION constexpr ViewOffset(const Arg1 &arg1, const Arg2 &arg2)
KOKKOS_INLINE_FUNCTION constexpr ViewOffset(const Arg1 &arg1)
LayoutNatural(LayoutNatural const &)=default