|
11 | 11 | #include <CL/__spirv/spirv_types.hpp>
|
12 | 12 | #include <sycl/atomic.hpp>
|
13 | 13 | #include <sycl/buffer.hpp>
|
| 14 | +#include <sycl/detail/accessor_iterator.hpp> |
14 | 15 | #include <sycl/detail/cl.h>
|
15 | 16 | #include <sycl/detail/common.hpp>
|
16 | 17 | #include <sycl/detail/export.hpp>
|
|
30 | 31 | #include <sycl/property_list_conversion.hpp>
|
31 | 32 | #include <sycl/sampler.hpp>
|
32 | 33 |
|
| 34 | +#include <iterator> |
33 | 35 | #include <type_traits>
|
34 | 36 |
|
35 | 37 | #include <utility>
|
@@ -334,7 +336,7 @@ class accessor_common {
|
334 | 336 |
|
335 | 337 | public:
|
336 | 338 | AccessorSubscript(AccType Accessor, id<Dims> IDs)
|
337 |
| - : MAccessor(Accessor), MIDs(IDs) {} |
| 339 | + : MIDs(IDs), MAccessor(Accessor) {} |
338 | 340 |
|
339 | 341 | // Only accessor class is supposed to use this c'tor for the first
|
340 | 342 | // operator[].
|
@@ -1201,7 +1203,12 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
|
1201 | 1203 | using value_type = DataT;
|
1202 | 1204 | using reference = DataT &;
|
1203 | 1205 | using const_reference = const DataT &;
|
1204 |
| - using difference_type = size_t; |
| 1206 | + |
| 1207 | + using iterator = typename detail::accessor_iterator<DataT, Dimensions>; |
| 1208 | + using const_iterator = |
| 1209 | + typename detail::accessor_iterator<const DataT, Dimensions>; |
| 1210 | + using difference_type = |
| 1211 | + typename std::iterator_traits<iterator>::difference_type; |
1205 | 1212 |
|
1206 | 1213 | // The list of accessor constructors with their arguments
|
1207 | 1214 | // -------+---------+-------+----+-----+--------------
|
@@ -2100,6 +2107,34 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
|
2100 | 2107 | bool operator==(const accessor &Rhs) const { return impl == Rhs.impl; }
|
2101 | 2108 | bool operator!=(const accessor &Rhs) const { return !(*this == Rhs); }
|
2102 | 2109 |
|
| 2110 | + iterator begin() const noexcept { |
| 2111 | + return iterator::getBegin( |
| 2112 | + get_pointer(), |
| 2113 | + detail::convertToArrayOfN<Dimensions, 1>(getMemoryRange()), get_range(), |
| 2114 | + get_offset()); |
| 2115 | + } |
| 2116 | + |
| 2117 | + iterator end() const noexcept { |
| 2118 | + return iterator::getEnd( |
| 2119 | + get_pointer(), |
| 2120 | + detail::convertToArrayOfN<Dimensions, 1>(getMemoryRange()), get_range(), |
| 2121 | + get_offset()); |
| 2122 | + } |
| 2123 | + |
| 2124 | + const_iterator cbegin() const noexcept { |
| 2125 | + return const_iterator::getBegin( |
| 2126 | + get_pointer(), |
| 2127 | + detail::convertToArrayOfN<Dimensions, 1>(getMemoryRange()), get_range(), |
| 2128 | + get_offset()); |
| 2129 | + } |
| 2130 | + |
| 2131 | + const_iterator cend() const noexcept { |
| 2132 | + return const_iterator::getEnd( |
| 2133 | + get_pointer(), |
| 2134 | + detail::convertToArrayOfN<Dimensions, 1>(getMemoryRange()), get_range(), |
| 2135 | + get_offset()); |
| 2136 | + } |
| 2137 | + |
2103 | 2138 | private:
|
2104 | 2139 | #ifdef __SYCL_DEVICE_ONLY__
|
2105 | 2140 | size_t getTotalOffset() const {
|
|
0 commit comments