Skip to content

Commit 504ac97

Browse files
author
psamolysov-intel
authored
[SYCL] Define missing feature test macros (#4792)
According to SYCL spec (6.3.3. Feature test macros), vendors are encouraged to group a related set of extensions together into a "feature" and to predefine a feature-test macro when the implementation supports the extensions in that feature. The feature-test macro should have the following form to ensure it is unique: SYCL_EXT_<vendorstring>_<featurename>. The patch defines the following feature test macros: - SYCL_EXT_ONEAPI_ASSERT (for https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/Assert/SYCL_ONEAPI_ASSERT.asciidoc) - SYCL_EXT_ONEAPI_FREE_FUNCTION_QUERIES (for https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/FreeFunctionQueries/SYCL_INTEL_free_function_queries.asciidoc) - SYCL_EXT_ONEAPI_GROUP_ALGORITHMS (for https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/GroupAlgorithms/SYCL_INTEL_group_algorithms.asciidoc) - SYCL_EXT_ONEAPI_GROUP_SORT (for https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/GroupAlgorithms/SYCL_INTEL_group_sort.asciidoc) - SYCL_EXT_ONEAPI_LOCAL_MEMORY (for https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/LocalMemory/LocalMemory.asciidoc) - SYCL_EXT_ONEAPI_ND_RANGE_REDUCTIONS (for https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/Reduction/Reduction.md) - SYCL_EXT_ONEAPI_DEFAULT_CONTEXT (for https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/PlatformContext/PlatformContext.adoc) - SYCL_EXT_ONEAPI_USE_PINNED_HOST_MEMORY_PROPERTY (for https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/UsePinnedMemoryProperty/UsePinnedMemoryPropery.adoc) - SYCL_EXT_ONEAPI_SUB_GROUP (for https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/SubGroup/SYCL_INTEL_sub_group.asciidoc) - SYCL_EXT_INTEL_BITCAST (for https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/Bitcast/SYCL_INTEL_bitcast.asciidoc) - SYCL_EXT_INTEL_DATAFLOW_PIPES (for https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/DataFlowPipes/data_flow_pipes.asciidoc) - SYCL_EXT_INTEL_EXTENDED_ATOMICS (for https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/ExtendedAtomics/SYCL_INTEL_extended_atomics.asciidoc) - SYCL_EXT_INTEL_FPGA_DEVICE_SELECTOR (for https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/IntelFPGA/FPGASelector.md) - SYCL_EXT_INTEL_FPGA_LSU (for https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/IntelFPGA/FPGALsu.md) - SYCL_EXT_INTEL_FPGA_REG (for https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/IntelFPGA/FPGAReg.md) - SYCL_EXT_INTEL_KERNEL_ARGS_RESTRICT (for https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/KernelRestrictAll/SYCL_INTEL_kernel_restrict_all.asciidoc) The feature macros are defined for documented extensions only.
1 parent c623223 commit 504ac97

File tree

16 files changed

+211
-11
lines changed

16 files changed

+211
-11
lines changed

sycl/doc/extensions/Bitcast/SYCL_INTEL_bitcast.asciidoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,22 @@ namespace sycl {
104104

105105
None.
106106

107+
== Feature test macro
108+
109+
This extension provides a feature-test macro as described in the core SYCL
110+
specification section 6.3.3 "Feature test macros". Therefore, an implementation
111+
supporting this extension must predefine the macro `SYCL_EXT_INTEL_BITCAST` to
112+
one of the values defined in the table below. Applications can test for the
113+
existence of this macro to determine if the implementation supports this
114+
feature, or applications can test the macro's value to determine which of the
115+
extension's APIs the implementation supports.
116+
117+
[%header,cols="1,5"]
118+
|===
119+
|Value |Description
120+
|1 |Initial extension version. Base features are supported.
121+
|===
122+
107123
== Revision History
108124

109125
[cols="5,15,15,70"]

sycl/doc/extensions/DataFlowPipes/data_flow_pipes.asciidoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,22 @@ Automated mechanisms are possible to provide uniquification across calls, and co
634634
*RESOLUTION*: Resolved. Abstraction/libraries on top enable functionality like this. We will make public a library that enables arrays of pipes.
635635
--
636636

637+
== Feature test macro
638+
639+
This extension provides a feature-test macro as described in the core SYCL
640+
specification section 6.3.3 "Feature test macros". Therefore, an implementation
641+
supporting this extension must predefine the macro `SYCL_EXT_INTEL_DATAFLOW_PIPES`
642+
to one of the values defined in the table below. Applications can test for the
643+
existence of this macro to determine if the implementation supports this
644+
feature, or applications can test the macro's value to determine which of the
645+
extension's APIs the implementation supports.
646+
647+
[%header,cols="1,5"]
648+
|===
649+
|Value |Description
650+
|1 |Initial extension version. Base features are supported.
651+
|===
652+
637653
== Revision History
638654

639655
[cols="5,15,15,70"]

sycl/doc/extensions/ExtendedAtomics/SYCL_INTEL_extended_atomics.asciidoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,22 @@ None.
647647
//*RESOLUTION*: Not resolved.
648648
//--
649649
650+
== Feature test macro
651+
652+
This extension provides a feature-test macro as described in the core SYCL
653+
specification section 6.3.3 "Feature test macros". Therefore, an implementation
654+
supporting this extension must predefine the macro `SYCL_EXT_INTEL_EXTENDED_ATOMICS`
655+
to one of the values defined in the table below. Applications can test for the
656+
existence of this macro to determine if the implementation supports this
657+
feature, or applications can test the macro's value to determine which of the
658+
extension's APIs the implementation supports.
659+
660+
[%header,cols="1,5"]
661+
|===
662+
|Value |Description
663+
|1 |Initial extension version. Base features are supported.
664+
|===
665+
650666
== Revision History
651667
652668
[cols="5,15,15,70"]

sycl/doc/extensions/FreeFunctionQueries/SYCL_INTEL_free_function_queries.asciidoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,19 @@ Returns the `sub_group` instance representing the particular `sub-group` within
208208
209209
If prerequisites are not fulfilled the behavior is undefined
210210
|===
211+
212+
== Feature test macro
213+
214+
This extension provides a feature-test macro as described in the core SYCL
215+
specification section 6.3.3 "Feature test macros". Therefore, an implementation
216+
supporting this extension must predefine the macro `SYCL_EXT_ONEAPI_FREE_FUNCTION_QUERIES`
217+
to one of the values defined in the table below. Applications can test for the
218+
existence of this macro to determine if the implementation supports this
219+
feature, or applications can test the macro's value to determine which of the
220+
extension's APIs the implementation supports.
221+
222+
[%header,cols="1,5"]
223+
|===
224+
|Value |Description
225+
|1 |Initial extension version. Base features are supported.
226+
|===

sycl/doc/extensions/GroupAlgorithms/SYCL_INTEL_group_algorithms.asciidoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,22 @@ None.
267267
*RESOLUTION*: The `is_native_function_object` trait has been removed. It proved too difficult to implement something that returned sensible values for transparent function objects (e.g. `std::plus<void>`) that did not also require checking additional traits for each individual group algorithm. Requiring the user to implement their own checks based on type requirements outlined in the specification would make it significantly harder for implementers to extend the algorithms to types and function objects beyond what is specified. Using constrained forms of the algorithms instead allows a user to determine whether an implementation of a particular algorithm exists using the C++ detection idiom.
268268
--
269269
270+
== Feature test macro
271+
272+
This extension provides a feature-test macro as described in the core SYCL
273+
specification section 6.3.3 "Feature test macros". Therefore, an implementation
274+
supporting this extension must predefine the macro `SYCL_EXT_ONEAPI_GROUP_ALGORITHMS`
275+
to one of the values defined in the table below. Applications can test for the
276+
existence of this macro to determine if the implementation supports this
277+
feature, or applications can test the macro's value to determine which of the
278+
extension's APIs the implementation supports.
279+
280+
[%header,cols="1,5"]
281+
|===
282+
|Value |Description
283+
|1 |Initial extension version. Base features are supported.
284+
|===
285+
270286
== Revision History
271287
272288
[cols="5,15,15,70"]

sycl/doc/extensions/IntelFPGA/FPGALsu.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,17 @@ Queue.submit([&](cl::sycl::handler &cgh) {
118118
});
119119
...
120120
```
121+
122+
## Feature Test Macro
123+
124+
This extension provides a feature-test macro as described in the core SYCL
125+
specification section 6.3.3 "Feature test macros". Therefore, an implementation
126+
supporting this extension must predefine the macro `SYCL_EXT_INTEL_FPGA_LSU`
127+
to one of the values defined in the table below. Applications can test for the
128+
existence of this macro to determine if the implementation supports this
129+
feature, or applications can test the macro’s value to determine which of the
130+
extension’s APIs the implementation supports.
131+
132+
|Value |Description|
133+
|:---- |:---------:|
134+
|1 |Initial extension version. Base features are supported.|

sycl/doc/extensions/IntelFPGA/FPGAReg.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,17 @@ int a = cl::sycl::intel::fpga_reg(a[k]) + b[k];
2929

3030
...
3131
```
32+
33+
## Feature Test Macro
34+
35+
This extension provides a feature-test macro as described in the core SYCL
36+
specification section 6.3.3 "Feature test macros". Therefore, an implementation
37+
supporting this extension must predefine the macro `SYCL_EXT_INTEL_FPGA_REG`
38+
to one of the values defined in the table below. Applications can test for the
39+
existence of this macro to determine if the implementation supports this
40+
feature, or applications can test the macro’s value to determine which of the
41+
extension’s APIs the implementation supports.
42+
43+
|Value |Description|
44+
|:---- |:---------:|
45+
|1 |Initial extension version. Base features are supported.|

sycl/doc/extensions/IntelFPGA/FPGASelector.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,17 @@ cl::sycl::queue deviceQueue{cl::sycl::ext::intel::fpga_selector{}};
2525
cl::sycl::queue deviceQueue{cl::sycl::ext::intel::fpga_emulator_selector{}};
2626
...
2727
```
28+
29+
## Feature Test Macro
30+
31+
This extension provides a feature-test macro as described in the core SYCL
32+
specification section 6.3.3 "Feature test macros". Therefore, an implementation
33+
supporting this extension must predefine the macro `SYCL_EXT_INTEL_FPGA_DEVICE_SELECTOR`
34+
to one of the values defined in the table below. Applications can test for the
35+
existence of this macro to determine if the implementation supports this
36+
feature, or applications can test the macro’s value to determine which of the
37+
extension’s APIs the implementation supports.
38+
39+
|Value |Description|
40+
|:---- |:---------:|
41+
|1 |Initial extension version. Base features are supported.|

sycl/doc/extensions/KernelRestrictAll/SYCL_INTEL_kernel_restrict_all.asciidoc

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,21 @@ None.
109109
//*RESOLUTION*: Description
110110
//--
111111
112-
112+
== Feature test macro
113+
114+
This extension provides a feature-test macro as described in the core SYCL
115+
specification section 6.3.3 "Feature test macros". Therefore, an implementation
116+
supporting this extension must predefine the macro `SYCL_EXT_INTEL_KERNEL_ARGS_RESTRICT`
117+
to one of the values defined in the table below. Applications can test for the
118+
existence of this macro to determine if the implementation supports this
119+
feature, or applications can test the macro’s value to determine which of the
120+
extension’s APIs the implementation supports.
121+
122+
[%header,cols="1,5"]
123+
|===
124+
|Value |Description
125+
|1 |Initial extension version. Base features are supported.
126+
|===
113127
114128
== Revision History
115129

sycl/doc/extensions/Reduction/Reduction.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,17 @@ __kernel void dot_product(__global float* a, __global float* b, __global float*
186186
atomic_add(sum, a[i] * b[i]);
187187
}
188188
```
189+
190+
## Feature Test Macro
191+
192+
This extension provides a feature-test macro as described in the core SYCL
193+
specification section 6.3.3 "Feature test macros". Therefore, an implementation
194+
supporting this extension must predefine the macro `SYCL_EXT_ONEAPI_ND_RANGE_REDUCTIONS`
195+
to one of the values defined in the table below. Applications can test for the
196+
existence of this macro to determine if the implementation supports this
197+
feature, or applications can test the macro's value to determine which of the
198+
extension's APIs the implementation supports.
199+
200+
|Value |Description|
201+
|:---- |:---------:|
202+
|1 |Initial extension version. Base features are supported.|

sycl/doc/extensions/SubGroup/SYCL_INTEL_sub_group.asciidoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,22 @@ Exact matching is required to ensure that developers can reason about the portab
317317
//*RESOLUTION*: Not resolved.
318318
//--
319319
320+
== Feature test macro
321+
322+
This extension provides a feature-test macro as described in the core SYCL
323+
specification section 6.3.3 "Feature test macros". Therefore, an implementation
324+
supporting this extension must predefine the macro `SYCL_EXT_ONEAPI_SUB_GROUP`
325+
to one of the values defined in the table below. Applications can test for the
326+
existence of this macro to determine if the implementation supports this
327+
feature, or applications can test the macro's value to determine which of the
328+
extension's APIs the implementation supports.
329+
330+
[%header,cols="1,5"]
331+
|===
332+
|Value |Description
333+
|1 |Initial extension version. Base features are supported.
334+
|===
335+
320336
== Revision History
321337
322338
[cols="5,15,15,70"]

sycl/doc/extensions/UsePinnedMemoryProperty/UsePinnedMemoryPropery.adoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,20 @@ This document describes an extension that introduces a +sycl::ext::oneapi::prope
2020
|`syc::ext::oneapi::property::buffer::use_pinned_host_memory`
2121
| The `use_pinned_host_memory` property adds the requirement that the SYCL runtime must allocate host pinned memory for the `sycl::buffer`. The property cannot be used with the `sycl::buffer` constructors that take hostData parameter, an invalid_object_error SYCL exception must be thrown in this case.
2222
|===
23+
24+
== Feature test macro
25+
26+
This extension provides a feature-test macro as described in the core SYCL
27+
specification section 6.3.3 "Feature test macros". Therefore, an implementation
28+
supporting this extension must predefine the macro
29+
`SYCL_EXT_ONEAPI_USE_PINNED_HOST_MEMORY_PROPERTY` to one of the values defined
30+
in the table below. Applications can test for the existence of this macro to
31+
determine if the implementation supports this feature, or applications can test
32+
the macro’s value to determine which of the extension’s APIs the implementation
33+
supports.
34+
35+
[%header,cols="1,5"]
36+
|===
37+
|Value |Description
38+
|1 |Initial extension version. Base features are supported.
39+
|===

sycl/include/CL/sycl/feature_test.hpp.in

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
__SYCL_INLINE_NAMESPACE(cl) {
1111
namespace sycl {
1212

13+
#ifdef __clang__
14+
#ifndef __has_extension
15+
#define __has_extension(x) 0
16+
#endif
17+
#endif
18+
1319
#define SYCL_BACKEND_OPENCL 1
1420

1521
// Feature test macro definitions
@@ -26,8 +32,28 @@ namespace sycl {
2632
#ifndef SYCL_EXT_ONEAPI_MATRIX
2733
#define SYCL_EXT_ONEAPI_MATRIX 2
2834
#endif
29-
#define SYCL_EXT_INTEL_BF16_CONVERSION 1
35+
#define SYCL_EXT_ONEAPI_ASSERT 1
3036
#define SYCL_EXT_ONEAPI_ENQUEUE_BARRIER 1
37+
#define SYCL_EXT_ONEAPI_FREE_FUNCTION_QUERIES 1
38+
#define SYCL_EXT_ONEAPI_GROUP_ALGORITHMS 1
39+
#define SYCL_EXT_ONEAPI_GROUP_SORT 1
40+
#define SYCL_EXT_ONEAPI_MAX_WORK_GROUP_QUERY 1
41+
#define SYCL_EXT_ONEAPI_ND_RANGE_REDUCTIONS 1
42+
#define SYCL_EXT_ONEAPI_DEFAULT_CONTEXT 1
43+
#define SYCL_EXT_ONEAPI_USE_PINNED_HOST_MEMORY_PROPERTY 1
44+
#define SYCL_EXT_ONEAPI_SUB_GROUP 1
45+
#define SYCL_EXT_INTEL_BF16_CONVERSION 1
46+
#define SYCL_EXT_INTEL_BITCAST 1
47+
#define SYCL_EXT_INTEL_DATAFLOW_PIPES 1
48+
#ifdef __clang__
49+
#if __has_extension(sycl_extended_atomics)
50+
#define SYCL_EXT_INTEL_EXTENDED_ATOMICS 1
51+
#endif
52+
#endif
53+
#define SYCL_EXT_INTEL_FPGA_DEVICE_SELECTOR 1
54+
#define SYCL_EXT_INTEL_FPGA_LSU 1
55+
#define SYCL_EXT_INTEL_FPGA_REG 1
56+
#define SYCL_EXT_INTEL_KERNEL_ARGS_RESTRICT 1
3157
#define SYCL_EXT_INTEL_MEM_CHANNEL_PROPERTY 1
3258
#define SYCL_EXT_INTEL_USM_ADDRESS_SPACES 1
3359
#define SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO 1
@@ -43,7 +69,6 @@ namespace sycl {
4369
#if SYCL_BUILD_PI_HIP
4470
#define SYCL_EXT_ONEAPI_BACKEND_HIP 1
4571
#endif
46-
#define SYCL_EXT_ONEAPI_MAX_WORK_GROUP_QUERY 1
4772

4873
} // namespace sycl
4974
} // __SYCL_INLINE_NAMESPACE(cl)

sycl/include/CL/sycl/platform.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ namespace detail {
2727
class platform_impl;
2828
}
2929

30-
// Feature test macro for Default Context
31-
#define SYCL_EXT_ONEAPI_DEFAULT_CONTEXT 1
32-
3330
/// Encapsulates a SYCL platform on which kernels may be executed.
3431
///
3532
/// \ingroup sycl_api

sycl/include/sycl/ext/oneapi/group_algorithm.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <sycl/ext/oneapi/functional.hpp>
2020
#include <sycl/ext/oneapi/sub_group.hpp>
2121

22-
#ifndef __DISABLE_SYCL_ONEAPI_GROUP_ALGORITHMS__
2322
__SYCL_INLINE_NAMESPACE(cl) {
2423
namespace sycl {
2524
namespace ext {
@@ -551,4 +550,3 @@ leader(Group g) {
551550

552551
} // namespace sycl
553552
} // __SYCL_INLINE_NAMESPACE(cl)
554-
#endif // __DISABLE_SYCL_ONEAPI_GROUP_ALGORITHMS__

sycl/include/sycl/ext/oneapi/group_sort.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616

1717
#include "experimental/group_helpers_sorters.hpp"
1818

19-
// define feature macro for group sorting algorithms
20-
#define SYCL_EXT_ONEAPI_GROUP_SORT 1
21-
2219
__SYCL_INLINE_NAMESPACE(cl) {
2320
namespace sycl {
2421
namespace ext {

0 commit comments

Comments
 (0)