Skip to content

Commit 8a75ec3

Browse files
Fznamznonbader
authored andcommitted
[SYCL] Align design document with recent changes (#260)
- Replace "kernel wrapper" with OpenCL kernel - Remove "OpenCL C++ to SPIR-V built-in function names mapper" Signed-off-by: Mariya Podchishchaeva <[email protected]>
1 parent d5c9e34 commit 8a75ec3

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

sycl/doc/SYCL_compiler_and_runtime_design.md

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ header" which provides information like kernel name, parameters order and data
3333
type for the runtime library.
3434
- **Middle-end** - transforms the initial LLVM IR* to get consumed by the
3535
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
3837
- TBD: potentially the middle-end optimizer can run any LLVM IR
3938
transformation with only one limitation: back-end compiler should be able to
4039
handle transformed LLVM IR.
@@ -109,38 +108,38 @@ invoking kernels (such as `parallel_for`). For example, in the previous code
109108
snippet above `accessor` `A` is one such captured kernel argument.
110109
111110
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
114113
body of the SYCL kernel function, receives OpenCL like parameters and
115114
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:
118117
119118
```C++
120119
121-
// Let the lambda expression passed to the parallel_for declare unnamed
122-
// function object with "Lambda" type.
123-
124120
// 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();
127125
}
128126
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:
136135
{
137-
lambda();
136+
KernelFuncObj();
138137
}
139138
}
140139
141140
```
142141

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.
144143

145144
### SYCL support in the driver
146145

0 commit comments

Comments
 (0)