Debian Codegraph @

packages/stokhos/src/sacado/kokkos/pce/Kokkos_View_UQ_PCE_Fwd.hpp

raw
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 #ifndef KOKKOS_VIEW_UQ_PCE_FWD_HPP
11 #define KOKKOS_VIEW_UQ_PCE_FWD_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 // Only include forward declarations so any overloads appear before they
20 // might be used inside Kokkos
21 #include "Kokkos_Core_fwd.hpp"
22 #include "Kokkos_View.hpp"
23 #ifdef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE
24 #undef KOKKOS_IMPL_PUBLIC_INCLUDE
25 #undef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE
26 #endif
27
28 //----------------------------------------------------------------------------
29
30 namespace Sacado {
31 namespace UQ {
32 template <typename Storage >
33 class PCE;
34 }
35 }
36
37 namespace Kokkos {
38
39 namespace Impl {
40 template<class Space, class T, class ... P>
41 struct MirrorViewType;
42 }
43
44 }
45
46 namespace Kokkos {
47 namespace Experimental {
48 namespace Impl {
49
50 struct ViewPCEContiguous;
51
52 } // namespace Impl
53 } // namespace Experimental
54 } // namespace Kokkos
55
56 namespace Kokkos {
57
58 // Declare overloads of create_mirror() so they are in scope
59 // Kokkos_Core.hpp is included below
60
61 template< class T , class ... P >
62 inline
63 typename std::enable_if<
64 std::is_same< typename ViewTraits<T,P...>::specialize ,
65 Kokkos::Experimental::Impl::ViewPCEContiguous >::value &&
66 !std::is_same< typename Kokkos::ViewTraits<T,P...>::array_layout,
67 Kokkos::LayoutStride >::value,
68 typename Kokkos::View<T,P...>::HostMirror>::type
69 create_mirror(const Kokkos::View<T,P...> & src);
70
71 template< class T , class ... P >
72 inline
73 typename std::enable_if<
74 std::is_same< typename ViewTraits<T,P...>::specialize ,
75 Kokkos::Experimental::Impl::ViewPCEContiguous >::value &&
76 std::is_same< typename Kokkos::ViewTraits<T,P...>::array_layout,
77 Kokkos::LayoutStride >::value,
78 typename Kokkos::View<T,P...>::HostMirror>::type
79 create_mirror(const Kokkos::View<T,P...> & src);
80
81 template<class Space, class T, class ... P,
82 typename Enable = std::enable_if_t<Kokkos::is_space<Space>::value>>
83 typename std::enable_if<
84 std::is_same< typename ViewTraits<T,P...>::specialize ,
85 Kokkos::Experimental::Impl::ViewPCEContiguous >::value,
86 typename Impl::MirrorViewType<Space,T,P ...>::dest_view_type>::type
87 create_mirror(const Space&,
88 const Kokkos::View<T,P...> & src);
89
90 template< class T , class ... P >
91 inline
92 typename std::enable_if<
93 std::is_same< typename ViewTraits<T,P...>::specialize ,
94 Kokkos::Experimental::Impl::ViewPCEContiguous >::value &&
95 !std::is_same< typename Kokkos::ViewTraits<T,P...>::array_layout,
96 Kokkos::LayoutStride >::value,
97 typename Kokkos::View<T,P...>::HostMirror>::type
98 create_mirror(Kokkos::Impl::WithoutInitializing_t wi,
99 const Kokkos::View<T,P...> & src);
100
101 template< class T , class ... P >
102 inline
103 typename std::enable_if<
104 std::is_same< typename ViewTraits<T,P...>::specialize ,
105 Kokkos::Experimental::Impl::ViewPCEContiguous >::value &&
106 std::is_same< typename Kokkos::ViewTraits<T,P...>::array_layout,
107 Kokkos::LayoutStride >::value,
108 typename Kokkos::View<T,P...>::HostMirror>::type
109 create_mirror(Kokkos::Impl::WithoutInitializing_t wi,
110 const Kokkos::View<T,P...> & src);
111
112 template<class Space, class T, class ... P,
113 typename Enable = std::enable_if_t<Kokkos::is_space<Space>::value>>
114 typename std::enable_if<
115 std::is_same< typename ViewTraits<T,P...>::specialize ,
116 Kokkos::Experimental::Impl::ViewPCEContiguous >::value,
117 typename Impl::MirrorViewType<Space,T,P ...>::dest_view_type>::type
118 create_mirror(Kokkos::Impl::WithoutInitializing_t wi,
119 const Space&, const Kokkos::View<T,P...> & src);
120
121 template <class Space, class T, class... P>
122 typename Impl::MirrorViewType<Space, T, P...>::view_type
123 create_mirror_view_and_copy(
124 const Space&, const Kokkos::View<T, P...>& src,
125 std::string const& name = "",
126 typename std::enable_if<
127 std::is_same<typename ViewTraits<T, P...>::specialize,
128 Kokkos::Experimental::Impl::ViewPCEContiguous>::value &&
129 Impl::MirrorViewType<Space, T, P...>::is_same_memspace>::type* =
130 nullptr);
131
132 template <class Space, class T, class... P>
133 typename Impl::MirrorViewType<Space, T, P...>::view_type
134 create_mirror_view_and_copy(
135 const Space&, const Kokkos::View<T, P...>& src,
136 std::string const& name = "",
137 typename std::enable_if<
138 std::is_same<typename ViewTraits<T, P...>::specialize,
139 Kokkos::Experimental::Impl::ViewPCEContiguous>::value &&
140 !Impl::MirrorViewType<Space, T, P...>::is_same_memspace>::type* =
141 nullptr);
142
143 // Overload of deep_copy for UQ::PCE views intializing to a constant scalar
144 template< class DT, class ... DP >
145 void deep_copy(
146 const View<DT,DP...> & view ,
147 const typename View<DT,DP...>::array_type::value_type & value
148 , typename std::enable_if<(
149 std::is_same< typename ViewTraits<DT,DP...>::specialize
150 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
151 )>::type * = 0 );
152
153 // Overload of deep_copy for UQ::PCE views intializing to a constant UQ::PCE
154 template< class DT, class ... DP >
155 void deep_copy(
156 const View<DT,DP...> & view ,
157 const typename View<DT,DP...>::value_type & value
158 , typename std::enable_if<(
159 std::is_same< typename ViewTraits<DT,DP...>::specialize
160 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
161 )>::type * = 0 );
162
163 // Overload of deep_copy for UQ::PCE views intializing to a constant scalar
164 template< class ExecSpace , class DT, class ... DP >
165 void deep_copy(
166 const ExecSpace &,
167 const View<DT,DP...> & view ,
168 const typename View<DT,DP...>::array_type::value_type & value
169 , typename std::enable_if<(
170 Kokkos::is_execution_space< ExecSpace >::value &&
171 std::is_same< typename ViewTraits<DT,DP...>::specialize
172 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
173 )>::type * = 0 );
174
175 // Overload of deep_copy for UQ::PCE views intializing to a constant UQ::PCE
176 template< class ExecSpace , class DT, class ... DP >
177 void deep_copy(
178 const ExecSpace &,
179 const View<DT,DP...> & view ,
180 const typename View<DT,DP...>::value_type & value
181 , typename std::enable_if<(
182 Kokkos::is_execution_space< ExecSpace >::value &&
183 std::is_same< typename ViewTraits<DT,DP...>::specialize
184 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
185 )>::type * = 0 );
186
187 /* Specialize for deep copy of UQ::PCE */
188 template< class DT , class ... DP , class ST , class ... SP >
189 inline
190 void deep_copy( const View<DT,DP...> & dst ,
191 const View<ST,SP...> & src
192 , typename std::enable_if<(
193 std::is_same< typename ViewTraits<DT,DP...>::specialize
194 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
195 &&
196 std::is_same< typename ViewTraits<ST,SP...>::specialize
197 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
198 )>::type * = 0 );
199
200 /* Specialize for deep copy of UQ::PCE */
201 template< class ExecSpace, class DT , class ... DP , class ST , class ... SP >
202 inline
203 void deep_copy( const ExecSpace &,
204 const View<DT,DP...> & dst ,
205 const View<ST,SP...> & src
206 , typename std::enable_if<(
207 std::is_same< typename ViewTraits<DT,DP...>::specialize
208 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
209 &&
210 std::is_same< typename ViewTraits<ST,SP...>::specialize
211 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
212 )>::type * = 0 );
213
214 namespace Impl {
215
216 template <unsigned N, typename... Args>
217 KOKKOS_FUNCTION std::enable_if_t<
218 N == View<Args...>::rank &&
219 std::is_same<typename ViewTraits<Args...>::specialize,
220 Kokkos::Experimental::Impl::ViewPCEContiguous>::value,
221 View<Args...>>
222 as_view_of_rank_n(View<Args...> v);
223
224 // Placeholder implementation to compile generic code for DynRankView; should
225 // never be called
226 template <unsigned N, typename T, typename... Args>
227 std::enable_if_t<
228 N != View<T, Args...>::rank &&
229 std::is_same<typename ViewTraits<T, Args...>::specialize,
230 Kokkos::Experimental::Impl::ViewPCEContiguous>::value,
231 View<typename RankDataType<typename View<T, Args...>::value_type, N>::type,
232 Args...>>
233 as_view_of_rank_n(View<T, Args...>);
234
235 }
236
237 } // namespace Kokkos
238
239 #endif /* #ifndef KOKKOS_VIEW_UQ_PCE_FWD_HPP */