@@ -17,6 +17,14 @@ attributes"][2] and [section 5.8.2 "Device function attributes"][3].
17
17
[ 2 ] : < https://www.khronos.org/registry/SYCL/specs/sycl-2020/html/sycl-2020.html#sec:kernel.attributes >
18
18
[ 3 ] : < https://www.khronos.org/registry/SYCL/specs/sycl-2020/html/sycl-2020.html#_device_function_attributes >
19
19
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
+
20
28
21
29
## Definition of terms
22
30
@@ -49,9 +57,9 @@ extension specification that enables indirect function calls.
49
57
### An exported device function
50
58
51
59
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 ] .
53
61
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 >
55
63
56
64
### The FE compiler
57
65
@@ -207,15 +215,15 @@ To illustrate, the type `sycl::half` is an optional feature whose associated
207
215
aspect is ` aspect::fp16 ` . We therefore decorate the declaration like this:
208
216
209
217
```
210
- using half [[__sycl_detail__::__uses_aspects__(has( aspect::fp16) )]] =
218
+ using half [[__sycl_detail__::__uses_aspects__(aspect::fp16)]] =
211
219
cl::sycl::detail::half_impl::half;
212
220
```
213
221
214
222
If an optional feature is expressed as a class type, it can be similarly
215
223
decorated (here illustrating a hypothetical AMX type):
216
224
217
225
```
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 {
219
227
/* ... */
220
228
};
221
229
```
@@ -224,26 +232,30 @@ This attribute is also used to decorate function declarations that correspond
224
232
to optional features. Again, illustrating a hypothetical AMX extension:
225
233
226
234
```
227
- [[__sycl_detail__::__uses_aspects__(has( aspect::ext_intel_amx) )]]
235
+ [[__sycl_detail__::__uses_aspects__(aspect::ext_intel_amx)]]
228
236
void amx_multiply();
229
237
```
230
238
231
239
This attribute can also be used to decorate class templates where only certain
232
240
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
234
242
can be used in conjunction with partial specialization to mark only certain
235
243
instantiations of ` sycl::atomic_ref ` as an optional feature.
236
244
237
- [ 5 ] : < #appendix-adding-an-attribute-to-8-byte-atomic_ref >
245
+ [ 6 ] : < #appendix-adding-an-attribute-to-8-byte-atomic_ref >
238
246
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)]] ` ).
242
254
243
255
Unfortunately, the fundamental type ` double ` is also an optional kernel
244
256
feature. Since there is no type alias for ` double ` , there is no convenient
245
257
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)]] `
247
259
attribute for any device code that uses the ` double ` type.
248
260
249
261
@@ -618,9 +630,9 @@ fact, the DPC++ driver supports a command line option which allows the user
618
630
to select an alternate configuration file.
619
631
620
632
** 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.
622
634
623
- [ 6 ] : < https://github.com/gmlueck/llvm/pull/1 >
635
+ [ 7 ] : < https://github.com/gmlueck/llvm/pull/1 >
624
636
625
637
626
638
### Changes to the DPC++ runtime
@@ -631,7 +643,7 @@ raise a synchronous `errc::kernel_not_supported` exception.
631
643
632
644
When the application submits a kernel to a device, the runtime identifies all
633
645
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
635
647
actually links these images together, it compares each image's
636
648
"SYCL/device-requirements" against the features provided by the target
637
649
device. If any of the following checks fail, the runtime throws
@@ -652,15 +664,15 @@ access the contents of the device image.
652
664
653
665
## Appendix: Adding an attribute to 8-byte ` atomic_ref `
654
666
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
656
668
any SYCL type representing an optional device feature with the
657
669
` [[sycl_detail::uses_aspects()]] ` attribute. This is somewhat tricky for
658
670
` atomic_ref ` , though, because it is only an optional feature when specialized
659
671
for a 8-byte type. However, we can accomplish this by using partial
660
672
specialization techniques. The following code snippet demonstrates (best read
661
673
from bottom to top):
662
674
663
- [ 7 ] : < #changes-to-dpc-headers >
675
+ [ 8 ] : < #changes-to-dpc-headers >
664
676
665
677
```
666
678
namespace sycl {
@@ -688,7 +700,7 @@ class atomic_ref_impl : public atomic_ref_impl_base<T> {
688
700
// Explicit specialization for 8-byte types. Only this specialization has the
689
701
// attribute.
690
702
template<typename T>
691
- class [[__sycl_detail__::__uses_aspects__(has( aspect::atomic64) )]]
703
+ class [[__sycl_detail__::__uses_aspects__(aspect::atomic64)]]
692
704
atomic_ref_impl<T, 8> : public atomic_ref_impl_base<T> {
693
705
public:
694
706
using atomic_ref_impl_base<T>::atomic_ref_impl_base;
0 commit comments