@@ -23,32 +23,26 @@ NOTE: Khronos(R) is a registered trademark and SYCL(TM) and SPIR(TM) are
23
23
trademarks of The Khronos Group Inc. OpenCL(TM) is a trademark of Apple Inc.
24
24
used by permission by Khronos.
25
25
26
- NOTE: This document is better viewed when rendered as html with asciidoctor.
27
- GitHub does not render image icons.
28
-
29
26
This extension introduces a replacement for the kernel attributes defined in
30
- Section 5.8.1 of the SYCL 2020 specification, in the form of a `property_list`
27
+ Section 5.8.1 of the SYCL 2020 specification, in the form of a property list
31
28
accepting properties with compile-time constant values.
32
29
33
30
== Notice
34
31
35
- Copyright (c) 2021 Intel Corporation. All rights reserved.
32
+ Copyright (c) 2021-2022 Intel Corporation. All rights reserved.
36
33
37
34
== Status
38
35
39
36
Working Draft
40
37
41
- This is a preview extension specification, intended to provide early access to
42
- a feature for review and community feedback. When the feature matures, this
43
- specification may be released as a formal extension.
44
-
45
- Because the interfaces defined by this specification are not final and are
46
- subject to change they are not intended to be used by shipping software
47
- products.
38
+ This is a proposed extension specification, intended to gather community
39
+ feedback. Interfaces defined in this specification may not be implemented yet
40
+ or may be in a preliminary state. The specification itself may also change in
41
+ incompatible ways before it is finalized. Shipping software products should not
42
+ rely on APIs defined in this specification.
48
43
49
44
== Version
50
45
51
- Built On: {docdate} +
52
46
Revision: 1
53
47
54
48
== Contributors
@@ -61,10 +55,10 @@ Roland Schulz, Intel
61
55
62
56
== Dependencies
63
57
64
- This extension is written against the SYCL 2020 specification, Revision 3 and
58
+ This extension is written against the SYCL 2020 specification, Revision 4 and
65
59
the following extensions:
66
60
67
- - https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/PropertyList/SYCL_EXT_ONEAPI_property_list .asciidoc[SYCL_EXT_ONEAPI_PROPERTY_LIST ]
61
+ - https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/PropertyList/SYCL_EXT_ONEAPI_properties .asciidoc[SYCL_EXT_ONEAPI_PROPERTIES ]
68
62
69
63
== Feature Test Macro
70
64
@@ -110,7 +104,7 @@ information, including:
110
104
performed at run-time and *after* compiling the kernel.
111
105
112
106
This extension proposes a replacement for these kernel attributes, in the form
113
- of a `property_list` accepting properties with compile-time constant
107
+ of a property list accepting properties with compile-time constant
114
108
values, to address several of these issues.
115
109
116
110
== Kernel Properties
@@ -123,58 +117,60 @@ Section 5.8.1 of the SYCL 2020 specification. Note that deprecated attributes
123
117
namespace sycl {
124
118
namespace ext {
125
119
namespace oneapi {
120
+ namespace experimental {
126
121
127
122
// Corresponds to reqd_work_group_size
128
- struct work_group_size {
123
+ struct work_group_size_key {
129
124
template <size_t... Dims>
130
- using value_t = property_value<work_group_size , std::integral_constant<size_t, Dims>...>;
131
- }; // work_group_size
125
+ using value_t = property_value<work_group_size_key , std::integral_constant<size_t, Dims>...>;
126
+ }; // work_group_size_key
132
127
133
128
// Corresponds to work_group_size_hint
134
- struct work_group_size_hint {
129
+ struct work_group_size_hint_key {
135
130
template <size_t... Dims>
136
- using value_t = property_value<work_group_size_hint , std::integral_constant<size_t, Dims>...>;
137
- }; // work_group_size_hint
131
+ using value_t = property_value<work_group_size_hint_key , std::integral_constant<size_t, Dims>...>;
132
+ }; // work_group_size_hint_key
138
133
139
134
// Corresponds to reqd_sub_group_size
140
- struct sub_group_size {
135
+ struct sub_group_size_key {
141
136
template <uint32_t Size>
142
- using value_t = property_value<sub_group_size , std::integral_constant<uint32_t, Size>>;
143
- }; // sub_group_size
137
+ using value_t = property_value<sub_group_size_key , std::integral_constant<uint32_t, Size>>;
138
+ }; // sub_group_size_key
144
139
145
140
// Corresponds to device_has
146
- struct device_has {
141
+ struct device_has_key {
147
142
template <sycl::aspect... Aspects>
148
- using value_t = property_value<device_has , std::integral_constant<sycl::aspect, Aspects>...>;
149
- }; // device_has
143
+ using value_t = property_value<device_has_key , std::integral_constant<sycl::aspect, Aspects>...>;
144
+ }; // device_has_key
150
145
151
146
template <size_t... Dims>
152
- struct property_value<work_group_size , std::integral_constant<size_t, Dims>...> {
147
+ struct property_value<work_group_size_key , std::integral_constant<size_t, Dims>...> {
153
148
constexpr size_t operator[](int dim);
154
149
};
155
150
156
151
template <size_t... Dims>
157
- struct property_value<work_group_size_hint , std::integral_constant<size_t, Dims>...> {
152
+ struct property_value<work_group_size_hint_key , std::integral_constant<size_t, Dims>...> {
158
153
constexpr size_t operator[](int dim);
159
154
};
160
155
161
156
template <sycl::aspect... Aspects>
162
- struct property_value<device_has , std::integral_constant<sycl::aspect, Aspects>...> {
157
+ struct property_value<device_has_key , std::integral_constant<sycl::aspect, Aspects>...> {
163
158
static constexpr std::array<sycl::aspect, sizeof...(Aspects)> value;
164
159
};
165
160
166
161
template <size_t... Dims>
167
- inline constexpr work_group_size ::value_t<Dims...> work_group_size_v ;
162
+ inline constexpr work_group_size_key ::value_t<Dims...> work_group_size ;
168
163
169
164
template <size_t... Dims>
170
- inline constexpr work_group_size_hint ::value_t<Dims...> work_group_size_hint_v ;
165
+ inline constexpr work_group_size_hint_key ::value_t<Dims...> work_group_size_hint ;
171
166
172
167
template <uint32_t Size>
173
- inline constexpr sub_group_size ::value_t<Size> sub_group_size_v ;
168
+ inline constexpr sub_group_size_key ::value_t<Size> sub_group_size ;
174
169
175
170
template <sycl::aspect... Aspects>
176
- inline constexpr device_has ::value_t<Aspects...> device_has_v ;
171
+ inline constexpr device_has_key ::value_t<Aspects...> device_has ;
177
172
173
+ } // namespace experimental
178
174
} // namespace oneapi
179
175
} // namespace ext
180
176
} // namespace sycl
@@ -221,15 +217,15 @@ SYCL implementations may introduce additional kernel properties. If any
221
217
combinations of kernel attributes are invalid, this must be clearly documented
222
218
as part of the new kernel property definition.
223
219
224
- == Adding a `property_list` to a Kernel Launch
220
+ == Adding a Property List to a Kernel Launch
225
221
226
222
To enable properties to be associated with kernels, this extension adds
227
223
new overloads to each of the variants of `single_task`, `parallel_for` and
228
224
`parallel_for_work_group` defined in the `queue` and `handler` classes. These
229
- new overloads accept a `sycl::ext::oneapi::property_list ` argument. For
230
- variants accepting a parameter pack, the `sycl::ext::oneapi::property_list `
225
+ new overloads accept a `sycl::ext::oneapi::experimental::properties ` argument. For
226
+ variants accepting a parameter pack, the `sycl::ext::oneapi::experimental::properties `
231
227
argument is inserted immediately prior to the parameter pack; for variants not
232
- accepting a parameter pack, the `sycl::ext::oneapi::property_list ` argument is
228
+ accepting a parameter pack, the `sycl::ext::oneapi::experimental::properties ` argument is
233
229
inserted immediately prior to the kernel function.
234
230
235
231
The overloads introduced by this extension are listed below:
@@ -313,15 +309,15 @@ class handler {
313
309
}
314
310
```
315
311
316
- Passing properties as an argument in this way allows properties to be
312
+ Passing a property list as an argument in this way allows properties to be
317
313
associated with a kernel function without modifying its type. This enables
318
314
the same kernel function (e.g. a lambda) to be submitted multiple times with
319
315
different properties, or for libraries building on SYCL to add properties
320
316
(e.g. for performance reasons) to user-provided kernel functions.
321
317
322
318
All the properties defined in this extension have compile-time values. However,
323
319
an implementation may support additional properties which could have run-time
324
- values. When this occurs, the `properties` parameter may be a `property_list`
320
+ values. When this occurs, the `properties` parameter may be a property list
325
321
containing a mix of both run-time and compile-time values, and a SYCL
326
322
implementation should respect both run-time and compile-time information when
327
323
determining the correct way to launch a kernel. However, only compile-time
@@ -331,28 +327,47 @@ A simple example of using this extension to set a required work-group size
331
327
and required sub-group size is given below:
332
328
333
329
```c++
334
- sycl::ext::oneapi::property_list properties{sycl::ext::oneapi::work_group_size_v <8, 8>,
335
- sycl::ext::oneapi::sub_group_size_v <8>};
330
+ sycl::ext::oneapi::experimental::properties properties{sycl::ext::oneapi::experimental::work_group_size <8, 8>,
331
+ sycl::ext::oneapi::experimental::sub_group_size <8>};
336
332
q.parallel_for(range<2>{16, 16}, properties, [=](id<2> i) {
337
333
a[i] = b[i] + c[i];
338
334
}).wait();
339
335
```
340
336
341
- == Encoding Properties into a Kernel
337
+ == Embedding Properties into a Kernel
342
338
343
- In other situations it may be useful to encode a kernel's properties directly
339
+ In other situations it may be useful to embed a kernel's properties directly
344
340
into its type, to ensure that a kernel cannot be launched without a property
345
341
that it depends upon for correctness.
346
342
347
343
To enable this use-case, this extension adds a mechanism for implementations to
348
344
extract a property list from a kernel functor, if a kernel functor declares
349
- a `property_list` member variable named `properties`. Note that this member
350
- variable must be `static constexpr`, and kernel functors can therefore only
351
- encode properties with compile-time values.
345
+ a member function named `get` accepting a `sycl::ext::oneapi::experimental::properties_tag`
346
+ tag type and returning an instance of `sycl::ext::oneapi::experimental::properties`.
347
+
348
+ ```c++
349
+ namespace sycl {
350
+ namespace ext {
351
+ namespace oneapi {
352
+ namespace experimental {
353
+
354
+ struct properties_tag {};
355
+
356
+ }
357
+ }
358
+ }
359
+ }
360
+ ```
361
+
362
+ NOTE: https://wg21.link/p1895[P1895] proposes a function called `tag_invoke`
363
+ as a general mechanism for customization points that could be used as a
364
+ replacement for the `get` function proposed here. If `tag_invoke` becomes
365
+ a feature in a future version of {cpp}, a future version of this extension
366
+ may expose a new interface compatible with `tag_invoke`.
352
367
353
368
NOTE: The attribute mechanism in SYCL 2020 allows for different kernel
354
369
attributes to be applied to different call operators within the same
355
- functor. The `property_list` member variable applies to all call operators in
370
+ functor. An embedded property list applies to all call operators in
356
371
the functor.
357
372
358
373
The example below shows how the kernel from the previous section could be
@@ -370,9 +385,10 @@ struct KernelFunctor {
370
385
a[i] = b[i] + c[i];
371
386
}
372
387
373
- static constexpr auto properties =
374
- sycl::ext::oneapi::property_list{sycl::ext::oneapi::work_group_size_v<8, 8>,
375
- sycl::ext::oneapi::sub_group_size_v<8>};
388
+ auto get(sycl::ext::oneapi::experimental::properties_tag) {
389
+ return sycl::ext::oneapi::experimental::properties{sycl::ext::oneapi::experimental::work_group_size<8, 8>,
390
+ sycl::ext::oneapi::experimental::sub_group_size<8>};
391
+ }
376
392
377
393
sycl::accessor<int, 2> a;
378
394
sycl::accessor<int, 2> b;
@@ -385,18 +401,18 @@ struct KernelFunctor {
385
401
q.parallel_for(range<2>{16, 16}, KernelFunctor(a, b, c)).wait();
386
402
```
387
403
388
- If a kernel functor with a `property_list` member variable is enqueued for
389
- execution using an invocation function with a `property_list` argument,
390
- the kernel is launched as-if the member variable and argument were combined. If
391
- the combined list contains any invalid combinations of properties, then this is
392
- an error: invalid combinations that can be detected at compile-time should be
393
- reported via a diagnostic; invalid combinations that can only be detected at
394
- run-time should result in an implementation throwing an `exception` with the
395
- `errc::invalid` error code.
404
+ If a kernel functor with embedded properties is enqueued for execution using an
405
+ invocation function with a property list argument, the kernel is launched as-if
406
+ the embedded properties and argument were combined. If the combined list
407
+ contains any invalid combinations of properties, then this is an error: invalid
408
+ combinations that can be detected at compile-time should be reported via a
409
+ diagnostic; invalid combinations that can only be detected at run-time should
410
+ result in an implementation throwing an `exception` with the `errc::invalid`
411
+ error code.
396
412
397
413
== Querying Properties in a Compiled Kernel
398
414
399
- Any properties encoded into a kernel type via a property list are reflected
415
+ Any properties embedded into a kernel type via a property list are reflected
400
416
in the results of a call to `kernel::get_info` with the
401
417
`info::kernel::attributes` information descriptor, as if the corresponding
402
418
attribute from the SYCL 2020 specification had been applied to the kernel
@@ -408,9 +424,9 @@ The SYCL 2020 `sycl::device_has` attribute can be applied to the declaration
408
424
of a non-kernel device function, to assert that the device function uses a
409
425
specific set of optional features. This extension provides a mechanism exposing
410
426
similar behavior, allowing for kernel properties to be associated with
411
- a function via the `SYCL_EXT_ONEAPI_PROPERTY ` macro. Each instance of the
412
- `SYCL_EXT_ONEAPI_PROPERTY ` macro accepts one argument, corresponding to a
413
- single property value.
427
+ a function via the `SYCL_EXT_ONEAPI_FUNCTION_PROPERTY ` macro. Each instance of
428
+ the `SYCL_EXT_ONEAPI_FUNCTION_PROPERTY ` macro accepts one argument,
429
+ corresponding to a single property value.
414
430
415
431
NOTE: Due to limitations of the C preprocessor, property value expressions
416
432
containing commas (e.g. due to template arguments) must be enclosed in
@@ -420,12 +436,13 @@ The example below shows a function that uses two optional features,
420
436
corresponding to the `fp16` and `atomic64` aspects.
421
437
422
438
```c++
423
- SYCL_EXT_ONEAPI_PROPERTY ((sycl::device_has_v <aspect::fp16, aspect::atomic64>))
439
+ SYCL_EXT_ONEAPI_FUNCTION_PROPERTY ((sycl::device_has <aspect::fp16, aspect::atomic64>))
424
440
void foo();
425
441
```
426
442
427
443
The table below describes the effects of associating each kernel property
428
- with a non-kernel device function via the `SYCL_EXT_ONEAPI_PROPERTY` macro.
444
+ with a non-kernel device function via the `SYCL_EXT_ONEAPI_FUNCTION_PROPERTY`
445
+ macro.
429
446
430
447
|===
431
448
|Property|Description
@@ -438,14 +455,14 @@ with a non-kernel device function via the `SYCL_EXT_ONEAPI_PROPERTY` macro.
438
455
439
456
|===
440
457
441
- The `SYCL_EXT_ONEAPI_PROPERTY ` macro can be used alongside the
458
+ The `SYCL_EXT_ONEAPI_FUNCTION_PROPERTY ` macro can be used alongside the
442
459
`SYCL_EXTERNAL` macro, and the macros may be specified in any order.
443
460
Whenever `SYCL_EXTERNAL` is used, there are two relevant translation units: the
444
461
translation unit that _defines_ the function and the translation unit that
445
462
_calls_ the function. If a given `SYCL_EXTERNAL` function _F_ is defined in
446
463
one translation unit with a set of properties _P_, then all other translation
447
464
units that declare that same function _F_ must list the same set of properties
448
- _P_ via the `SYCL_EXT_ONEAPI_PROPERTY ` macro. Programs which fail to do this
465
+ _P_ via the `SYCL_EXT_ONEAPI_FUNCTION_PROPERTY ` macro. Programs which fail to do this
449
466
are ill-formed, but no diagnostic is required.
450
467
451
468
== Issues
@@ -461,14 +478,14 @@ new properties, for example `device_has_all_of` and `device_has_any_of`:
461
478
device_has_any_of<device_has<aspect::fp16, device_has<aspect::fp64>>`.
462
479
--
463
480
464
- . How should the `property_list` member variable behave with inheritance?
481
+ . How should an embedded property list behave with inheritance?
465
482
+
466
483
--
467
- *UNRESOLVED *: The specification currently allows for a class to inspect the
468
- `property_list` member variable from its base class(es) and construct a new
469
- `property_list` member variable that applies to all call operators. Associating
470
- different properties with different call operators via inheritance has the
471
- potential to be confusing and would increase implementation complexity.
484
+ *RESOLVED *: The specification currently allows for a class to inspect the
485
+ property list embedded into its base class(es) and construct a new property
486
+ list that applies to all call operators. Associating different properties with
487
+ different call operators via inheritance has the potential to be confusing and
488
+ would increase implementation complexity.
472
489
--
473
490
474
491
//. asd
0 commit comments