Skip to content

Commit

Permalink
Waiver on manifestly constant-evaluation in kernel code
Browse files Browse the repository at this point in the history
In the case of a manifestly constant-evaluated expression or
conversion, any code accepted by the C++ standard in this case is also
accepted in SYCL device function.
  • Loading branch information
keryell committed May 17, 2023
1 parent 96f1e0e commit ef19c48
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions adoc/chapters/device_compiler.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,26 @@ these restrictions:
* Exception-handling cannot be used inside a
<<device-function>>.
[code]#noexcept# is allowed.
* Recursion is not allowed in a <<device-function>> except in a
constant evaluation.
* Recursion is not allowed in a <<device-function>>.
* Variables with thread storage duration ([code]#thread_local#
storage class specifier) are not allowed to be odr-used in a
<<device-function>>.
* Variables with static storage duration that are odr-used inside a
<<device-function>>, must be [code]#const#
or [code]#constexpr# and zero-initialized or constant-initialized.

In the case of a manifestly constant-evaluated expression or
conversion, any code accepted by the C++ standard in this case is also
accepted in SYCL<<device-function>>.

[NOTE]
====
Amongst other things, this restriction makes it illegal for a
<<device-function>> to access a global variable that isn't [code]#const#
or [code]#constexpr#.
The restriction waiver in manifestly constant-evaluated expressions
allows any kind of meta-programming in a <<device-function>>.
====

* The rules for kernels apply to both the kernel function objects
Expand Down

0 comments on commit ef19c48

Please sign in to comment.