@@ -33,8 +33,7 @@ header" which provides information like kernel name, parameters order and data
33
33
type for the runtime library.
34
34
- ** Middle-end** - transforms the initial LLVM IR* to get consumed by the
35
35
back-end. Today middle-end transformations include just a couple of passes:
36
- - OpenCL C++* to SPIR-V* built-in function names mapper
37
- - Address space handling pass
36
+ - Optionally: Address space inference pass
38
37
- TBD: potentially the middle-end optimizer can run any LLVM IR
39
38
transformation with only one limitation: back-end compiler should be able to
40
39
handle transformed LLVM IR.
@@ -109,38 +108,38 @@ invoking kernels (such as `parallel_for`). For example, in the previous code
109
108
snippet above `accessor` `A` is one such captured kernel argument.
110
109
111
110
To facilitate the mapping of the captures/fields of lambdas/functors to OpenCL
112
- kernel and overcome OpenCL limitations we added the generation of a "kernel
113
- wrapper" function inside the compiler. A "kernel wrapper" function contains the
111
+ kernel and overcome OpenCL limitations we added the generation of an OpenCL
112
+ kernel function inside the compiler. An OpenCL kernel function contains the
114
113
body of the SYCL kernel function, receives OpenCL like parameters and
115
114
additionally does some manipulation to initialize captured lambda/functor fields
116
- with these parameters. In some pseudo code the " kernel wrapper" for the previous
117
- code snippet above looks like this:
115
+ with these parameters. In some pseudo code the OpenCL kernel function for the
116
+ previous code snippet above looks like this:
118
117
119
118
```C++
120
119
121
- // Let the lambda expression passed to the parallel_for declare unnamed
122
- // function object with "Lambda" type.
123
-
124
120
// SYCL kernel is defined in SYCL headers:
125
- __attribute__((sycl_kernel)) someSYCLKernel(Lambda lambda) {
126
- lambda();
121
+ template <typename KernelName, typename KernelType/*, ...*/>
122
+ __attribute__((sycl_kernel)) void sycl_kernel_function(KernelType KernelFuncObj) {
123
+ // ...
124
+ KernelFuncObj();
127
125
}
128
126
129
- // Kernel wrapper
130
- __kernel wrapper(global int* a) {
131
- Lambda lambda; // Actually lambda declaration doesn't have a name in AST
132
- // Let the lambda have one captured field - accessor A. We need to init it
133
- // with global pointer from arguments:
134
- lambda.A.__init(a);
135
- // Body of SYCL kernel from SYCL headers:
127
+ // Generated OpenCL kernel function
128
+ __kernel KernelName(global int* a) {
129
+ KernelType KernelFuncObj; // Actually kernel function object declaration
130
+ // doesn't have a name in AST.
131
+ // Let the kernel function object have one captured field - accessor A.
132
+ // We need to init it with global pointer from arguments:
133
+ KernelFuncObj.A.__init(a);
134
+ // Body of the SYCL kernel from SYCL headers:
136
135
{
137
- lambda ();
136
+ KernelFuncObj ();
138
137
}
139
138
}
140
139
141
140
```
142
141
143
- "Kernel wrapper" is generated by the compiler inside the Sema using AST nodes.
142
+ OpenCL kernel function is generated by the compiler inside the Sema using AST nodes.
144
143
145
144
### SYCL support in the driver
146
145
0 commit comments