Skip to content

Commit aa06b99

Browse files
authored
[SYCL][Doc] Fix "grf_size" example (#21356)
The `grf_size` and `grf_size_automatic` properties are compile-time constant kernel properties. We used to have a way to pass these properties via `single_task` as the old example showed, but this was deprecated and removed a while ago. The proper way to decorate a kernel with a compile-time property now is to define a `get` function in the kernel's class.
1 parent 204f925 commit aa06b99

File tree

1 file changed

+35
-20
lines changed

1 file changed

+35
-20
lines changed

sycl/doc/extensions/experimental/sycl_ext_intel_grf_size.asciidoc

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ https://github.com/intel/llvm/issues
3636

3737
== Dependencies
3838

39-
This extension is written against the SYCL 2020 revision 7 specification. All
39+
This extension is written against the SYCL 2020 revision 11 specification. All
4040
references below to the "core SYCL specification" or to section numbers in the
4141
SYCL specification refer to that revision.
4242

@@ -87,7 +87,6 @@ the implementation supports this feature, or applications can test the macro's
8787
value to determine which of the extension's features the implementation
8888
supports.
8989

90-
9190
[%header,cols="1,5"]
9291
|===
9392
|Value
@@ -117,7 +116,9 @@ At most one of the `grf_size` and `grf_size_automatic` properties may be associa
117116
If a kernel is not associated with a `grf_size` or `grf_size_automatic` property, the manner in which the GRF size is selected is implementation-defined.
118117

119118
The properties are defined as follows:
120-
```c++
119+
120+
[source,c++]
121+
----
121122
namespace sycl::ext::intel::experimental {
122123
123124
struct grf_size_key {
@@ -138,8 +139,10 @@ inline constexpr grf_size_key::value_t<Size> grf_size;
138139
inline constexpr grf_size_automatic_key::value_t grf_size_automatic;
139140
140141
} // namespace sycl::ext::intel::experimental
141-
```
142+
----
143+
142144
The supported values are as follows:
145+
143146
[%header,cols="1,5"]
144147
|===
145148
|GPU |Supported Values
@@ -153,25 +156,37 @@ Providing a value not consistent with the supported values may result in undefin
153156

154157
A simple example of using this extension is below.
155158

156-
```c++
159+
[source,c++]
160+
----
161+
#include <sycl/sycl.hpp>
157162
namespace syclex = sycl::ext::oneapi::experimental;
158163
namespace intelex = sycl::ext::intel::experimental;
159-
{
160-
...
161-
syclex::properties kernel_properties{intelex::grf_size<256>};
162164
163-
q.single_task(kernel_properties, [=] {
164-
...
165-
}).wait();
166-
}
167-
{
168-
...
169-
syclex::properties kernel_properties{intelex:grf_size_automatic};
165+
struct Kernel1 {
166+
Kernel1() {}
170167
171-
q.single_task(kernel_properties, [=] {
172-
...
173-
}).wait();
174-
}
175-
```
168+
void operator()(sycl::nd_item<1> it) const { /* ... */ }
176169
170+
auto get(syclex::properties_tag) const {
171+
return syclex::properties{intelex::grf_size<256>};
172+
}
173+
};
177174
175+
struct Kernel2 {
176+
Kernel2() {}
177+
178+
void operator()(sycl::nd_item<1> it) const { /* ... */ }
179+
180+
auto get(syclex::properties_tag) const {
181+
return syclex::properties{intelex::grf_size_automatic};
182+
}
183+
};
184+
185+
int main() {
186+
sycl::queue q;
187+
188+
sycl::nd_range ndr{{256},{16}};
189+
q.parallel_for(ndr, Kernel1{}).wait();
190+
q.parallel_for(ndr, Kernel2{}).wait();
191+
}
192+
----

0 commit comments

Comments
 (0)