Stokhos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Kokkos_View_UQ_PCE_Fwd.hpp
Go to the documentation of this file.
1// @HEADER
2// ***********************************************************************
3//
4// Stokhos Package
5// Copyright (2009) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
38//
39// ***********************************************************************
40// @HEADER
41
42#ifndef KOKKOS_VIEW_UQ_PCE_FWD_HPP
43#define KOKKOS_VIEW_UQ_PCE_FWD_HPP
44
45// We are hooking into Kokkos Core internals here
46// Need to define this macro since we include non-public headers
47#ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
48#define KOKKOS_IMPL_PUBLIC_INCLUDE
49#define KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE
50#endif
51// Only include forward declarations so any overloads appear before they
52// might be used inside Kokkos
53#include "Kokkos_Core_fwd.hpp"
54#include "Kokkos_View.hpp"
55#ifdef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE
56#undef KOKKOS_IMPL_PUBLIC_INCLUDE
57#undef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE
58#endif
59
60//----------------------------------------------------------------------------
61
62namespace Sacado {
63 namespace UQ {
64 template <typename Storage >
65 class PCE;
66 }
67}
68
69namespace Kokkos {
70
71 namespace Impl {
72 template<class Space, class T, class ... P>
73 struct MirrorType;
74 template<class Space, class T, class ... P>
76 }
77
78}
79
80namespace Kokkos {
81namespace Experimental {
82namespace Impl {
83
85
86} // namespace Impl
87} // namespace Experimental
88} // namespace Kokkos
89
90namespace Kokkos {
91
92// Declare overloads of create_mirror() so they are in scope
93// Kokkos_Core.hpp is included below
94
95template< class T , class ... P >
96inline
97typename std::enable_if<
98 std::is_same< typename ViewTraits<T,P...>::specialize ,
100 !std::is_same< typename Kokkos::ViewTraits<T,P...>::array_layout,
101 Kokkos::LayoutStride >::value,
102 typename Kokkos::View<T,P...>::HostMirror>::type
103create_mirror(const Kokkos::View<T,P...> & src);
104
105template< class T , class ... P >
106inline
107typename std::enable_if<
108 std::is_same< typename ViewTraits<T,P...>::specialize ,
110 std::is_same< typename Kokkos::ViewTraits<T,P...>::array_layout,
111 Kokkos::LayoutStride >::value,
112 typename Kokkos::View<T,P...>::HostMirror>::type
113create_mirror(const Kokkos::View<T,P...> & src);
114
115template<class Space, class T, class ... P,
116 typename Enable = std::enable_if_t<Kokkos::is_space<Space>::value>>
117 typename std::enable_if<
118 std::is_same< typename ViewTraits<T,P...>::specialize ,
120 typename Impl::MirrorType<Space,T,P ...>::view_type>::type
121create_mirror(const Space&,
122 const Kokkos::View<T,P...> & src);
123
124template< class T , class ... P >
125inline
126typename std::enable_if<
127 std::is_same< typename ViewTraits<T,P...>::specialize ,
129 !std::is_same< typename Kokkos::ViewTraits<T,P...>::array_layout,
130 Kokkos::LayoutStride >::value,
131 typename Kokkos::View<T,P...>::HostMirror>::type
132create_mirror(Kokkos::Impl::WithoutInitializing_t wi,
133 const Kokkos::View<T,P...> & src);
134
135template< class T , class ... P >
136inline
137typename std::enable_if<
138 std::is_same< typename ViewTraits<T,P...>::specialize ,
140 std::is_same< typename Kokkos::ViewTraits<T,P...>::array_layout,
141 Kokkos::LayoutStride >::value,
142 typename Kokkos::View<T,P...>::HostMirror>::type
143create_mirror(Kokkos::Impl::WithoutInitializing_t wi,
144 const Kokkos::View<T,P...> & src);
145
146template<class Space, class T, class ... P,
147 typename Enable = std::enable_if_t<Kokkos::is_space<Space>::value>>
148typename std::enable_if<
149 std::is_same< typename ViewTraits<T,P...>::specialize ,
151 typename Impl::MirrorType<Space,T,P ...>::view_type>::type
152create_mirror(Kokkos::Impl::WithoutInitializing_t wi,
153 const Space&, const Kokkos::View<T,P...> & src);
154
155template <class Space, class T, class... P>
156typename Impl::MirrorViewType<Space, T, P...>::view_type
158 const Space&, const Kokkos::View<T, P...>& src,
159 std::string const& name = "",
160 typename std::enable_if<
161 std::is_same<typename ViewTraits<T, P...>::specialize,
163 Impl::MirrorViewType<Space, T, P...>::is_same_memspace>::type* =
164 nullptr);
165
166template <class Space, class T, class... P>
167typename Impl::MirrorViewType<Space, T, P...>::view_type
169 const Space&, const Kokkos::View<T, P...>& src,
170 std::string const& name = "",
171 typename std::enable_if<
172 std::is_same<typename ViewTraits<T, P...>::specialize,
174 !Impl::MirrorViewType<Space, T, P...>::is_same_memspace>::type* =
175 nullptr);
176
177// Overload of deep_copy for UQ::PCE views intializing to a constant scalar
178template< class DT, class ... DP >
179void deep_copy(
180 const View<DT,DP...> & view ,
181 const typename View<DT,DP...>::array_type::value_type & value
182 , typename std::enable_if<(
183 std::is_same< typename ViewTraits<DT,DP...>::specialize
185 )>::type * = 0 );
186
187// Overload of deep_copy for UQ::PCE views intializing to a constant UQ::PCE
188template< class DT, class ... DP >
189void deep_copy(
190 const View<DT,DP...> & view ,
191 const typename View<DT,DP...>::value_type & value
192 , typename std::enable_if<(
193 std::is_same< typename ViewTraits<DT,DP...>::specialize
195 )>::type * = 0 );
196
197// Overload of deep_copy for UQ::PCE views intializing to a constant scalar
198template< class ExecSpace , class DT, class ... DP >
199void deep_copy(
200 const ExecSpace &,
201 const View<DT,DP...> & view ,
202 const typename View<DT,DP...>::array_type::value_type & value
203 , typename std::enable_if<(
204 Kokkos::is_execution_space< ExecSpace >::value &&
205 std::is_same< typename ViewTraits<DT,DP...>::specialize
207 )>::type * = 0 );
208
209// Overload of deep_copy for UQ::PCE views intializing to a constant UQ::PCE
210template< class ExecSpace , class DT, class ... DP >
211void deep_copy(
212 const ExecSpace &,
213 const View<DT,DP...> & view ,
214 const typename View<DT,DP...>::value_type & value
215 , typename std::enable_if<(
216 Kokkos::is_execution_space< ExecSpace >::value &&
217 std::is_same< typename ViewTraits<DT,DP...>::specialize
219 )>::type * = 0 );
220
221/* Specialize for deep copy of UQ::PCE */
222template< class DT , class ... DP , class ST , class ... SP >
223inline
224void deep_copy( const View<DT,DP...> & dst ,
225 const View<ST,SP...> & src
226 , typename std::enable_if<(
227 std::is_same< typename ViewTraits<DT,DP...>::specialize
229 &&
230 std::is_same< typename ViewTraits<ST,SP...>::specialize
232 )>::type * = 0 );
233
234/* Specialize for deep copy of UQ::PCE */
235template< class ExecSpace, class DT , class ... DP , class ST , class ... SP >
236inline
237void deep_copy( const ExecSpace &,
238 const View<DT,DP...> & dst ,
239 const View<ST,SP...> & src
240 , typename std::enable_if<(
241 std::is_same< typename ViewTraits<DT,DP...>::specialize
243 &&
244 std::is_same< typename ViewTraits<ST,SP...>::specialize
246 )>::type * = 0 );
247
248namespace Impl {
249
250template <unsigned N, typename... Args>
251KOKKOS_FUNCTION std::enable_if_t<
252 N == View<Args...>::Rank &&
253 std::is_same<typename ViewTraits<Args...>::specialize,
255 View<Args...>>
256as_view_of_rank_n(View<Args...> v);
257
258// Placeholder implementation to compile generic code for DynRankView; should
259// never be called
260template <unsigned N, typename T, typename... Args>
261std::enable_if_t<
262 N != View<T, Args...>::Rank &&
263 std::is_same<typename ViewTraits<T, Args...>::specialize,
265 View<typename RankDataType<typename View<T, Args...>::value_type, N>::type,
266 Args...>>
267as_view_of_rank_n(View<T, Args...>);
268
269}
270
271} // namespace Kokkos
272
273#endif /* #ifndef KOKKOS_VIEW_UQ_PCE_FWD_HPP */
KOKKOS_FUNCTION std::enable_if_t< N==View< Args... >::Rank &&std::is_same< typename ViewTraits< Args... >::specialize, Kokkos::Experimental::Impl::ViewPCEContiguous >::value, View< Args... > > as_view_of_rank_n(View< Args... > v)
void deep_copy(const Stokhos::CrsMatrix< ValueType, DstDevice, Layout > &dst, const Stokhos::CrsMatrix< ValueType, SrcDevice, Layout > &src)
Stokhos::CrsMatrix< ValueType, Device, Layout >::HostMirror create_mirror(const Stokhos::CrsMatrix< ValueType, Device, Layout > &A)
Impl::MirrorViewType< Space, T, P... >::view_type create_mirror_view_and_copy(const Space &, const Kokkos::View< T, P... > &src, std::string const &name="", typename std::enable_if< std::is_same< typename ViewTraits< T, P... >::specialize, Kokkos::Experimental::Impl::ViewPCEContiguous >::value &&Impl::MirrorViewType< Space, T, P... >::is_same_memspace >::type *=nullptr)