kokkos-utils
0.0.5
Toggle main menu visibility
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
4
#include "
kokkos-utils/concepts/View.hpp
"
5
16
17
namespace
Kokkos::utils::view
18
{
19
20
namespace
impl
21
{
22
23
template
<
typename
ViewType,
typename
... Indices,
size_t
... AllsIndices>
24
KOKKOS_FUNCTION
25
constexpr
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
51
template
<
size_t
Rank,
typename
ViewType,
typename
... Indices>
52
requires
concepts::ViewOfRank<std::remove_reference_t<ViewType>
, Rank>
53
KOKKOS_FUNCTION
54
constexpr
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
65
template
<
typename
ViewType,
typename
... Indices>
66
requires
concepts::ViewOfRank<std::remove_reference_t<ViewType>
,
sizeof
...(Indices)>
67
KOKKOS_FUNCTION
68
constexpr
auto
slice
(ViewType&&
view
, Indices&&... indices)
69
{
70
return
slice<std::remove_reference_t<ViewType>::rank
()>(
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
Kokkos::utils::concepts::ViewOfRank
Specify that a type is a Kokkos::View of given rank Rank.
Definition
View.hpp:19
View.hpp
Kokkos::utils::view::impl
Definition
extents.hpp:17
Kokkos::utils::view::impl::slice
KOKKOS_FUNCTION constexpr auto slice(ViewType &&view, Indices &&... indices, std::index_sequence< AllsIndices... >)
Definition
slice.hpp:25
Kokkos::utils::view
Definition
extents.hpp:14
Kokkos::utils::view::slice
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
include
kokkos-utils
view
slice.hpp
Generated on
for kokkos-utils by
1.18.0