-
Notifications
You must be signed in to change notification settings - Fork 745
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL] Adjust accessor::value_type in accordance with the spec (#7096)
`value_type` should be defined as `const DataT` for read-only accessors. This also makes `accessor::iterator` of a read-only accessor non-writeable as it should be in accordance with the spec.
- Loading branch information
1 parent
7a86aac
commit 227614c
Showing
2 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// RUN: %clangxx -fsycl -c %s | ||
// | ||
// Purpose of this test is to check that [accessor|host_accessor]::iterator and | ||
// ::const_iterator are aliased to the correct type. | ||
// FIXME: extend this test to also check ::reverse_iterator and | ||
// ::const_reverse_iterator | ||
#include <sycl/sycl.hpp> | ||
|
||
#include <type_traits> | ||
|
||
template <typename DataT, int Dimensions, sycl::access_mode AccessMode, | ||
sycl::target AccessTarget = sycl::target::device> | ||
void check_accessor() { | ||
using AccessorT = | ||
typename sycl::accessor<DataT, Dimensions, AccessMode, AccessTarget>; | ||
static_assert(std::is_same_v<sycl::detail::accessor_iterator< | ||
typename AccessorT::value_type, Dimensions>, | ||
typename AccessorT::iterator>); | ||
|
||
static_assert( | ||
std::is_same_v<sycl::detail::accessor_iterator< | ||
const typename AccessorT::value_type, Dimensions>, | ||
typename AccessorT::const_iterator>); | ||
} | ||
|
||
template <typename DataT, int Dimensions, sycl::access_mode AccessMode> | ||
void check_host_accessor() { | ||
using AccessorT = typename sycl::host_accessor<DataT, Dimensions, AccessMode>; | ||
static_assert(std::is_same_v<sycl::detail::accessor_iterator< | ||
typename AccessorT::value_type, Dimensions>, | ||
typename AccessorT::iterator>); | ||
|
||
static_assert( | ||
std::is_same_v<sycl::detail::accessor_iterator< | ||
const typename AccessorT::value_type, Dimensions>, | ||
typename AccessorT::const_iterator>); | ||
} | ||
|
||
struct user_defined_t { | ||
char c; | ||
float f; | ||
double d; | ||
sycl::vec<int, 3> v3; | ||
}; | ||
|
||
int main() { | ||
|
||
check_accessor<int, 1, sycl::access_mode::read>(); | ||
check_accessor<float, 2, sycl::access_mode::write>(); | ||
check_accessor<user_defined_t, 3, sycl::access_mode::read_write>(); | ||
|
||
check_host_accessor<user_defined_t, 1, sycl::access_mode::read>(); | ||
check_host_accessor<int, 2, sycl::access_mode::write>(); | ||
check_host_accessor<float, 3, sycl::access_mode::read_write>(); | ||
|
||
return 0; | ||
} |