42#ifndef TPETRA_DETAILS_DUALVIEWUTIL_HPP
43#define TPETRA_DETAILS_DUALVIEWUTIL_HPP
45#include "TpetraCore_config.h"
46#include "Kokkos_DualView.hpp"
47#include "Teuchos_ArrayView.hpp"
62 decltype (Kokkos::view_alloc (label, Kokkos::WithoutInitializing));
68template<
class ElementType,
class DeviceType>
71 (Kokkos::DualView<ElementType*, DeviceType>&
dv,
72 const typename Kokkos::DualView<ElementType*, DeviceType>::t_host&
hostView)
74 using dual_view_type = Kokkos::DualView<ElementType*, DeviceType>;
78 dv.clear_sync_state ();
90template<
class ElementType,
class DeviceType>
92makeDualViewFromArrayView (Kokkos::DualView<ElementType*, DeviceType>&
dv,
93 const Teuchos::ArrayView<const ElementType>&
av,
94 const std::string&
label)
96 using dual_view_type = Kokkos::DualView<ElementType*, DeviceType>;
100 const auto size =
av.size ();
109template<
class ElementType,
class DeviceType>
111makeDualViewFromVector (Kokkos::DualView<ElementType*, DeviceType>& dv,
112 const std::vector<ElementType>& vec,
113 const std::string& label)
115 using dual_view_type = Kokkos::DualView<ElementType*, DeviceType>;
116 using host_view_type =
typename dual_view_type::t_host;
117 using const_host_view_type =
typename host_view_type::const_type;
119 const auto size = vec.size ();
120 const ElementType* ptr = (size == 0) ?
nullptr : vec.data ();
121 const_host_view_type inView (ptr, size);
123 Kokkos::deep_copy (hostView, inView);
128template<
class ElementType,
class DeviceType>
130printDualView (std::ostream& out,
131 const Kokkos::DualView<ElementType*, DeviceType>& dv,
132 const std::string& name)
135 const size_t size = size_t (dv.extent (0));
136 const auto hostView = dv.view_host ();
139 for (
size_t k = 0; k < size; ++k) {
141 if (k +
size_t (1) < size) {
Struct that holds views of the contents of a CrsMatrix.
Implementation details of Tpetra.
auto view_alloc_no_init(const std::string &label) -> decltype(Kokkos::view_alloc(label, Kokkos::WithoutInitializing))
Use in place of the string label as the first argument of Kokkos::View's constructor,...
void makeDualViewFromOwningHostView(Kokkos::DualView< ElementType *, DeviceType > &dv, const typename Kokkos::DualView< ElementType *, DeviceType >::t_host &hostView)
Initialize dv such that its host View is hostView.
Namespace Tpetra contains the class and methods constituting the Tpetra library.