Skip to content

[SYCL] Implement missing accessor functions #6781

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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