10#ifndef TPETRA_DETAILS_DUALVIEWUTIL_HPP 
   11#define TPETRA_DETAILS_DUALVIEWUTIL_HPP 
   13#include "TpetraCore_config.h" 
   14#include "Kokkos_DualView.hpp" 
   15#include "Teuchos_ArrayView.hpp" 
   29auto view_alloc_no_init(
const std::string& label) -> 
decltype(Kokkos::view_alloc(label, Kokkos::WithoutInitializing));
 
   35template <
class ElementType, 
class DeviceType>
 
   37                                    const typename Kokkos::DualView<ElementType*, DeviceType>::t_host& 
hostView) {
 
   38  using execution_space = 
typename DeviceType::execution_space;
 
   39  using dual_view_type  = Kokkos::DualView<ElementType*, DeviceType>;
 
   41  if constexpr (Kokkos::SpaceAccessibility<Kokkos::HostSpace, typename DeviceType::memory_space>::accessible) {
 
   45    typename Kokkos::DualView<ElementType*, DeviceType>::t_dev 
devView;
 
   53    execution_space().fence();
 
 
   57template <
class ElementType, 
class DeviceType>
 
   58void makeDualViewFromArrayView(Kokkos::DualView<ElementType*, DeviceType>& 
dv,
 
   59                               const Teuchos::ArrayView<const ElementType>& 
av,
 
   60                               const std::string& label) {
 
   61  using execution_space      = 
typename DeviceType::execution_space;
 
   62  using dual_view_type       = Kokkos::DualView<ElementType*, DeviceType>;
 
   63  using host_view_type       = 
typename dual_view_type::t_host;
 
   66  const auto size        = 
av.size();
 
   76template <
class ElementType, 
class DeviceType>
 
   77void makeDualViewFromVector(Kokkos::DualView<ElementType*, DeviceType>& dv,
 
   78                            const std::vector<ElementType>& vec,
 
   79                            const std::string& label) {
 
   80  using dual_view_type       = Kokkos::DualView<ElementType*, DeviceType>;
 
   81  using execution_space      = 
typename DeviceType::execution_space;
 
   82  using host_view_type       = 
typename dual_view_type::t_host;
 
   83  using const_host_view_type = 
typename host_view_type::const_type;
 
   85  const auto size        = vec.size();
 
   86  const ElementType* ptr = (size == 0) ? 
nullptr : vec.data();
 
   87  const_host_view_type inView(ptr, size);
 
   90  Kokkos::deep_copy(execution_space(), hostView, inView);
 
   95template <
class ElementType, 
class DeviceType>
 
   96void printDualView(std::ostream& out,
 
   97                   const Kokkos::DualView<ElementType*, DeviceType>& dv,
 
   98                   const std::string& name) {
 
  100  const size_t size   = size_t(dv.extent(0));
 
  101  const auto hostView = dv.view_host();
 
  104  for (
size_t k = 0; k < size; ++k) {
 
  106    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.