Skip to content

Commit 1e927c1

Browse files
committed
Simplify "[[sycl::uses_aspects()]]"
We are planning to change `[[sycl::requires()]]` in the SYCL 2020 spec to omit the `has()` clause, which means the parameter to that attribute will just be a list of aspects. Make the same change to `[[sycl::uses_aspects()]]` in this design document. Also add a note that we plan to change the name of `[[sycl::requires()]]` to `[[sycl::device_has()]]`. We can update this design document again once that change is adopted into the SYCL 2020 spec.
1 parent 0e47976 commit 1e927c1

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

sycl/doc/OptionalDeviceFeatures.md

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ attributes"][2] and [section 5.8.2 "Device function attributes"][3].
1717
[2]: <https://www.khronos.org/registry/SYCL/specs/sycl-2020/html/sycl-2020.html#sec:kernel.attributes>
1818
[3]: <https://www.khronos.org/registry/SYCL/specs/sycl-2020/html/sycl-2020.html#_device_function_attributes>
1919

20+
**NOTE**: At the time this document was written, there is a
21+
[proposed change][4] to the SYCL 2020 specification that will rename
22+
`[[sycl::requires()]]` to `[[sycl::device_has()]]`. Since that proposal has
23+
not yet been adopted, this design document continues to use the
24+
`[[sycl::requires()]]` name.
25+
26+
[4]: <https://github.com/KhronosGroup/SYCL-Docs/pull/171>
27+
2028

2129
## Definition of terms
2230

@@ -49,9 +57,9 @@ extension specification that enables indirect function calls.
4957
### An exported device function
5058

5159
The term "exported device function" means a device function that is exported
52-
from a shared library as defined by [Device Code Dynamic Linking][4].
60+
from a shared library as defined by [Device Code Dynamic Linking][5].
5361

54-
[4]: <https://github.com/intel/llvm/blob/sycl/sycl/doc/SharedLibraries.md>
62+
[5]: <https://github.com/intel/llvm/blob/sycl/sycl/doc/SharedLibraries.md>
5563

5664
### The FE compiler
5765

@@ -207,15 +215,15 @@ To illustrate, the type `sycl::half` is an optional feature whose associated
207215
aspect is `aspect::fp16`. We therefore decorate the declaration like this:
208216

209217
```
210-
using half [[__sycl_detail__::__uses_aspects__(has(aspect::fp16))]] =
218+
using half [[__sycl_detail__::__uses_aspects__(aspect::fp16)]] =
211219
cl::sycl::detail::half_impl::half;
212220
```
213221

214222
If an optional feature is expressed as a class type, it can be similarly
215223
decorated (here illustrating a hypothetical AMX type):
216224

217225
```
218-
class [[__sycl_detail__::__uses_aspects__(has(aspect::ext_intel_amx))]] amx_type {
226+
class [[__sycl_detail__::__uses_aspects__(aspect::ext_intel_amx)]] amx_type {
219227
/* ... */
220228
};
221229
```
@@ -224,26 +232,30 @@ This attribute is also used to decorate function declarations that correspond
224232
to optional features. Again, illustrating a hypothetical AMX extension:
225233

226234
```
227-
[[__sycl_detail__::__uses_aspects__(has(aspect::ext_intel_amx))]]
235+
[[__sycl_detail__::__uses_aspects__(aspect::ext_intel_amx)]]
228236
void amx_multiply();
229237
```
230238

