Skip to content

Commit 73fa014

Browse files
author
Alexander Batashev
authored
[SYCL][Doc] Fix KernelParameterPassing.md markup (#2077)
1 parent b903854 commit 73fa014

File tree

2 files changed

+27
-25
lines changed

2 files changed

+27
-25
lines changed

sycl/doc/KernelParameterPassing.md

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<h2>SYCL Kernel Parameter Handling and Array Support</h2>
1+
# SYCL Kernel Parameter Handling and Array Support
22

3-
<h3>Introduction</h3>
3+
## Introduction
44

55
This document describes how parameters of SYCL kernels are passed
66
from host to device. Support for arrays as kernel parameters was added
@@ -28,7 +28,8 @@ The first few sections describe the overall design.
2828
The last three sections provide additional details of array support.
2929
The implementation of this design is confined to four classes in the
3030
file `SemaSYCL.cpp`.
31-
<h3>A SYCL Kernel</h3>
31+
32+
## A SYCL Kernel
3233

3334
The SYCL constructs `single_task`, `parallel_for`, and
3435
`parallel_for_work_group` each take a function object or a lambda function
@@ -37,7 +38,7 @@ lambda function is executed on the device.
3738
To enable execution of the kernel on OpenCL devices, the lambda/function object
3839
is converted into the format of an OpenCL kernel.
3940

40-
<h3>SYCL Kernel Code Generation</h3>
41+
## SYCL Kernel Code Generation
4142

4243
Consider a source code example that captures an int, a struct and an accessor
4344
by value:
@@ -112,7 +113,7 @@ spir_kernel void caller(
112113
// Reassemble capture object from parts
113114
local.i = i;
114115
local.s = s;
115-
// Call accessors init function
116+
// Call accessor's init function
116117
sycl::accessor::init(&local.outAcc, AccData, AccR1, AccR2, I);
117118
118119
// Call the kernel body
@@ -140,7 +141,7 @@ host to device separately. The values received on the device
140141
are passed to the `init` functions executed on the device,
141142
which results in the reassembly of the SYCL object in a form usable on the device.
142143

143-
There is one other aspect of code generation. An integration header
144+
There is one other aspect of code generation. An "integration header"
144145
is generated for use during host compilation.
145146
This header file contains entries for each kernel.
146147
Among the items it defines is a table of sizes and offsets of the
@@ -169,7 +170,7 @@ object which contains three values:
169170
The previous sections described how kernel arguments are handled today.
170171
The next three sections describe support for arrays.
171172

172-
<h3>Fix 1: Kernel Arguments that are Standard-Layout Arrays</h3>
173+
## Fix 1: Kernel Arguments that are Standard-Layout Arrays
173174

174175
As described earlier, each variable captured by a lambda that comprises a
175176
SYCL kernel becomes a parameter of the kernel caller function.
@@ -180,7 +181,7 @@ the purposes of passing to the device. Each array element is passed as a
180181
separate parameter. The array elements received on the device
181182
are copied into the array within the local capture object.
182183

183-
<h4>Source code fragment:</h4>
184+
**Source code fragment:**
184185

185186
```C++
186187
constexpr int num_items = 2;
@@ -197,7 +198,7 @@ are copied into the array within the local capture object.
197198
});
198199
```
199200
200-
<h4>Integration header produced:</h4>
201+
**Integration header produced:**
201202
202203
```C++
203204
static constexpr
@@ -211,7 +212,7 @@ const kernel_param_desc_t kernel_signatures[] = {
211212
212213
```
213214

214-
<h4>The changes to device code made to support this extension, in pseudo-code:</h4>
215+
**The changes to device code made to support this extension, in pseudo-code:**
215216

216217
```C++
217218
struct Capture {
@@ -238,22 +239,22 @@ spir_kernel void caller(
238239
// Initialize array using existing clang Initialization mechanisms
239240
local.array[0] = p_array_0;
240241
local.array[1] = p_array_1;
241-
// Call accessors init function
242+
// Call accessor's init function
242243
sycl::accessor::init(&local.outAcc, AccData, AccR1, AccR2, I);
243244

244245
callee(&local, id<1> wi);
245246
}
246247
```
247248

248-
<h3>Fix 2: Kernel Arguments that are Arrays of Accessors</h3>
249+
## Fix 2: Kernel Arguments that are Arrays of Accessors
249250

250251
Arrays of accessors are supported in a manner similar to that of a plain
251252
accessor. For each accessor array element, the four values required to
252253
call its init function are passed as separate arguments to the kernel.
253254
Reassembly within the kernel caller is done by calling the `init` functions
254255
of each accessor array element in ascending index value.
255256

256-
<h4>Source code fragment:</h4>
257+
**Source code fragment:**
257258

258259
```C++
259260
myQueue.submit([&](handler &cgh) {
@@ -269,7 +270,7 @@ of each accessor array element in ascending index value.
269270
});
270271
```
271272
272-
<h4>Integration header:</h4>
273+
**Integration header:**
273274
274275
```C++
275276
static constexpr
@@ -281,7 +282,7 @@ const kernel_param_desc_t kernel_signatures[] = {
281282
};
282283
```
283284

284-
<h4>Device code generated in pseudo-code form:</h4>
285+
**Device code generated in pseudo-code form:**
285286

286287
```C++
287288
struct Capture {
@@ -311,20 +312,20 @@ spir_kernel void caller(
311312
struct Capture local;
312313

313314
// Reassemble capture object from parts
314-
// Call outAcc accessors init function
315+
// Call outAcc accessor's init function
315316
sycl::accessor::init(&local.outAcc, outAccData, outAccR1, outAccR2, outI);
316317

317-
// Call inAcc[0] accessors init function
318+
// Call inAcc[0] accessor's init function
318319
sycl::accessor::init(&local.inAcc[0], inAccData_0, inAccR1_0, inAccR2_0, inI_0);
319320

320-
// Call inAcc[1] accessors init function
321+
// Call inAcc[1] accessor's init function
321322
sycl::accessor::init(&local.inAcc[1], inAccData_1, inAccR1_1, inAccR2_1, inI_1);
322323

323324
callee(&local, id<1> wi);
324325
}
325326
```
326327

327-
<h3>Fix 3: Accessor Arrays within Structs</h3>
328+
## Fix 3: Accessor Arrays within Structs
328329

329330
Kernel parameters that are structs are traversed member
330331
by member, recursively, to enumerate member structs that are one of
@@ -340,7 +341,7 @@ Within the kernel caller function, the lambda object is reassembled
340341
in a manner similar to other instances of accessor arrays.
341342

342343

343-
<h4>Source code fragment:</h4>
344+
**Source code fragment:**
344345

345346
```C++
346347
myQueue.submit([&](handler &cgh) {
@@ -361,7 +362,7 @@ in a manner similar to other instances of accessor arrays.
361362
});
362363
```
363364

364-
<h4>Integration header:</h4>
365+
**Integration header:**
365366

366367
```C++
367368
static constexpr
@@ -375,7 +376,7 @@ const kernel_param_desc_t kernel_signatures[] = {
375376
};
376377
```
377378

378-
<h4>Device code generated in pseudo-code form:</h4>
379+
**Device code generated in pseudo-code form:**
379380

380381
```C++
381382
struct Capture {
@@ -411,15 +412,15 @@ spir_kernel void caller(
411412
local.s = s;
412413

413414
// 2. Initialize accessors by calling init functions
414-
// 2a. Call outAcc accessors init function
415+
// 2a. Call outAcc accessor's init function
415416
sycl::accessor::init(
416417
&local.outAcc, outAccData, outAccR1, outAccR2, outI);
417418

418-
// 2b. Call s.inAcc[0] accessors init function
419+
// 2b. Call s.inAcc[0] accessor's init function
419420
sycl::accessor::init(
420421
&local.s.inAcc[0], inAccData_0, inAccR1_0, inAccR2_0, inI_0);
421422

422-
// 2c. Call s.inAcc[1] accessors init function
423+
// 2c. Call s.inAcc[1] accessor's init function
423424
sycl::accessor::init(
424425
&local.s.inAcc[1], inAccData_1, inAccR1_1, inAccR2_1, inI_1);
425426

sycl/doc/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Developing oneAPI DPC++ Compiler
2323

2424
API Reference <https://intel.github.io/llvm-docs/doxygen>
2525
CompilerAndRuntimeDesign
26+
KernelParameterPassing
2627
EnvironmentVariables
2728
PluginInterface
2829
ABIPolicyGuide

0 commit comments

Comments
 (0)