Skip to content

Commit 8b57306

Browse files
[C++ for OpenCL] Add section w/ kernel function restrictions. (#583)
Co-authored-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
1 parent 86afed1 commit 8b57306

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

CXX_for_OpenCL.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ include::cxx4opencl/diff2openclc.txt[]
4646

4747
include::cxx4opencl/address_spaces.txt[]
4848

49+
<<<<
50+
51+
include::cxx4opencl/kernel.txt[]
52+
4953
<<<
5054

5155
include::cxx4opencl/references.txt[]

cxx4opencl/kernel.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2021 The Khronos Group. This work is licensed under a
2+
// Creative Commons Attribution 4.0 International License; see
3+
// http://creativecommons.org/licenses/by/4.0/
4+
5+
[[kernel_function]]
6+
=== Kernel functions
7+
8+
Kernel functions have implicit C linkage ({cpp}17 `[dcl.link]`) which
9+
means that {cpp} specific features are not supported. Therefore, the kernel
10+
functions:
11+
12+
* Can not be class members ({cpp}17 `[class.mfct]`);
13+
* Can not be overloaded ({cpp}17 `[over]`);
14+
* Can not be function templates ({cpp}17 `[temp.fct]`).
15+
16+
:fn-ker-par-ref: footnote:[Whether C++ features (e.g references) can be used \
17+
in functions with C linkage is implementation-defined ({cpp}17 [dcl.link\]).]
18+
19+
Moreover the types used in parameters of the kernel functions must be:
20+
21+
* Trivial and standard-layout types {cpp}17 `[basic.types]` (plain old data
22+
types) for parameters passed by value;
23+
* Standard layout types for pointer parameters. The same applies to
24+
references{fn-ker-par-ref} if an implementation supports them in kernel
25+
parameters.
26+
27+
These are additional restrictions to the list detailed in `OpenCL C v2.0
28+
section 6.9`.

0 commit comments

Comments
 (0)