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
Iterators
Francesco Rizzi edited this page Feb 8, 2022
·
1 revision
Header File: Kokkos_Core.hpp
template <class DataType, class... Properties>
KOKKOS_INLINE_FUNCTION auto begin(const Kokkos::View<DataType, Properties...>& view); (1)
template <class DataType, class... Properties>
KOKKOS_INLINE_FUNCTION auto cbegin(const Kokkos::View<DataType, Properties...>& view); (2)
template <class DataType, class... Properties>
KOKKOS_INLINE_FUNCTION auto end(const Kokkos::View<DataType, Properties...>& view); (3)
template <class DataType, class... Properties>
KOKKOS_INLINE_FUNCTION auto cend(const Kokkos::View<DataType, Properties...>& view); (4)
- (1,2) return a Kokkos iterator to the beginning of
view
- (3,4) return a Kokkos iterator to the element past the end of
view
-
for performance reasons, these functions currently return a random access iterator
-
cbegin, cend
ensure that the dereferenced iterator is const-qualified. -
view
is taken asconst
because, within each function, we are not changing the view itself: the returned iterator operates on the view without changing its structure. -
dereferencing an iterator must be done within an execution space where
view
is accessible
-
view
: must be a rank-1 view withLayoutLeft
,LayoutRight
, orLayoutStride
namespace KE = Kokkos::Experimental;
using view_type = Kokkos::View<int*>;
view_type a("a", 15);
auto it = KE::begin(a);
// if dereferenced (within a proper execution space), can modify the content of `a`
auto itc = KE::cbegin(a);
// if dereferenced (within a proper execution space), can only read the content of `a`
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