Stokhos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Kokkos_View_MP_Vector_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_MP_VECTOR_FWD_HPP
43#define KOKKOS_VIEW_MP_VECTOR_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 MP {
64 template <typename Storage >
65 class Vector;
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>
75 struct MirrorViewType;
76 }
77
78}
79
80namespace Kokkos {
81namespace Experimental {
82namespace Impl {
83
84struct ViewMPVectorContiguous;
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>>
117typename 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
153 Kokkos::Impl::WithoutInitializing_t wi,
154 const Space&,
155 const Kokkos::View<T,P...> & src);
156
157template <class Space, class T, class... P>
158typename Impl::MirrorViewType<Space, T, P...>::view_type
160 const Space&, const Kokkos::View<T, P...>& src,
161 std::string const& name = "",
162 typename std::enable_if<
163 std::is_same<typename ViewTraits<T, P...>::specialize,
165 Impl::MirrorViewType<Space, T, P...>::is_same_memspace>::type* =
166 nullptr);
167
168template <class Space, class T, class... P>
169typename Impl::MirrorViewType<Space, T, P...>::view_type
171 const Space&, const Kokkos::View<T, P...>& src,
172 std::string const& name = "",
173 typename std::enable_if<
174 std::is_same<typename ViewTraits<T, P...>::specialize,
176 !Impl::MirrorViewType<Space, T, P...>::is_same_memspace>::type* =
177 nullptr);
178
179// Overload of deep_copy for MP::Vector views intializing to a constant scalar
180template< class DT, class ... DP >
181void deep_copy(
182 const View<DT,DP...> & view ,
183 const typename View<DT,DP...>::array_type::value_type & value
184 , typename std::enable_if<(
185 std::is_same< typename ViewTraits<DT,DP...>::specialize
187 )>::type * = 0 );
188
189// Overload of deep_copy for MP::Vector views intializing to a constant MP::Vector
190template< class DT, class ... DP >
191void deep_copy(
192 const View<DT,DP...> & view ,
193 const typename View<DT,DP...>::value_type & value
194 , typename std::enable_if<(
195 std::is_same< typename ViewTraits<DT,DP...>::specialize
197 )>::type * = 0 );
198
199// Overload of deep_copy for MP::Vector views intializing to a constant scalar
200template< class ExecSpace , class DT, class ... DP >
201void deep_copy(
202 const ExecSpace &,
203 const View<DT,DP...> & view ,
204 const typename View<DT,DP...>::array_type::value_type & value
205 , typename std::enable_if<(
206 Kokkos::is_execution_space< ExecSpace >::value &&
207 std::is_same< typename ViewTraits<DT,DP...>::specialize
209 )>::type * = 0 );
210
211// Overload of deep_copy for MP::Vector views intializing to a constant MP::Vector
212template< class ExecSpace , class DT, class ... DP >
213void deep_copy(
214 const ExecSpace &,
215 const View<DT,DP...> & view ,
216 const typename View<DT,DP...>::value_type & value
217 , typename std::enable_if<(
218 Kokkos::is_execution_space< ExecSpace >::value &&
219 std::is_same< typename ViewTraits<DT,DP...>::specialize
221 )>::type * = 0 );
222
223/* Specialize for deep copy of MP::Vector */
224template< class DT , class ... DP , class ST , class ... SP >
225inline
226void deep_copy( const View<DT,DP...> & dst ,
227 const View<ST,SP...> & src
228 , typename std::enable_if<(
229 std::is_same< typename ViewTraits<DT,DP...>::specialize
231 &&
232 std::is_same< typename ViewTraits<ST,SP...>::specialize
234 )>::type * = 0 );
235
236/* Specialize for deep copy of MP::Vector */
237template< class ExecSpace, class DT , class ... DP , class ST , class ... SP >
238inline
239void deep_copy( const ExecSpace &,
240 const View<DT,DP...> & dst ,
241 const View<ST,SP...> & src
242 , typename std::enable_if<(
243 std::is_same< typename ViewTraits<DT,DP...>::specialize
245 &&
246 std::is_same< typename ViewTraits<ST,SP...>::specialize
248 )>::type * = 0 );
249
250namespace Impl {
251
252template <unsigned N, typename... Args>
253KOKKOS_FUNCTION std::enable_if_t<
254 N == View<Args...>::Rank &&
255 std::is_same<typename ViewTraits<Args...>::specialize,
257 View<Args...>>
258as_view_of_rank_n(View<Args...> v);
259
260// Placeholder implementation to compile generic code for DynRankView; should
261// never be called
262template <unsigned N, typename T, typename... Args>
263std::enable_if_t<
264 N != View<T, Args...>::Rank &&
265 std::is_same<typename ViewTraits<T, Args...>::specialize,
267 View<typename RankDataType<typename View<T, Args...>::value_type, N>::type,
268 Args...>>
269as_view_of_rank_n(View<T, Args...>);
270
271}
272
273} // namespace Kokkos
274
275#endif /* #ifndef KOKKOS_VIEW_MP_VECTOR_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)