Skip to content

Commit 33d88b0

Browse files
committed
Align size of spec_constant class between host and device
Added a padding field to device representation of spec_constant class in order to align its size with size of it on host. If sizes are not the same it could lead to memory corruptions in SYCL RT when it tries to access arguments of SYCL Kernel function.
1 parent 67836cc commit 33d88b0

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

sycl/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ if(SYCL_ENABLE_WERROR)
3939
endif()
4040
endif()
4141

42+
add_definitions(-g)
43+
4244
# Create a soft option for enabling or disabling the instrumentation
4345
# of the SYCL runtime and expect enabling
4446
option(SYCL_ENABLE_XPTI_TRACING "Enable tracing of SYCL constructs" OFF)

sycl/include/CL/sycl/ONEAPI/experimental/spec_constant.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ template <typename T, typename ID = T> class spec_constant {
4242
spec_constant(T Cst) : Val(Cst) {}
4343

4444
T Val;
45-
#endif
45+
#else
46+
char padding[sizeof(T)];
47+
#endif // __SYCL_DEVICE_ONLY__
4648
friend class cl::sycl::program;
4749

4850
public:

0 commit comments

Comments
 (0)