Sacado Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
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// We are hooking into Kokkos Core internals here
34// Need to define this macro since we include non-public headers
35#ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
36#define KOKKOS_IMPL_PUBLIC_INCLUDE
37#define KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE
38#endif
39#include "Kokkos_Core_fwd.hpp"
40#include "Kokkos_Layout.hpp"
41#include "Kokkos_LayoutContiguous.hpp" // for inner_layout<>
42#ifdef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE
43#undef KOKKOS_IMPL_PUBLIC_INCLUDE
44#undef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE
45#endif
46
47namespace Kokkos {
48
49// Natural layout for scalar types -- equivalent to the wrapped
50// layout type
51template <typename Layout>
52struct LayoutNatural : public Layout {
53
56
57 LayoutNatural( LayoutNatural const & ) = default ;
58 LayoutNatural( LayoutNatural && ) = default ;
59 LayoutNatural & operator = ( LayoutNatural const & ) = default ;
61
62 KOKKOS_INLINE_FUNCTION
63 constexpr LayoutNatural(
64 size_t N0 = 0 , size_t N1 = 0 , size_t N2 = 0 , size_t N3 = 0
65 , size_t N4 = 0 , size_t N5 = 0 , size_t N6 = 0 , size_t N7 = 0 )
66 : Layout( N0 , N1 , N2 , N3 , N4 , N5 , N6 , N7 ) {}
67};
68
69// Is Layout == LayoutNatural<L> for some L
70template <class Layout>
72 static const bool value = false;
73};
74
75template <class Layout>
77 static const bool value = true;
78};
79
80template <class Layout>
81struct inner_layout< LayoutNatural<Layout> > {
82 typedef Layout type;
83};
84
85} // namespace Kokkos
86
87// Make LayoutNatural<Layout> equivalent to Layout
88namespace std {
89
90 template <class Layout>
91 struct is_same< Kokkos::LayoutNatural<Layout>, Layout> {
92 static const bool value = true;
93 };
94
95 template <class Layout>
96 struct is_same< Layout, Kokkos::LayoutNatural<Layout> > {
97 static const bool value = true;
98 };
99
100}
101
102#include "impl/Kokkos_ViewMapping.hpp"
103
104namespace Kokkos {
105namespace Impl {
106
107// Implement ViewOffset for LayoutNatural
108template < class Dimension , class Layout >
109struct ViewOffset<Dimension, LayoutNatural<Layout>, void>
110 : public ViewOffset<Dimension,Layout> {
111public:
112
113 // Would like to use inherited constructors, but gcc 4.7 doesn't support it
114 //using ViewOffset<Dimension,Layout>::ViewOffset;
115
116 typedef ViewOffset<Dimension,Layout> Base;
117
118 ViewOffset() = default ;
119 ViewOffset( const ViewOffset & ) = default ;
120 ViewOffset & operator = ( const ViewOffset & ) = default ;
121
122 // All constructors take one or two arguments
123
124 template <typename Arg1>
125 KOKKOS_INLINE_FUNCTION
126 constexpr ViewOffset(const Arg1& arg1) : Base(arg1) {}
127
128 template <typename Arg1, typename Arg2>
129 KOKKOS_INLINE_FUNCTION
130 constexpr ViewOffset(const Arg1& arg1, const Arg2& arg2) : Base(arg1,arg2) {}
131};
132
133} // namespace Impl
134} // namespace Kokkos
135
136#endif // #ifndef KOKKOS_LAYOUT_NATURAL_HPP
KOKKOS_INLINE_FUNCTION constexpr ViewOffset(const Arg1 &arg1, const Arg2 &arg2)
KOKKOS_INLINE_FUNCTION constexpr ViewOffset(const Arg1 &arg1)
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 & operator=(LayoutNatural const &)=default
LayoutNatural(LayoutNatural &&)=default
LayoutNatural array_layout
Tag this class as a kokkos array layout.
LayoutNatural(LayoutNatural const &)=default