Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Kokkos_View_MP_Vector_Fwd.hpp
Go to the documentation of this file.
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_MP_VECTOR_FWD_HPP
11 #define KOKKOS_VIEW_MP_VECTOR_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 MP {
32  template <typename Storage >
33  class Vector;
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 ViewMPVectorContiguous;
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, class... ViewCtorArgs>
62 inline auto create_mirror(
63  const Impl::ViewCtorProp<ViewCtorArgs...>& arg_prop,
64  const View<T, P...>& src,
65  typename std::enable_if_t<
66  std::is_same_v<typename ViewTraits<T, P...>::specialize,
67  Experimental::Impl::ViewMPVectorContiguous>>* = nullptr
68 );
69 
70 template <class T, class... P>
71 inline auto create_mirror(
72  const View<T, P...>& src,
73  typename std::enable_if_t<
74  std::is_same_v<typename ViewTraits<T, P...>::specialize,
75  Experimental::Impl::ViewMPVectorContiguous>>* = nullptr
76 );
77 
78 template <class Space, class T, class... P, typename Enable = std::enable_if_t<Kokkos::is_space<Space>::value>>
79 inline auto create_mirror(
80  const Space& space,
81  const View<T, P...>& src,
82  typename std::enable_if_t<
83  std::is_same_v<typename ViewTraits<T, P...>::specialize,
84  Experimental::Impl::ViewMPVectorContiguous>>* = nullptr
85 );
86 
87 template <class T, class... P>
88 inline auto create_mirror(
89  Impl::WithoutInitializing_t wi,
90  const View<T, P...>& src,
91  typename std::enable_if_t<
92  std::is_same_v<typename ViewTraits<T, P...>::specialize,
93  Experimental::Impl::ViewMPVectorContiguous>>* = nullptr
94 );
95 
96 template <class Space, class T, class... P, typename Enable = std::enable_if_t<is_space<Space>::value>>
97 inline auto create_mirror(
98  Impl::WithoutInitializing_t wi,
99  const Space& space,
100  const View<T, P...>& src,
101  typename std::enable_if_t<
102  std::is_same_v<typename ViewTraits<T, P...>::specialize,
103  Experimental::Impl::ViewMPVectorContiguous>>* = nullptr
104 );
105 
106 template <class T, class... P, class... ViewCtorArgs>
107 inline auto create_mirror_view(
108  const Impl::ViewCtorProp<ViewCtorArgs...>& arg_prop,
109  const Kokkos::View<T, P...>& src,
110  typename std::enable_if_t<
111  std::is_same_v<typename ViewTraits<T, P...>::specialize,
112  Experimental::Impl::ViewMPVectorContiguous>>* = nullptr
113 );
114 
115 template <class Space, class T, class... P>
116 typename Impl::MirrorViewType<Space, T, P...>::view_type
118  const Space&, const Kokkos::View<T, P...>& src,
119  std::string const& name = "",
120  typename std::enable_if<
121  std::is_same<typename ViewTraits<T, P...>::specialize,
123  Impl::MirrorViewType<Space, T, P...>::is_same_memspace>::type* =
124  nullptr);
125 
126 template <class Space, class T, class... P>
127 typename Impl::MirrorViewType<Space, T, P...>::view_type
129  const Space&, const Kokkos::View<T, P...>& src,
130  std::string const& name = "",
131  typename std::enable_if<
132  std::is_same<typename ViewTraits<T, P...>::specialize,
134  !Impl::MirrorViewType<Space, T, P...>::is_same_memspace>::type* =
135  nullptr);
136 
137 // Overload of deep_copy for MP::Vector views intializing to a constant scalar
138 template< class DT, class ... DP >
139 void deep_copy(
140  const View<DT,DP...> & view ,
141  const typename View<DT,DP...>::array_type::value_type & value
142  , typename std::enable_if<(
143  std::is_same< typename ViewTraits<DT,DP...>::specialize
145  )>::type * = 0 );
146 
147 // Overload of deep_copy for MP::Vector views intializing to a constant MP::Vector
148 template< class DT, class ... DP >
149 void deep_copy(
150  const View<DT,DP...> & view ,
151  const typename View<DT,DP...>::value_type & value
152  , typename std::enable_if<(
153  std::is_same< typename ViewTraits<DT,DP...>::specialize
155  )>::type * = 0 );
156 
157 // Overload of deep_copy for MP::Vector views intializing to a constant scalar
158 template< class ExecSpace , class DT, class ... DP >
159 void deep_copy(
160  const ExecSpace &,
161  const View<DT,DP...> & view ,
162  const typename View<DT,DP...>::array_type::value_type & value
163  , typename std::enable_if<(
164  Kokkos::is_execution_space< ExecSpace >::value &&
165  std::is_same< typename ViewTraits<DT,DP...>::specialize
167  )>::type * = 0 );
168 
169 // Overload of deep_copy for MP::Vector views intializing to a constant MP::Vector
170 template< class ExecSpace , class DT, class ... DP >
171 void deep_copy(
172  const ExecSpace &,
173  const View<DT,DP...> & view ,
174  const typename View<DT,DP...>::value_type & value
175  , typename std::enable_if<(
176  Kokkos::is_execution_space< ExecSpace >::value &&
177  std::is_same< typename ViewTraits<DT,DP...>::specialize
179  )>::type * = 0 );
180 
181 /* Specialize for deep copy of MP::Vector */
182 template< class DT , class ... DP , class ST , class ... SP >
183 inline
184 void deep_copy( const View<DT,DP...> & dst ,
185  const View<ST,SP...> & src
186  , typename std::enable_if<(
187  std::is_same< typename ViewTraits<DT,DP...>::specialize
189  &&
190  std::is_same< typename ViewTraits<ST,SP...>::specialize
192  )>::type * = 0 );
193 
194 /* Specialize for deep copy of MP::Vector */
195 template< class ExecSpace, class DT , class ... DP , class ST , class ... SP >
196 inline
197 void deep_copy( const ExecSpace &,
198  const View<DT,DP...> & dst ,
199  const View<ST,SP...> & src
200  , typename std::enable_if<(
201  std::is_same< typename ViewTraits<DT,DP...>::specialize
203  &&
204  std::is_same< typename ViewTraits<ST,SP...>::specialize
206  )>::type * = 0 );
207 
208 namespace Impl {
209 
210 template <unsigned N, typename... Args>
211 KOKKOS_FUNCTION std::enable_if_t<
212  N == View<Args...>::rank &&
213  std::is_same<typename ViewTraits<Args...>::specialize,
215  View<Args...>>
216 as_view_of_rank_n(View<Args...> v);
217 
218 // Placeholder implementation to compile generic code for DynRankView; should
219 // never be called
220 template <unsigned N, typename T, typename... Args>
221 std::enable_if_t<
222  N != View<T, Args...>::rank &&
223  std::is_same<typename ViewTraits<T, Args...>::specialize,
225  View<typename RankDataType<typename View<T, Args...>::value_type, N>::type,
226  Args...>>
227 as_view_of_rank_n(View<T, Args...>);
228 
229 }
230 
231 } // namespace Kokkos
232 
233 #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)
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)
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)
Stokhos::CrsMatrix< ValueType, Device, Layout >::HostMirror create_mirror_view(const Stokhos::CrsMatrix< ValueType, Device, Layout > &A)