kokkos-utils 0.0.1
 
Loading...
Searching...
No Matches
slice.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_UTILS_VIEW_SLICE_HPP
2#define KOKKOS_UTILS_VIEW_SLICE_HPP
3
5
16
17namespace Kokkos::utils::view
18{
19
20namespace impl
21{
22
23template <typename ViewType, typename... Indices, size_t... AllsIndices>
24KOKKOS_FUNCTION
25constexpr auto slice(ViewType&& view, Indices&&... indices, std::index_sequence<AllsIndices...>)
26{
27 return Kokkos::subview(
28 std::forward<ViewType>(view),
29 std::forward<Indices>(indices)...,
30 std::get<AllsIndices>(std::array<Kokkos::ALL_t, sizeof...(AllsIndices)>{})...
31 );
32}
33
34} // namespace impl
35
51template <size_t Rank, typename ViewType, typename... Indices>
53KOKKOS_FUNCTION
54constexpr auto slice(ViewType&& view, Indices&&... indices)
55{
56 constexpr auto size = Rank - sizeof...(Indices);
57 return impl::slice<ViewType, Indices...>(
58 std::forward<ViewType>(view),
59 std::forward<Indices>(indices)...,
60 std::make_index_sequence<size>{}
61 );
62}
63
65template <typename ViewType, typename... Indices>
67KOKKOS_FUNCTION
68constexpr auto slice(ViewType&& view, Indices&&... indices)
69{
71 std::forward<ViewType>(view),
72 std::forward<Indices>(indices)...
73 );
74}
75
76} // namespace Kokkos::utils::view
77
78#endif // KOKKOS_UTILS_VIEW_SLICE_HPP
Specify that a type is a Kokkos::View of given rank Rank.
Definition View.hpp:19
KOKKOS_FUNCTION constexpr auto slice(ViewType &&view, Indices &&... indices, std::index_sequence< AllsIndices... >)
Definition slice.hpp:25
KOKKOS_FUNCTION constexpr auto slice(ViewType &&view, Indices &&... indices)
Get a subview, given the first indices. The rest is filled with Kokkos::ALL.
Definition slice.hpp:54