Sacado Package Browser (Single Doxygen Collection)  Version of the Day
Kokkos_LayoutContiguous.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_EXPERIMENTAL_LAYOUT_CONTIGUOUS_HPP
31 #define KOKKOS_EXPERIMENTAL_LAYOUT_CONTIGUOUS_HPP
32 
33 #include "Kokkos_Core.hpp"
34 #include "Kokkos_Macros.hpp"
35 #include "Kokkos_Layout.hpp"
36 
37 namespace Kokkos {
38 
39 // Contiguous layout for scalar types -- equivalent to the wrapped
40 // layout type
41 template <typename Layout>
42 struct LayoutContiguous : public Layout {
43 
46 
47  LayoutContiguous( LayoutContiguous const & ) = default ;
48  LayoutContiguous( LayoutContiguous && ) = default ;
49  LayoutContiguous & operator = ( LayoutContiguous const & ) = default ;
51 
53  constexpr LayoutContiguous(
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 } // namespace Kokkos
60 
61 // Make LayoutContiguous<Layout> equivalent to Layout
62 namespace std {
63 
64  template <class Layout>
65  struct is_same< Kokkos::LayoutContiguous<Layout>, Layout> {
66  static const bool value = true;
67  };
68 
69  template <class Layout>
70  struct is_same< Layout, Kokkos::LayoutContiguous<Layout> > {
71  static const bool value = true;
72  };
73 
74 }
75 
76 #include "impl/KokkosExp_ViewMapping.hpp"
77 
78 namespace Kokkos {
79 namespace Experimental {
80 namespace Impl {
81 
82 // Implement ViewOffset for LayoutContiguous
83 template < class Dimension , class Layout >
84 struct ViewOffset<Dimension, LayoutContiguous<Layout>, void>
85  : public ViewOffset<Dimension,Layout> {
86 public:
87 
88  // Would like to use inherited constructors, but gcc 4.7 doesn't support it
89  //using ViewOffset<Dimension,Layout>::ViewOffset;
90 
91  typedef ViewOffset<Dimension,Layout> Base;
92 
93  ViewOffset() = default ;
94  ViewOffset( const ViewOffset & ) = default ;
95  ViewOffset & operator = ( const ViewOffset & ) = default ;
96 
97  // All constructors take one or two arguments
98 
99  template <typename Arg1>
101  constexpr ViewOffset(const Arg1& arg1) : Base(arg1) {}
102 
103  template <typename Arg1, typename Arg2>
105  constexpr ViewOffset(const Arg1& arg1, const Arg2& arg2) : Base(arg1,arg2) {}
106 };
107 
108 } // namespace Impl
109 } // namespace Experimental
110 } // namespace Kokkos
111 
112 #endif // #ifndef KOKKOS_EXPERIMENTAL_LAYOUT_CONTIGUOUS_HPP
KOKKOS_INLINE_FUNCTION constexpr LayoutContiguous(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)
KOKKOS_INLINE_FUNCTION constexpr ViewOffset(const Arg1 &arg1, const Arg2 &arg2)
#define KOKKOS_INLINE_FUNCTION
LayoutContiguous(LayoutContiguous const &)=default
LayoutContiguous & operator=(LayoutContiguous const &)=default
LayoutContiguous array_layout
Tag this class as a kokkos array layout.