Skip to content

Commit 7e97d81

Browse files
dkhaldibader
authored andcommitted
[SYCL] Assert that constant memory is only used with read access mode
Signed-off-by: Dounia <dounia.khaldi@intel.com>
1 parent 60ec960 commit 7e97d81

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

sycl/include/CL/sycl/accessor.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,12 @@ class accessor :
651651
AccessTarget == access::target::host_buffer),
652652
"Expected buffer type");
653653

654+
static_assert((AccessTarget == access::target::global_buffer ||
655+
AccessTarget == access::target::host_buffer) ||
656+
(AccessTarget == access::target::constant_buffer &&
657+
AccessMode == access::mode::read),
658+
"Access mode can be only read for constant buffers");
659+
654660
using AccessorCommonT = detail::accessor_common<DataT, Dimensions, AccessMode,
655661
AccessTarget, IsPlaceholder>;
656662

sycl/test/multi_ptr/multi_ptr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void testMultPtrArrowOperator() {
115115
accessor<point<T>, 1, access::mode::read, access::target::global_buffer,
116116
access::placeholder::false_t>
117117
accessorData_1(bufferData_1, cgh);
118-
accessor<point<T>, 1, access::mode::read_write, access::target::constant_buffer,
118+
accessor<point<T>, 1, access::mode::read, access::target::constant_buffer,
119119
access::placeholder::false_t>
120120
accessorData_2(bufferData_2, cgh);
121121
accessor<point<T>, 1, access::mode::read_write, access::target::local,

0 commit comments

Comments
 (0)