Skip to content

Commit 0a17e16

Browse files
authored
[SYCL] Add size_type to accessor and local_accessor classes. (#8379)
1 parent 77866ff commit 0a17e16

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

sycl/include/sycl/accessor.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
12451245
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
12461246
using difference_type =
12471247
typename std::iterator_traits<iterator>::difference_type;
1248+
using size_type = std::size_t;
12481249

12491250
// The list of accessor constructors with their arguments
12501251
// -------+---------+-------+----+-----+--------------
@@ -1972,11 +1973,11 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
19721973

19731974
__SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead")
19741975
size_t get_count() const { return size(); }
1975-
size_t size() const noexcept { return getAccessRange().size(); }
1976+
size_type size() const noexcept { return getAccessRange().size(); }
19761977

1977-
size_t byte_size() const noexcept { return size() * sizeof(DataT); }
1978+
size_type byte_size() const noexcept { return size() * sizeof(DataT); }
19781979

1979-
size_t max_size() const noexcept {
1980+
size_type max_size() const noexcept {
19801981
return empty() ? 0 : (std::numeric_limits<difference_type>::max)();
19811982
}
19821983

@@ -2746,15 +2747,16 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(local_accessor) local_accessor
27462747
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
27472748
using difference_type =
27482749
typename std::iterator_traits<iterator>::difference_type;
2750+
using size_type = std::size_t;
27492751

27502752
template <access::decorated IsDecorated>
27512753
using accessor_ptr = local_ptr<value_type, IsDecorated>;
27522754

27532755
void swap(local_accessor &other) { std::swap(this->impl, other.impl); }
27542756

2755-
size_t byte_size() const noexcept { return this->size() * sizeof(DataT); }
2757+
size_type byte_size() const noexcept { return this->size() * sizeof(DataT); }
27562758

2757-
size_t max_size() const noexcept {
2759+
size_type max_size() const noexcept {
27582760
return empty() ? 0 : (std::numeric_limits<difference_type>::max)();
27592761
}
27602762

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -fsyntax-only
2+
3+
#include <sycl/sycl.hpp>
4+
#include <type_traits>
5+
6+
int main() {
7+
using accessor_size_type = sycl::accessor<int, 3>::size_type;
8+
using local_accessor_size_type = sycl::local_accessor<int, 3>::size_type;
9+
using host_accessor_size_type = sycl::host_accessor<int, 3>::size_type;
10+
11+
static_assert(std::is_same_v<accessor_size_type, std::size_t>);
12+
static_assert(std::is_same_v<local_accessor_size_type, std::size_t>);
13+
static_assert(std::is_same_v<host_accessor_size_type, std::size_t>);
14+
}

0 commit comments

Comments
 (0)