Skip to content

Commit 333bf43

Browse files
committed
Clarify when errc::kernel_not_supported is thrown
Clarify wording about when `errc::kernel_not_supported` is thrown.
1 parent 50835d4 commit 333bf43

File tree

1 file changed

+40
-18
lines changed

1 file changed

+40
-18
lines changed

sycl/doc/OptionalDeviceFeatures.md

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,32 @@ kernel uses an unsupported feature, the runtime must throw a synchronous
7373

7474
This exception must be thrown in the following circumstances:
7575

76-
* A device function in the kernel's static call tree uses a feature that the
77-
device does not support. However, this only applies to features that are
78-
exposed via a C++ type or function. Examples of this include `sycl::half` or
79-
instantiating `sycl::atomic_ref` for a 64-bit type. In cases where the
80-
feature is more "notional", such as requiring a particular type of forward
81-
progress guarantee, no exception is required.
82-
83-
* The kernel or a device function in the kernel's static call tree is decorated
84-
with `[[sycl::requires()]]`, and the device does not have the required
85-
aspects. An exception must be thrown in this case even if the kernel does
86-
not actually use a feature corresponding to the aspect.
76+
* For a kernel that is not decorated with `[[sycl::requires()]]`: the exception
77+
must be thrown if a device function in the kernel's static call tree uses a
78+
feature that the device does not support. However, this only applies to
79+
features that are exposed via a C++ type or function. Examples of this
80+
include `sycl::half` or instantiating `sycl::atomic_ref` for a 64-bit type.
81+
If the kernel relies on optional features that are more "notional" such as
82+
sub-group independent forward progress
83+
(`info::device::sub_group_independent_forward_progress`), no exception is
84+
required.
85+
86+
* For a kernel that is decorated with `[[sycl::requires()]]`: the exception
87+
must be thrown if the device does not have the aspects listed in that
88+
attribute. Note that the exception must be thrown even if the kernel does
89+
not actually use a feature corresponding to the aspect, and it must be
90+
thrown even if the aspect does not correspond to any optional feature.
91+
92+
* For a kernel that is decorated with `[[sycl::requires()]]`: the exception
93+
must be thrown if a function in the kernel's static call tree uses a feature
94+
that the device does not support even if the `[[sycl::requires()]]` attribute
95+
is missing the corresponding aspect. This case can only occur if the kernel
96+
calls a `SYCL_EXTERNAL` function in another translation unit and the function
97+
uses an optional feature that is not listed in the `[[sycl::requires()]]`
98+
attribute attached to the `SYCL_EXTERNAL` function declaration. (In any
99+
other case, the front-end compiler would diagnose an error.) Although the
100+
SYCL 2020 spec says that such applications are non-conformant, it is easy for
101+
DPC++ to throw an exception in such a case.
87102

88103
* The kernel is decorated with the `[[sycl::reqd_work_group_size(W)]]` or
89104
`[[sycl::reqd_sub_group_size(S)]]` attribute, and the device does not support
@@ -330,13 +345,20 @@ decorations to the appropriate functions and to emit the specialization
330345
constants that these decorations reference. This can be done with two passes
331346
over each kernel's static call tree.
332347

333-
The first pass operates only on kernel functions that are not decorated with
334-
the `[[sycl::requires()]]` attribute. When the kernel is decorated with this
335-
attribute, the attribute tells the full set of aspects that the kernel uses
336-
(and the front-end compiler has already validated this). For kernels without
337-
the attribute, the pass propagates the required aspects from
338-
`[[sycl::requires()]]` attributes in a kernel's call tree up to the kernel
339-
function, forming a union of all required aspects for the kernel.
348+
The first pass operates on each kernel, iterating over all the functions in the
349+
kernel's static call tree to form the union of all aspects required by kernel.
350+
If the kernel is decorated with the `[[sycl::requires()]]`, those aspects are
351+
also added to the union.
352+
353+
**NOTE**: This first pass traverses the static call tree even for kernels that
354+
are decorated with the `[[sycl::requires()]]` attribute. Although the
355+
front-end compiler has already verified that the kernel doesn't require any
356+
aspects beyond those listed in the attribute, the front-end compiler was only
357+
able to verify this for the device functions that reside in the same
358+
translation unit as the kernel. Therefore, we might still find more required
359+
aspects in the post-link tool because we have visibility to all device
360+
functions in the kernel's static call tree, even those that are defined in
361+
other translation units.
340362

341363
Once we have the full set of aspects used by each kernel, we do the following
342364
for each kernel:

0 commit comments

Comments
 (0)