8#ifndef PECLET_CORE_COMMON_VIEW_HPP
9#define PECLET_CORE_COMMON_VIEW_HPP
11#include <Kokkos_Core.hpp>
26using View = Kokkos::View<T*, MemSpace>;
40using Field3D = Kokkos::View<T***, Kokkos::LayoutLeft, MemSpace>;
45 View<T> d(Kokkos::view_alloc(label, Kokkos::WithoutInitializing),
h.size());
47 Kokkos::View<const T*, Kokkos::HostSpace, Kokkos::MemoryTraits<Kokkos::Unmanaged>>
hv(
h.data(),
49 Kokkos::deep_copy(d,
hv);
63std::vector<std::remove_const_t<typename V::value_type>>
toVector(
const V&
view) {
64 using T = std::remove_const_t<typename V::value_type>;
65 std::vector<T>
out(
view.size());
73 Kokkos::View<typename V::non_const_data_type, typename V::memory_space>
contig(
74 Kokkos::view_alloc(Kokkos::WithoutInitializing,
"peclet::core::toVector::contig"),
77 auto host = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),
contig);
78 Kokkos::LayoutRight
layout;
79 for (std::size_t
i = 0;
i < V::rank; ++
i)
81 Kokkos::View<
typename V::non_const_data_type, Kokkos::LayoutRight, Kokkos::HostSpace,
82 Kokkos::MemoryTraits<Kokkos::Unmanaged>>
decltype(Kokkos::create_mirror_view(std::declval< View< T > >())) HostView
Host-accessible mirror of View<T> (identical to View<T> on host backends).
View< T > toDevice(const std::vector< T > &h, const std::string &label)
Upload a host std::vector into a freshly-sized device View (empty vector => empty view).
ExecSpace::memory_space MemSpace
Kokkos::View< T *, MemSpace > View
1D device array.
Kokkos::DefaultExecutionSpace ExecSpace
Kokkos::View< Index *, MemSpace > IndexView
Device array of grid/particle indices (the matched send/recv/self-copy lists).
Kokkos::View< T ***, Kokkos::LayoutLeft, MemSpace > Field3D
3D structured field in the suite's x-fastest convention: LayoutLeft makes the leftmost (x) index cont...
std::vector< std::remove_const_t< typename V::value_type > > toVector(const V &view)
Copy a (host- or device-resident) Kokkos View of any rank into a contiguous host std::vector,...