Commit 4db72d5
authored
[SYCL] Lift restriction that prevents us from using free function kernel queries in device compilation mode (#17398)
Free function kernel queries can, at the moment, only be used in host
compilation mode requiring us to add `#ifndef __SYCL_DEVICE_ONLY__ `
directives to get code that uses them to compile. This PR removes this
restriction and the instances of the workaround used in our tests.
My understanding is the following:
The current implementation employs SFINAE using the predicate
`is_kernel_v<Func>` to delete at compile time queries that are
instantiated with a `Func` that is not a free function kernel. This is
certainly a reasonable interpretation of the spec which says :
`Constraints: Available only if is_kernel_v<Func> is true.` for each
query.
However, this causes a problem. During the device front-end compiler
phase of our toolchain, information is gathered regarding what the free
function kernels are as defined in the code provided by the user. This
means during this phase itself, `Func` will be treated as an invalid
free function kernel name since this information becomes known only
after the front-end has finished executing. And because SFINAE interacts
with the front-end mechanisms, we get a hard error in this phase of
compilation about a missing function.
One simple fix, proposed in this PR, is to simply define the trait
`is_kernel_v<Func>` to be constantly true in device compilation mode
regardless of `Func`.
This will ensure device front-end succeeds since a declaration of the
query exists and it still interprets the spec reasonably because if
`Func` does not represent a kernel, then during host compilation the
declaration will not be available because the `is_kernel` trait fails
which will print a nice message to the user saying what went wrong.1 parent 6dbe186 commit 4db72d5
File tree
22 files changed
+20
-94
lines changed- sycl
- include/sycl
- ext/oneapi/experimental
- test-e2e
- DeviceImageBackendContent
- DeviceImageDependencies
- NewOffloadDriver
- Graph
- Inputs
- Update/FreeFunctionKernels
- KernelAndProgram
- WorkGroupMemory
22 files changed
+20
-94
lines changedLines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
32 | 40 | | |
| 41 | + | |
33 | 42 | | |
34 | 43 | | |
35 | 44 | | |
36 | 45 | | |
37 | 46 | | |
38 | 47 | | |
39 | 48 | | |
40 | | - | |
| 49 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
491 | 491 | | |
492 | 492 | | |
493 | 493 | | |
494 | | - | |
495 | 494 | | |
496 | 495 | | |
497 | 496 | | |
| |||
838 | 837 | | |
839 | 838 | | |
840 | 839 | | |
841 | | - | |
842 | 840 | | |
843 | 841 | | |
844 | 842 | | |
| |||
866 | 864 | | |
867 | 865 | | |
868 | 866 | | |
869 | | - | |
870 | 867 | | |
871 | 868 | | |
872 | 869 | | |
| |||
Lines changed: 1 addition & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | 26 | | |
30 | 27 | | |
31 | 28 | | |
| |||
90 | 87 | | |
91 | 88 | | |
92 | 89 | | |
93 | | - | |
94 | 90 | | |
Lines changed: 1 addition & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | 28 | | |
32 | 29 | | |
33 | 30 | | |
| |||
77 | 74 | | |
78 | 75 | | |
79 | 76 | | |
80 | | - | |
81 | 77 | | |
Lines changed: 1 addition & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
82 | | - | |
83 | | - | |
84 | 83 | | |
85 | 84 | | |
86 | 85 | | |
| |||
98 | 97 | | |
99 | 98 | | |
100 | 99 | | |
101 | | - | |
102 | 100 | | |
103 | 101 | | |
104 | 102 | | |
| |||
131 | 129 | | |
132 | 130 | | |
133 | 131 | | |
134 | | - | |
135 | | - | |
136 | 132 | | |
137 | 133 | | |
138 | 134 | | |
| |||
151 | 147 | | |
152 | 148 | | |
153 | 149 | | |
154 | | - | |
155 | 150 | | |
156 | 151 | | |
157 | 152 | | |
| |||
189 | 184 | | |
190 | 185 | | |
191 | 186 | | |
192 | | - | |
193 | | - | |
194 | 187 | | |
195 | 188 | | |
196 | 189 | | |
| |||
208 | 201 | | |
209 | 202 | | |
210 | 203 | | |
211 | | - | |
212 | 204 | | |
213 | 205 | | |
214 | 206 | | |
| |||
250 | 242 | | |
251 | 243 | | |
252 | 244 | | |
253 | | - | |
254 | | - | |
255 | 245 | | |
256 | 246 | | |
257 | 247 | | |
| |||
269 | 259 | | |
270 | 260 | | |
271 | 261 | | |
272 | | - | |
273 | 262 | | |
274 | 263 | | |
275 | 264 | | |
| |||
Lines changed: 1 addition & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
81 | | - | |
82 | | - | |
83 | 82 | | |
84 | 83 | | |
85 | 84 | | |
| |||
97 | 96 | | |
98 | 97 | | |
99 | 98 | | |
100 | | - | |
101 | 99 | | |
102 | 100 | | |
103 | 101 | | |
| |||
130 | 128 | | |
131 | 129 | | |
132 | 130 | | |
133 | | - | |
134 | | - | |
135 | 131 | | |
136 | 132 | | |
137 | 133 | | |
| |||
150 | 146 | | |
151 | 147 | | |
152 | 148 | | |
153 | | - | |
154 | 149 | | |
155 | 150 | | |
156 | 151 | | |
| |||
188 | 183 | | |
189 | 184 | | |
190 | 185 | | |
191 | | - | |
192 | | - | |
193 | 186 | | |
194 | 187 | | |
195 | 188 | | |
| |||
207 | 200 | | |
208 | 201 | | |
209 | 202 | | |
210 | | - | |
211 | 203 | | |
212 | 204 | | |
213 | 205 | | |
| |||
249 | 241 | | |
250 | 242 | | |
251 | 243 | | |
252 | | - | |
253 | | - | |
254 | 244 | | |
255 | 245 | | |
256 | 246 | | |
| |||
268 | 258 | | |
269 | 259 | | |
270 | 260 | | |
271 | | - | |
272 | 261 | | |
273 | 262 | | |
274 | 263 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
| |||
38 | 37 | | |
39 | 38 | | |
40 | 39 | | |
41 | | - | |
42 | 40 | | |
43 | 41 | | |
44 | 42 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
| |||
57 | 56 | | |
58 | 57 | | |
59 | 58 | | |
60 | | - | |
61 | 59 | | |
62 | 60 | | |
63 | 61 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
| |||
52 | 51 | | |
53 | 52 | | |
54 | 53 | | |
55 | | - | |
56 | 54 | | |
57 | 55 | | |
58 | 56 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
| |||
69 | 68 | | |
70 | 69 | | |
71 | 70 | | |
72 | | - | |
73 | 71 | | |
74 | 72 | | |
75 | 73 | | |
| |||
0 commit comments