Skip to content

Commit f1f907a

Browse files
authored
[SYCL] Implement missing accessor functions (#6781)
E2E tests: intel/llvm-test-suite#1265
1 parent 5b9fd3c commit f1f907a

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

sycl/include/sycl/accessor.hpp

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,7 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
11481148
using value_type = DataT;
11491149
using reference = DataT &;
11501150
using const_reference = const DataT &;
1151+
using difference_type = size_t;
11511152

11521153
// The list of accessor constructors with their arguments
11531154
// -------+---------+-------+----+-----+--------------
@@ -1863,6 +1864,8 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
18631864
#endif
18641865
}
18651866

1867+
void swap(accessor &other) { std::swap(impl, other.impl); }
1868+
18661869
constexpr bool is_placeholder() const { return IsPlaceH; }
18671870

18681871
size_t get_size() const { return getAccessRange().size() * sizeof(DataT); }
@@ -1871,6 +1874,14 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
18711874
size_t get_count() const { return size(); }
18721875
size_t size() const noexcept { return getAccessRange().size(); }
18731876

1877+
size_t byte_size() const noexcept { return size() * sizeof(DataT); }
1878+
1879+
size_t max_size() const noexcept {
1880+
return std::numeric_limits<difference_type>::max();
1881+
}
1882+
1883+
bool empty() const noexcept { return size() == 0; }
1884+
18741885
template <int Dims = Dimensions, typename = detail::enable_if_t<(Dims > 0)>>
18751886
range<Dimensions> get_range() const {
18761887
return detail::convertToArrayOfN<Dimensions, 1>(getAccessRange());
@@ -2529,12 +2540,6 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(local_accessor) local_accessor
25292540
// Use base classes constructors
25302541
using local_acc::local_acc;
25312542

2532-
using value_type = DataT;
2533-
using iterator = value_type *;
2534-
using const_iterator = const value_type *;
2535-
using reverse_iterator = std::reverse_iterator<iterator>;
2536-
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
2537-
25382543
#ifdef __SYCL_DEVICE_ONLY__
25392544

25402545
// __init needs to be defined within the class not through inheritance.
@@ -2556,6 +2561,24 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(local_accessor) local_accessor
25562561
#endif
25572562

25582563
public:
2564+
using value_type = DataT;
2565+
using iterator = value_type *;
2566+
using const_iterator = const value_type *;
2567+
using reverse_iterator = std::reverse_iterator<iterator>;
2568+
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
2569+
using difference_type =
2570+
typename std::iterator_traits<iterator>::difference_type;
2571+
2572+
void swap(local_accessor &other) { std::swap(this->impl, other.impl); }
2573+
2574+
size_t byte_size() const noexcept { return this->size() * sizeof(DataT); }
2575+
2576+
size_t max_size() const noexcept {
2577+
return std::numeric_limits<difference_type>::max();
2578+
}
2579+
2580+
bool empty() const noexcept { return this->size() == 0; }
2581+
25592582
iterator begin() const noexcept {
25602583
return &this->operator[](id<Dimensions>());
25612584
}

0 commit comments

Comments
 (0)