This repository has been archived by the owner on Apr 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Kokkos::subview
Christian Trott edited this page Sep 14, 2020
·
3 revisions
Header File: Kokkos_Core.hpp
Usage:
auto s = subview(view,std::pair<int,int>(5,191),Kokkos::ALL,1);
Creates a Kokkos::View
viewing a subset of another Kokkos::View
.
template <class ViewType, class... Args>
IMPL_DETAIL subview(const ViewType& v, Args ... args);
-
template <class ViewType, class... Args> IMPL_DETAIL subview(const ViewType& v, Args ... args);
Returns a new
Kokkos::View
s
viewing a subset ofv
specified byargs...
. The return type of subview is an implementation detail and is determined by the types inArgs...
.Subset selection:
- For every integer argument in
args...
the rank of the returned view is one smaller than the rank ofv
and the values referenced bys
correspond to the values associated with using the integer argument in the corresponding position during indexing intov
. - Passing
Kokkos::ALL
as ther
th argument is equivalent to passingpair<ptrdiff_t,ptrdiff_t>(0,v.extent(r))
as ther
th argument. - If the
r
th argumentarg_r
is thed
th range (std::pair
,Kokkos::pair
orKokkos::ALL
) in the argument list thans.extent(d) = arg_r.second-arg_r.first
, and dimensiond
ofs
references the range[arg_r.first,arg_r.second)
of dimensionr
ofv
.
Restrictions:
-
sizeof...(args)
is equal toViewType::rank
. - Valid arguments are of type:
-
std::pair<iType,iType>
withstd::is_integral<iType>::value
being true. -
Kokkos::pair<iType,iType>
withstd::is_integral<iType>::value
being true. -
iType
withstd::is_integral<iType>::value
being true. decltype(Kokkos::ALL)
-
- If the
r
th argumentarg_r
is of typestd::pair<iType,iType>
orKokkos::pair<iType,iType>
it must meet:arg_r.first >= 0
arg_r.second <= v.extent(r)
arg_r.first <= arg_r.second
- If the
r
th argumentarg_r
is an integral it must meet:arg_r >= 0
arg_r < v.extent(r)
- For every integer argument in
Kokkos::View<double***[5]> a("A",N0,N1,N2);
auto s = Kokkos::subview(a,
std::pair<int,int>(3,15),
5,
Kokkos::ALL,
Kokkos::ALL);
for(int i0 = 0; i0 < s.extent(0); i0++)
for(int i1 = 0; i1 < s.extent(1); i1++)
for(int i2 = 0; i2 < s.extent(2); i2++) {
assert(s(i0,i1,i2) == a(i0+3,5,i1,i2));
}
auto s3415 = Kokkos::subview(a,3,4,1,5);
assert(s3415() == a(3,4,1,5));
Home:
- Introduction
- Machine Model
- Programming Model
- Compiling
- Initialization
- View
- Parallel Dispatch
- Hierarchical Parallelism
- Custom Reductions
- Atomic Operations
- Subviews
- Interoperability
- Kokkos and Virtual Functions
- Initialization and Finalization
- View
- Data Parallelism
- Execution Policies
- Spaces
- Task Parallelism
- Utilities
- STL Compatibility
- Numerics
- Detection Idiom