Sacado Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Kokkos_View_Fad_Fwd.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_VIEW_FAD_FWD_HPP
31#define KOKKOS_VIEW_FAD_FWD_HPP
32
33#include "Sacado_ConfigDefs.h"
34#if defined(HAVE_SACADO_KOKKOSCORE)
35
36// We are hooking into Kokkos Core internals here
37// Need to define this macro since we include non-public headers
38#ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
39#define KOKKOS_IMPL_PUBLIC_INCLUDE
40#define KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE
41#endif
42// Only include forward declarations so any overloads appear before they
43// might be used inside Kokkos
44#include "Kokkos_Core_fwd.hpp"
45#include "Kokkos_View.hpp"
46#ifdef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE
47#undef KOKKOS_IMPL_PUBLIC_INCLUDE
48#undef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE
49#endif
50
51namespace Kokkos {
52
53// Whether a given type is a view with Sacado FAD scalar type
54template <typename view_type>
55struct is_view_fad;
56
57}
58
59// Make sure the user really wants these View specializations
60#if defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
61
62namespace Kokkos {
63namespace Impl {
64
65struct ViewSpecializeSacadoFad;
66struct ViewSpecializeSacadoFadContiguous;
67
68// Overload view_copy for Fad View's:
69// 1. Should be faster than using Fad directly
70// 2. Fixes issues with hierarchical parallelism since the default
71// implementation uses MDRangePolicy which doesn't work with hierarchical
72// parallelism.
73// Needs to go before include of Kokkos_Core.hpp so it is in scope when
74// Kokkos_CopyViews.hpp is included by Kokkos_Core.hpp, which internally
75// calls view_copy().
76template<class DT, class ... DP,
77 class ST, class ... SP>
78typename std::enable_if< is_view_fad< Kokkos::View<DT,DP...> >::value &&
79 is_view_fad< Kokkos::View<ST,SP...> >::value
80 >::type
81view_copy(const Kokkos::View<DT,DP...>& dst, const Kokkos::View<ST,SP...>& src);
82
83template<class ExecutionSpace,
84 class DT, class ... DP,
85 class ST, class ... SP>
86typename std::enable_if< is_view_fad< Kokkos::View<DT,DP...> >::value &&
87 is_view_fad< Kokkos::View<ST,SP...> >::value
88 >::type
89view_copy(const ExecutionSpace& space,
90 const Kokkos::View<DT,DP...>& dst, const Kokkos::View<ST,SP...>& src);
91
92template<class Space, class T, class ... P>
93struct MirrorType;
94template<class Space, class T, class ... P>
95struct MirrorViewType;
96
97} // namespace Impl
98
99// Declare overloads of create_mirror() so they are in scope
100// Kokkos_Core.hpp is included later
101
102template< class T , class ... P >
103inline
104typename std::enable_if<
105 ( std::is_same< typename ViewTraits<T,P...>::specialize ,
106 Kokkos::Impl::ViewSpecializeSacadoFad >::value ||
107 std::is_same< typename ViewTraits<T,P...>::specialize ,
108 Kokkos::Impl::ViewSpecializeSacadoFadContiguous >::value ) &&
109 !std::is_same< typename Kokkos::ViewTraits<T,P...>::array_layout,
110 Kokkos::LayoutStride >::value,
111 typename Kokkos::View<T,P...>::HostMirror>::type
112create_mirror(const Kokkos::View<T,P...> & src);
113
114template< class T , class ... P >
115inline
116typename std::enable_if<
117 ( std::is_same< typename ViewTraits<T,P...>::specialize ,
118 Kokkos::Impl::ViewSpecializeSacadoFad >::value ||
119 std::is_same< typename ViewTraits<T,P...>::specialize ,
120 Kokkos::Impl::ViewSpecializeSacadoFadContiguous >::value ) &&
121 std::is_same< typename Kokkos::ViewTraits<T,P...>::array_layout,
122 Kokkos::LayoutStride >::value,
123 typename Kokkos::View<T,P...>::HostMirror>::type
124create_mirror(const Kokkos::View<T,P...> & src);
125
126template<class Space, class T, class ... P,
127 typename Enable = std::enable_if_t<Kokkos::is_space<Space>::value>>
128typename std::enable_if<
129 std::is_same< typename ViewTraits<T,P...>::specialize ,
130 Kokkos::Impl::ViewSpecializeSacadoFad >::value ||
131 std::is_same< typename ViewTraits<T,P...>::specialize ,
132 Kokkos::Impl::ViewSpecializeSacadoFadContiguous >::value,
133 typename Impl::MirrorType<Space,T,P ...>::view_type>::type
134create_mirror(const Space&, const Kokkos::View<T,P...> & src);
135
136template< class T , class ... P >
137inline
138typename std::enable_if<
139 ( std::is_same< typename ViewTraits<T,P...>::specialize ,
140 Kokkos::Impl::ViewSpecializeSacadoFad >::value ||
141 std::is_same< typename ViewTraits<T,P...>::specialize ,
142 Kokkos::Impl::ViewSpecializeSacadoFadContiguous >::value ) &&
143 !std::is_same< typename Kokkos::ViewTraits<T,P...>::array_layout,
144 Kokkos::LayoutStride >::value,
145 typename Kokkos::View<T,P...>::HostMirror>::type
146create_mirror(Kokkos::Impl::WithoutInitializing_t wi,
147 const Kokkos::View<T,P...> & src);
148
149template< class T , class ... P >
150inline
151typename std::enable_if<
152 ( std::is_same< typename ViewTraits<T,P...>::specialize ,
153 Kokkos::Impl::ViewSpecializeSacadoFad >::value ||
154 std::is_same< typename ViewTraits<T,P...>::specialize ,
155 Kokkos::Impl::ViewSpecializeSacadoFadContiguous >::value ) &&
156 std::is_same< typename Kokkos::ViewTraits<T,P...>::array_layout,
157 Kokkos::LayoutStride >::value,
158 typename Kokkos::View<T,P...>::HostMirror>::type
159create_mirror(Kokkos::Impl::WithoutInitializing_t wi,
160 const Kokkos::View<T,P...> & src);
161
162template<class Space, class T, class ... P,
163 typename Enable = std::enable_if_t<Kokkos::is_space<Space>::value>>
164typename std::enable_if<
165 ( std::is_same< typename ViewTraits<T,P...>::specialize ,
166 Kokkos::Impl::ViewSpecializeSacadoFad >::value ||
167 std::is_same< typename ViewTraits<T,P...>::specialize ,
168 Kokkos::Impl::ViewSpecializeSacadoFadContiguous >::value ),
169 typename Impl::MirrorType<Space,T,P ...>::view_type>::type
170create_mirror(Kokkos::Impl::WithoutInitializing_t wi,
171 const Space&, const Kokkos::View<T,P...> & src);
172
173template <class Space, class T, class... P>
174typename Impl::MirrorViewType<Space, T, P...>::view_type
175create_mirror_view_and_copy(
176 const Space&, const Kokkos::View<T, P...>& src,
177 std::string const& name = "",
178 typename std::enable_if<
179 ( std::is_same<typename ViewTraits<T, P...>::specialize,
180 Kokkos::Impl::ViewSpecializeSacadoFad>::value ||
181 std::is_same< typename ViewTraits<T,P...>::specialize ,
182 Kokkos::Impl::ViewSpecializeSacadoFadContiguous >::value ) &&
183 Impl::MirrorViewType<Space, T, P...>::is_same_memspace>::type* =
184 nullptr);
185
186template <class Space, class T, class... P>
187typename Impl::MirrorViewType<Space, T, P...>::view_type
188create_mirror_view_and_copy(
189 const Space&, const Kokkos::View<T, P...>& src,
190 std::string const& name = "",
191 typename std::enable_if<
192 ( std::is_same<typename ViewTraits<T, P...>::specialize,
193 Kokkos::Impl::ViewSpecializeSacadoFad>::value ||
194 std::is_same< typename ViewTraits<T,P...>::specialize ,
195 Kokkos::Impl::ViewSpecializeSacadoFadContiguous >::value ) &&
196 !Impl::MirrorViewType<Space, T, P...>::is_same_memspace>::type* =
197 nullptr);
198
199namespace Impl {
200
201template <unsigned N, typename... Args>
202KOKKOS_FUNCTION std::enable_if_t<
203 N == View<Args...>::Rank &&
204 (std::is_same<typename ViewTraits<Args...>::specialize,
205 Kokkos::Impl::ViewSpecializeSacadoFad>::value ||
206 std::is_same<typename ViewTraits<Args...>::specialize,
207 Kokkos::Impl::ViewSpecializeSacadoFadContiguous>::value),
208 View<Args...>>
209as_view_of_rank_n(View<Args...> v);
210
211// Placeholder implementation to compile generic code for DynRankView; should
212// never be called
213template <unsigned N, typename T, typename... Args>
214std::enable_if_t<
215 N != View<T, Args...>::Rank &&
216 (std::is_same<typename ViewTraits<T, Args...>::specialize,
217 Kokkos::Impl::ViewSpecializeSacadoFad>::value ||
218 std::is_same<typename ViewTraits<T, Args...>::specialize,
219 Kokkos::Impl::ViewSpecializeSacadoFadContiguous>::value),
220 View<typename RankDataType<typename View<T, Args...>::value_type, N>::type,
221 Args...>>
222as_view_of_rank_n(View<T, Args...>);
223
224}
225
226} // namespace Kokkos
227
228#endif // defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
229
230#endif // defined(HAVE_SACADO_KOKKOSCORE)
231
232#endif /* #ifndef KOKKOS_VIEW_FAD_FWD_HPP */
View
#define T
Definition: Sacado_rad.hpp:573
const int N
int value