Skip to content

[SYCL] Add size_type, to accessor and local_accessor classes. #8379

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 20 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2503a62
Diagnostic for const qualified DataT with non read-only accessor
mmoadeli Jan 31, 2023
862b688
Merge branch 'sycl' of https://github.com/mmoadeli/llvm into sycl
mmoadeli Jan 31, 2023
1edb94f
Add test for const qualified DataT with non readonly accessor.
mmoadeli Jan 31, 2023
7ba64c6
Assign valid access mode for local accessor, depending on the type of…
mmoadeli Feb 1, 2023
ef0038e
Minor test update.
mmoadeli Feb 1, 2023
36971f8
- Rename AccessMode to AccessModeFromConstness
mmoadeli Feb 2, 2023
29e3036
- Revert test to be without -Xclang -verify.
mmoadeli Feb 2, 2023
92debe8
Refactors implementation of diagnostic to avoid compiler errors due t…
mmoadeli Feb 3, 2023
7eac372
Updates the test to use -Xclang -verify
mmoadeli Feb 3, 2023
dcac706
Fix style-checl
mmoadeli Feb 3, 2023
9d4b313
Merge branch 'intel:sycl' into sycl
mmoadeli Feb 6, 2023
ad92330
Merge branch 'intel:sycl' into sycl
mmoadeli Feb 7, 2023
45edd05
Add size_type in host_accessor.
mmoadeli Feb 16, 2023
8e52469
Add value_type, reference and const_reference to host_accessor.
mmoadeli Feb 16, 2023
c7d3887
Add size_type to accessor and local_accessor classes.
mmoadeli Feb 16, 2023
7030585
Replace size_type with size_t according to specification.
mmoadeli Feb 16, 2023
45825d8
Add test for checking size_type in accessors.
mmoadeli Feb 18, 2023
ee42a0a
Remove newly defined aliases from the host_accessor as they are alrea…
mmoadeli Feb 20, 2023
635012b
Remove the need to run the test.
mmoadeli Feb 21, 2023
f78a556
Re-define size_type using std::size_t.
mmoadeli Mar 7, 2023
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
12 changes: 7 additions & 5 deletions sycl/include/sycl/accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
using difference_type =
typename std::iterator_traits<iterator>::difference_type;
using size_type = std::size_t;

// The list of accessor constructors with their arguments
// -------+---------+-------+----+-----+--------------
Expand Down Expand Up @@ -1980,11 +1981,11 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :

__SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead")
size_t get_count() const { return size(); }
size_t size() const noexcept { return getAccessRange().size(); }
size_type size() const noexcept { return getAccessRange().size(); }

size_t byte_size() const noexcept { return size() * sizeof(DataT); }
size_type byte_size() const noexcept { return size() * sizeof(DataT); }

size_t max_size() const noexcept {
size_type max_size() const noexcept {
return empty() ? 0 : (std::numeric_limits<difference_type>::max)();
}

Expand Down Expand Up @@ -2733,15 +2734,16 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(local_accessor) local_accessor
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
using difference_type =
typename std::iterator_traits<iterator>::difference_type;
using size_type = std::size_t;

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

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

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

size_t max_size() const noexcept {
size_type max_size() const noexcept {
return empty() ? 0 : (std::numeric_limits<difference_type>::max)();
}

Expand Down
14 changes: 14 additions & 0 deletions sycl/test/basic_tests/accessor/accessor_size_type.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -fsyntax-only

#include <sycl/sycl.hpp>
#include <type_traits>

int main() {
using accessor_size_type = sycl::accessor<int, 3>::size_type;
using local_accessor_size_type = sycl::local_accessor<int, 3>::size_type;
using host_accessor_size_type = sycl::host_accessor<int, 3>::size_type;

static_assert(std::is_same_v<accessor_size_type, std::size_t>);
static_assert(std::is_same_v<local_accessor_size_type, std::size_t>);
static_assert(std::is_same_v<host_accessor_size_type, std::size_t>);
}