Skip to content

Commit 295ad05

Browse files
committed
[SYCL] Add lightweight free-function kernel property headers
Introduce lightweight kernel-property headers for free-function kernel annotation and launch-tuning use cases: - function_properties.hpp provides a standalone path for execution-kind annotations such as nd_range_kernel and single_task_kernel. - function_launch_properties.hpp provides a lightweight path for launch properties such as work_group_size, work_group_size_hint, and sub_group_size. - kernel_properties/properties.hpp remains the umbrella path for full property-list semantics and cross-property conflict checking. This reduces compile-time cost for kernel-language and JIT-style usage while preserving the full umbrella interface for users who need complete property-list behavior. Measured header compile times: - function_properties.hpp: ~26 ms - function_launch_properties path: ~58 ms - kernel_properties/properties.hpp umbrella: ~68 ms
1 parent 9c1cb8a commit 295ad05

16 files changed

+630
-308
lines changed

sycl/doc/extensions/experimental/sycl_ext_oneapi_free_function_kernels.asciidoc

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,36 @@ supports.
112112
feature-test macro always has this value.
113113
|===
114114

115+
=== Headers
116+
117+
In the {dpcpp} implementation, applications that use this extension have a
118+
choice of headers depending on which properties they need:
119+
120+
* `#include <sycl/ext/oneapi/kernel_properties/function_properties.hpp>` is
121+
sufficient for `SYCL_EXT_ONEAPI_FUNCTION_PROPERTY`,
122+
`nd_range_kernel<Dims>`, and `single_task_kernel`.
123+
124+
* `#include <sycl/ext/oneapi/kernel_properties/function_launch_properties.hpp>`
125+
additionally provides the launch-configuration properties that may be applied
126+
directly to a free function kernel declaration, such as
127+
`work_group_size`, `work_group_size_hint`, `sub_group_size`,
128+
`max_work_group_size`, and `max_linear_work_group_size`.
129+
130+
* `#include <sycl/ext/oneapi/kernel_properties/properties.hpp>` provides the
131+
full kernel properties interface, including property lists such as
132+
`properties{...}` and embedded kernel properties via `properties_tag`.
133+
134+
Applications may include the umbrella header in all cases. The lighter-weight
135+
headers are intended for code that only needs function annotations on free
136+
function kernels and where reducing compile time is a priority.
137+
138+
The lighter-weight headers retain validation of each individual property, such
139+
as arity and non-zero size requirements, but they do not provide the
140+
cross-property validation that is performed when properties are combined via
141+
the full property-list machinery. For example, checks for conflicting
142+
combinations such as `work_group_size` together with `max_work_group_size` are
143+
available only through the umbrella header.
144+
115145
=== Defining a free function kernel
116146

117147
A free function kernel is a normal C++ function definition, where the function
@@ -803,6 +833,13 @@ in link:../experimental/sycl_ext_oneapi_kernel_properties.asciidoc[
803833
sycl_ext_oneapi_kernel_properties] by applying the properties to the function
804834
declaration as illustrated below.
805835

836+
In the {dpcpp} implementation, code that uses only function annotations may
837+
include either `function_properties.hpp` or
838+
`function_launch_properties.hpp` instead of the full
839+
`kernel_properties/properties.hpp` header. Applications that need property-list
840+
semantics, including cross-property validation, should include the umbrella
841+
header.
842+
806843
```
807844
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY((syclexp::nd_range_kernel<1>))
808845
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY((syclexp::work_group_size<32>))

sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_properties.asciidoc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,40 @@ supports.
115115
feature-test macro always has this value.
116116
|===
117117

118+
=== Headers
119+
120+
In the {dpcpp} implementation, the full API described in this extension is
121+
provided by:
122+
123+
* `#include <sycl/ext/oneapi/kernel_properties/properties.hpp>`
124+
125+
This umbrella header should be used when code needs property lists such as
126+
`properties{...}`, embedded kernel properties via `properties_tag`, or any of
127+
the non-launch kernel properties described in this extension.
128+
129+
The implementation also provides lighter-weight headers for code that only
130+
needs free-function annotations:
131+
132+
* `#include <sycl/ext/oneapi/kernel_properties/function_properties.hpp>` for
133+
`nd_range_kernel<Dims>`, `single_task_kernel`, and
134+
`SYCL_EXT_ONEAPI_FUNCTION_PROPERTY`.
135+
136+
* `#include <sycl/ext/oneapi/kernel_properties/function_launch_properties.hpp>`
137+
for the launch-configuration properties that can be applied directly to free
138+
function declarations, including `work_group_size`,
139+
`work_group_size_hint`, `sub_group_size`, `max_work_group_size`, and
140+
`max_linear_work_group_size`.
141+
142+
These lighter-weight headers are primarily intended for code paths where
143+
reduced compile time is a high priority and the application only needs
144+
function-level annotations.
145+
146+
They retain validation of each individual property, but they do not provide
147+
the cross-property validation that depends on forming a full property list.
148+
For example, checks for conflicting combinations such as `work_group_size`
149+
together with `max_work_group_size` or `max_linear_work_group_size` are
150+
performed only when using the umbrella header.
151+
118152
=== Kernel Properties
119153

120154
The kernel properties below correspond to kernel attributes defined in

sycl/include/sycl/ext/oneapi/experimental/virtual_functions.hpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
#include <sycl/ext/oneapi/kernel_properties/function_properties.hpp>
34
#include <sycl/ext/oneapi/properties/property.hpp>
45
#include <sycl/ext/oneapi/properties/property_utils.hpp>
56
#include <sycl/ext/oneapi/properties/property_value.hpp>
@@ -49,6 +50,17 @@ struct PropertyMetaInfo<indirectly_callable_key::value_t<Set>> {
4950
#endif
5051
};
5152

53+
template <typename Set>
54+
struct FunctionPropertyMetaInfo<indirectly_callable_key::value_t<Set>> {
55+
static constexpr const char *name = "indirectly-callable";
56+
static constexpr const char *value =
57+
#ifdef __SYCL_DEVICE_ONLY__
58+
__builtin_sycl_unique_stable_name(Set);
59+
#else
60+
"";
61+
#endif
62+
};
63+
5264
#ifdef __SYCL_DEVICE_ONLY__
5365
// Helper to concatenate several lists of characters into a single string.
5466
// Lists are separated from each other with comma within the resulting string.
@@ -105,6 +117,17 @@ struct PropertyMetaInfo<calls_indirectly_key::value_t<SetIds...>> {
105117
#endif
106118
};
107119

120+
template <typename... SetIds>
121+
struct FunctionPropertyMetaInfo<calls_indirectly_key::value_t<SetIds...>> {
122+
static constexpr const char *name = "calls-indirectly";
123+
static constexpr const char *value =
124+
#ifdef __SYCL_DEVICE_ONLY__
125+
UniqueStableNameListStr<SetIds...>::value;
126+
#else
127+
"";
128+
#endif
129+
};
130+
108131
} // namespace detail
109132

110133
} // namespace ext::oneapi::experimental

0 commit comments

Comments
 (0)