42 #ifndef TPETRA_DETAILS_GETENTRYONHOST_HPP
43 #define TPETRA_DETAILS_GETENTRYONHOST_HPP
51 #include "TpetraCore_config.h"
52 #include "Kokkos_Core.hpp"
58 template<
class ViewType,
59 class IndexType =
typename ViewType::size_type,
60 const bool isHostSpace =
61 std::is_same<
typename ViewType::memory_space,
62 Kokkos::HostSpace>::value>
63 struct GetEntryOnHost {
64 static typename ViewType::non_const_value_type
65 getEntryOnHost (
const ViewType& x,
69 template<
class ViewType,
71 struct GetEntryOnHost<ViewType, IndexType, true> {
72 static typename ViewType::non_const_value_type
73 getEntryOnHost (
const ViewType& x,
76 static_assert (ViewType::Rank == 1,
"x must be a rank-1 Kokkos::View.");
81 template<
class ViewType,
83 struct GetEntryOnHost<ViewType, IndexType, false> {
84 static typename ViewType::non_const_value_type
85 getEntryOnHost (
const ViewType& x,
91 static_assert (ViewType::Rank == 1,
"x must be a rank-1 Kokkos::View.");
92 #ifdef KOKKOS_ENABLE_CUDA
95 typedef typename ViewType::device_type device_type;
97 typedef typename device_type::execution_space dev_exec_space;
98 #endif // KOKKOS_ENABLE_CUDA
99 typedef typename ViewType::HostMirror::execution_space host_exec_space;
100 typedef Kokkos::Device<host_exec_space, Kokkos::HostSpace> host_device_type;
101 typedef typename ViewType::non_const_value_type value_type;
104 Kokkos::View<value_type, host_device_type> view_h (&val);
105 auto view_d = Kokkos::subview (x, ind);
106 #ifdef KOKKOS_ENABLE_CUDA
107 typedef typename device_type::memory_space dev_memory_space;
108 if (std::is_same<dev_memory_space, Kokkos::CudaUVMSpace>::value) {
109 dev_exec_space::fence ();
111 #endif // KOKKOS_ENABLE_CUDA
113 #ifdef KOKKOS_ENABLE_CUDA
114 if (std::is_same<dev_memory_space, Kokkos::CudaUVMSpace>::value) {
115 dev_exec_space::fence ();
117 #endif // KOKKOS_ENABLE_CUDA
124 template<
class ViewType,
126 typename ViewType::non_const_value_type
127 getEntryOnHost (
const ViewType& x,
130 return Impl::GetEntryOnHost<ViewType, IndexType>::getEntryOnHost (x, ind);
136 #endif // TPETRA_DETAILS_GETENTRYONHOST_HPP
void deep_copy(MultiVector< DS, DL, DG, DN > &dst, const MultiVector< SS, SL, SG, SN > &src)
Copy the contents of the MultiVector src into dst.