From dabdc647d32c8321abf4c56a1d871bb2352f4b83 Mon Sep 17 00:00:00 2001 From: Greg Lueck Date: Thu, 14 Nov 2024 15:00:17 -0500 Subject: [PATCH] Allow any manifestly constant-evaluated expression and conversion in device function Cherry pick #388 from main (cherry picked from commit 94eb55836038e27469e738345ce87762c4eb364e) --- adoc/chapters/device_compiler.adoc | 21 ++++++++++++++++++++- adoc/chapters/glossary.adoc | 15 ++++++++++++++- adoc/chapters/what_changed.adoc | 4 ++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/adoc/chapters/device_compiler.adoc b/adoc/chapters/device_compiler.adoc index 5b89c137..d75680ff 100644 --- a/adoc/chapters/device_compiler.adoc +++ b/adoc/chapters/device_compiler.adoc @@ -205,6 +205,16 @@ Amongst other things, this restriction makes it illegal for a implementation defines the [code]#SYCL_EXTERNAL# macro as described in <>. +Inside a <> or in the case of a +<>, any code accepted by the C++ standard in this +case is also accepted in a SYCL <>. + +[NOTE] +==== +The restriction waiver in <> or +<> allows any kind of meta-programming in a +<>. +==== [[subsec:scalartypes]] == Built-in scalar data types @@ -377,8 +387,17 @@ in <> must be defined by all conformant implementations. A number of kernel features defined by this SYCL specification are optional; they may be supported on some devices but not on other devices. + +As stated in <>, the restrictions for +optional kernel features do not apply to discarded statements or to manifestly +constant-evaluated expressions or conversions in device code. +Device code may use optional features in <> or +<> even if the device does not support the +optional feature. + As described in <>, an application can test whether a device -supports these features by testing whether the device has an associated aspect. +supports an optional feature by testing whether the device has an associated +aspect. The following aspects are those that correspond to optional kernel features: * [code]#fp16# diff --git a/adoc/chapters/glossary.adoc b/adoc/chapters/glossary.adoc index 379bacdc..2fb43ce9 100644 --- a/adoc/chapters/glossary.adoc +++ b/adoc/chapters/glossary.adoc @@ -188,6 +188,12 @@ For the full description please refer to <>. One of the device with the highest non-negative value is selected. See <> for more details. +[[discarded-statement]]discarded statement:: + ISO C++ +[stmt.if]+ describes a discarded statement as the branch statement + of an [code]#if constexpr# which is not instantiated because of the boolean + condition. + For more context, see <>. + [[event]]event:: A SYCL object that represents the status of an operation that is being executed by the SYCL runtime. @@ -339,6 +345,14 @@ For the full description please refer to <>. Local memory is a memory region associated with a <> and accessible only by <> in that <>. +[[manifestly-constant-evaluated]]manifestly constant-evaluated expression or conversion:: + ISO C++ +[expr.const]+ describes manifestly constant-evaluated expression or + conversion like constant expressions, condition of an +if constexpr+, an + immediate invocation, used in template parameters, in constant + initialization, etc. + This is evaluated at compile-time by the compiler. + For more context, see <>. + [[mem-fence]]mem-fence:: A memory fence provides control over re-ordering of memory load and store operations when coupled with an atomic operation. @@ -353,7 +367,6 @@ For the full description please refer to <>. A <> in a device image whose value can be used by an online compiler as an immediate value during the compilation. - [[nd-item]]nd-item:: A unique identifier representing a single <> and <> within the index space of a SYCL kernel execution. diff --git a/adoc/chapters/what_changed.adoc b/adoc/chapters/what_changed.adoc index bb96a207..270187e0 100644 --- a/adoc/chapters/what_changed.adoc +++ b/adoc/chapters/what_changed.adoc @@ -463,4 +463,8 @@ parameters did not clearly specify which accessor's size determines the amount of memory that is copied. The spec now clarifies that the [code]#src# accessor's size is used. +Any code considered as a <> or as a +<> by the C++ standard is now also accepted in +SYCL device function. + // %%%%%%%%%%%%%%%%%%%%%%%%%%%% end what_changed %%%%%%%%%%%%%%%%%%%%%%%%%%%%