Skip to content

Commit

Permalink
[SYCL] Implement missing accessor functions (#6781)
Browse files Browse the repository at this point in the history
  • Loading branch information
KornevNikita authored Sep 22, 2022
1 parent 5b9fd3c commit f1f907a
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions sycl/include/sycl/accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
// -------+---------+-------+----+-----+--------------
Expand Down Expand Up @@ -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); }
Expand All @@ -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<difference_type>::max();
}

bool empty() const noexcept { return size() == 0; }

template <int Dims = Dimensions, typename = detail::enable_if_t<(Dims > 0)>>
range<Dimensions> get_range() const {
return detail::convertToArrayOfN<Dimensions, 1>(getAccessRange());
Expand Down Expand Up @@ -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<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;

#ifdef __SYCL_DEVICE_ONLY__

// __init needs to be defined within the class not through inheritance.
Expand All @@ -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<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
using difference_type =
typename std::iterator_traits<iterator>::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<difference_type>::max();
}

bool empty() const noexcept { return this->size() == 0; }

iterator begin() const noexcept {
return &this->operator[](id<Dimensions>());
}
Expand Down

0 comments on commit f1f907a

Please sign in to comment.