10#ifndef TPETRA_DETAILS_GET1DCONSTVIEW_HPP
11#define TPETRA_DETAILS_GET1DCONSTVIEW_HPP
18#include "Tpetra_ConfigDefs.hpp"
20#include "Kokkos_DualView.hpp"
21#include <Teuchos_Array.hpp>
35template<
class ST,
class DT,
36 const bool outputIsHostMemory =
37 std::is_same<typename DT::memory_space, Kokkos::HostSpace>::value>
38struct Get1DConstViewOfUnmanagedHostArray {};
40template<
class ST,
class DT>
41struct Get1DConstViewOfUnmanagedHostArray<ST, DT, true> {
42 typedef Kokkos::View<const ST*, Kokkos::HostSpace, Kokkos::MemoryUnmanaged> output_view_type;
44 static output_view_type
45 getView (
const char [],
const ST* x_raw,
const size_t x_len)
49 return output_view_type (x_raw, x_len);
53template<
class ST,
class DT>
54struct Get1DConstViewOfUnmanagedHostArray<ST, DT, false> {
55 typedef Kokkos::View<const ST*, Kokkos::HostSpace, Kokkos::MemoryUnmanaged> input_view_type;
56 typedef Kokkos::View<const ST*, DT> output_view_type;
58 static output_view_type
59 getView (
const char label[],
const ST* x_raw,
const size_t x_len)
61 input_view_type x_in (x_raw, x_len);
68 Kokkos::View<ST*, DT> x_out (std::string (label), x_len);
70 Kokkos::deep_copy (x_out, x_in);
75template<
class ST,
class DT>
76 typename Get1DConstViewOfUnmanagedHostArray<ST, DT>::output_view_type
77get1DConstViewOfUnmanagedHostArray (
const char label[],
const ST* x_raw,
const size_t x_len)
79 return Get1DConstViewOfUnmanagedHostArray<ST, DT>::getView (label, x_raw, x_len);
Stand-alone utility functions and macros.
Nonmember function that computes a residual Computes R = B - A * X.
Namespace Tpetra contains the class and methods constituting the Tpetra library.