From f1f907a2a84f508de3ec21fb2b9afc15eb71afea Mon Sep 17 00:00:00 2001 From: Nikita Date: Thu, 22 Sep 2022 20:12:20 +0200 Subject: [PATCH] [SYCL] Implement missing accessor functions (#6781) E2E tests: intel/llvm-test-suite#1265 --- sycl/include/sycl/accessor.hpp | 35 ++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/sycl/include/sycl/accessor.hpp b/sycl/include/sycl/accessor.hpp index 9e05e48f20080..7cbcbb0773ef9 100644 --- a/sycl/include/sycl/accessor.hpp +++ b/sycl/include/sycl/accessor.hpp @@ -1148,6 +1148,7 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : using value_type = DataT; using reference = DataT &; using const_reference = const DataT &; + using difference_type = size_t; // The list of accessor constructors with their arguments // -------+---------+-------+----+-----+-------------- @@ -1863,6 +1864,8 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : #endif } + void swap(accessor &other) { std::swap(impl, other.impl); } + constexpr bool is_placeholder() const { return IsPlaceH; } size_t get_size() const { return getAccessRange().size() * sizeof(DataT); } @@ -1871,6 +1874,14 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : size_t get_count() const { return size(); } size_t size() const noexcept { return getAccessRange().size(); } + size_t byte_size() const noexcept { return size() * sizeof(DataT); } + + size_t max_size() const noexcept { + return std::numeric_limits::max(); + } + + bool empty() const noexcept { return size() == 0; } + template 0)>> range get_range() const { return detail::convertToArrayOfN(getAccessRange()); @@ -2529,12 +2540,6 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(local_accessor) local_accessor // Use base classes constructors using local_acc::local_acc; - using value_type = DataT; - using iterator = value_type *; - using const_iterator = const value_type *; - using reverse_iterator = std::reverse_iterator; - using const_reverse_iterator = std::reverse_iterator; - #ifdef __SYCL_DEVICE_ONLY__ // __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 #endif public: + using value_type = DataT; + using iterator = value_type *; + using const_iterator = const value_type *; + using reverse_iterator = std::reverse_iterator; + using const_reverse_iterator = std::reverse_iterator; + using difference_type = + typename std::iterator_traits::difference_type; + + void swap(local_accessor &other) { std::swap(this->impl, other.impl); } + + size_t byte_size() const noexcept { return this->size() * sizeof(DataT); } + + size_t max_size() const noexcept { + return std::numeric_limits::max(); + } + + bool empty() const noexcept { return this->size() == 0; } + iterator begin() const noexcept { return &this->operator[](id()); }