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) {
48 return output_view_type(x_raw, x_len);
52template <
class ST,
class DT>
53struct Get1DConstViewOfUnmanagedHostArray<ST, DT, false> {
54 typedef Kokkos::View<const ST*, Kokkos::HostSpace, Kokkos::MemoryUnmanaged> input_view_type;
55 typedef Kokkos::View<const ST*, DT> output_view_type;
57 static output_view_type
58 getView(
const char label[],
const ST* x_raw,
const size_t x_len) {
59 input_view_type x_in(x_raw, x_len);
66 Kokkos::View<ST*, DT> x_out(std::string(label), x_len);
68 Kokkos::deep_copy(x_out, x_in);
73template <
class ST,
class DT>
74typename Get1DConstViewOfUnmanagedHostArray<ST, DT>::output_view_type
75get1DConstViewOfUnmanagedHostArray(
const char label[],
const ST* x_raw,
const size_t x_len) {
76 return Get1DConstViewOfUnmanagedHostArray<ST, DT>::getView(label, x_raw, x_len);
Stand-alone utility functions and macros.
Implementation details of Tpetra.
Namespace Tpetra contains the class and methods constituting the Tpetra library.