231239
This attribute can also be used to decorate class templates where only certain
232240
instantiations correspond to optional features. See ["Appendix: Adding an
233-
attribute to 8-byte `atomic_ref`"][5] for an illustration of how this attribute
241+
attribute to 8-byte `atomic_ref`"][6] for an illustration of how this attribute
234242
can be used in conjunction with partial specialization to mark only certain
235243
instantiations of `sycl::atomic_ref` as an optional feature.
236244

237-
[5]: <#appendix-adding-an-attribute-to-8-byte-atomic_ref>
245+
[6]: <#appendix-adding-an-attribute-to-8-byte-atomic_ref>
238246

239-
As you can see from the examples above, the syntax for the parameter to the
240-
`[[sycl_detail::uses_aspects()]]` attribute is identical to the syntax for the
241-
standard `[[sycl::requires()]]` attribute.
247+
Although the examples above show only a single aspect parameter to the
248+
`[[sycl_detail::uses_aspects()]]` attribute, this attribute should support a
249+
list of aspects, similar to the `[[sycl::requires()]]` attribute. This will
250+
allow us to support future features that depend on a conjunction of aspects
251+
(e.g. a feature that does atomic operations on 64-bit floating point values
252+
might be decorated with
253+
`[[sycl_detail::uses_aspects(aspect::fp64, aspect::atomic64)]]`).
242254

243255
Unfortunately, the fundamental type `double` is also an optional kernel
244256
feature. Since there is no type alias for `double`, there is no convenient
245257
place to add an attribute. Instead, the FE device compiler must behave as
246-
though there was an implicit `[[sycl_detail::uses_aspects(has(aspect::fp64))]]`
258+
though there was an implicit `[[sycl_detail::uses_aspects(aspect::fp64)]]`
247259
attribute for any device code that uses the `double` type.
248260

249261

@@ -618,9 +630,9 @@ fact, the DPC++ driver supports a command line option which allows the user
618630
to select an alternate configuration file.
619631

620632
**TODO**: More information will be inserted here when we merge
621-
[this separate PR][6] into this design document.
633+
[this separate PR][7] into this design document.
622634

623-
[6]: <https://github.com/gmlueck/llvm/pull/1>
635+
[7]: <https://github.com/gmlueck/llvm/pull/1>
624636

625637

626638
### Changes to the DPC++ runtime
@@ -631,7 +643,7 @@ raise a synchronous `errc::kernel_not_supported` exception.
631643

632644
When the application submits a kernel to a device, the runtime identifies all
633645
the other device images that export device functions which are needed by the
634-
kernel as described in [Device Code Dynamic Linking][4]. Before the runtime
646+
kernel as described in [Device Code Dynamic Linking][5]. Before the runtime
635647
actually links these images together, it compares each image's
636648
"SYCL/device-requirements" against the features provided by the target
637649
device. If any of the following checks fail, the runtime throws
@@ -652,15 +664,15 @@ access the contents of the device image.
652664

653665
## Appendix: Adding an attribute to 8-byte `atomic_ref`
654666

655-
As described above under ["Changes to DPC++ headers"][7], we need to decorate
667+
As described above under ["Changes to DPC++ headers"][8], we need to decorate
656668
any SYCL type representing an optional device feature with the
657669
`[[sycl_detail::uses_aspects()]]` attribute. This is somewhat tricky for
658670
`atomic_ref`, though, because it is only an optional feature when specialized
659671
for a 8-byte type. However, we can accomplish this by using partial
660672
specialization techniques. The following code snippet demonstrates (best read
661673
from bottom to top):
662674

663-
[7]: <#changes-to-dpc-headers>
675+
[8]: <#changes-to-dpc-headers>
664676

665677
```
666678
namespace sycl {
@@ -688,7 +700,7 @@ class atomic_ref_impl : public atomic_ref_impl_base<T> {
688700
// Explicit specialization for 8-byte types. Only this specialization has the
689701
// attribute.
690702
template<typename T>
691-
class [[__sycl_detail__::__uses_aspects__(has(aspect::atomic64))]]
703+
class [[__sycl_detail__::__uses_aspects__(aspect::atomic64)]]
692704
atomic_ref_impl<T, 8> : public atomic_ref_impl_base<T> {
693705
public:
694706
using atomic_ref_impl_base<T>::atomic_ref_impl_base;

0 commit comments

Comments
 (0)