Skip to content

Commit 4fbaea1

Browse files
Misc updates about C++ for OpenCL and SPIR-V.
This change adds information about C++ for OpenCL 2021 and replaces SPIR -> SPIR-V. With introduction of SPIR-V target in Clang/LLVM we should discourage the use of old SPIR everywhere.
1 parent 9ab3f70 commit 4fbaea1

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

chapters/cpp_for_opencl.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ clang -cl-std=CLC++ test.cl
9696
clang test.clcpp
9797
```
9898
99-
More details can be found in its [UsersManual](https://clang.llvm.org/docs/UsersManual.html#cxx-for-opencl). In the majority of cases the generated binary can be used in existing drivers. C++ for OpenCL version 1.0 is developed against OpenCL 2.0. Depending on the features used, drivers from other versions (e.g. OpenCL 3.0) might be able to load the binaries produced with C++ for OpenCL v1.0 too. Use of global objects and static function objects with non-trivial constructors is not supported in a portable way, refer to [the following clang documentation](https://clang.llvm.org/docs/UsersManual.html#constructing-and-destroying-global-objects) for details.
99+
More details can be found in its [UsersManual](https://clang.llvm.org/docs/UsersManual.html#cxx-for-opencl). In the majority of cases the generated binary can be used in existing drivers. C++ for OpenCL version 1.0 is developed against OpenCL 2.0. Depending on the features used, drivers from other versions (e.g. OpenCL 3.0) might be able to load the binaries produced with C++ for OpenCL v1.0 too. C++ for OpenCL version 2021 is developed for OpenCL 3.0 drivers. Use of global objects and static function objects with non-trivial constructors is not supported in a portable way, refer to [the following clang documentation](https://clang.llvm.org/docs/UsersManual.html#constructing-and-destroying-global-objects) for details.
100100
101-
Clang only supports a limited number of vendors and therefore to allow executing the binaries from C++ for OpenCL on more devices it is recommended to generate portable executable formats. C++ for OpenCL kernel sources can be compiled into SPIR-V using [open source tools](os_tooling.md) and then loaded into drivers supporting SPIR-V. C++ for OpenCL 1.0 mainly requires SPIR-V 1.0 plus SPIR-V 1.2 for some features.
101+
Clang only supports a limited number of vendors and therefore to allow executing the binaries from C++ for OpenCL on more devices it is recommended to generate portable executable formats. C++ for OpenCL kernel sources can be compiled into SPIR-V using [open source tools](os_tooling.md) and then loaded into drivers supporting SPIR-V. C++ for OpenCL 1.0 and 2021 mainly requires SPIR-V 1.0 plus SPIR-V 1.2 for some features.
102102
103103
The bugs and implementation of new features in clang can be tracked via the [OpenCL Support Page](https://clang.llvm.org/docs/OpenCLSupport.html#c-for-opencl-implementation-status).
104104

chapters/os_tooling.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This section describes available open source tools for offline compilation of Op
66

77
## Open Source Tools
88

9-
* [clang](https://clang.llvm.org/) is a compiler front-end for the C/C++ family of languages, including OpenCL C and C++ for OpenCL. It can produce executable binaries (e.g. AMDGPU), or portable binaries (e.g. SPIR). It is part of [the LLVM compiler infrastructure project](https://llvm.org/), and there is information regarding [OpenCL kernel language support and standard headers](https://clang.llvm.org/docs/UsersManual.html#opencl-features).
9+
* [clang](https://clang.llvm.org/) is a compiler front-end for the C/C++ family of languages, including OpenCL C and C++ for OpenCL. It can produce executable binaries (e.g. AMDGPU), or portable binaries (e.g. SPIR-V). It is part of [the LLVM compiler infrastructure project](https://llvm.org/), and there is information regarding [OpenCL kernel language support and standard headers](https://clang.llvm.org/docs/UsersManual.html#opencl-features).
1010
* [SPIRV-LLVM Translator](https://github.com/KhronosGroup/SPIRV-LLVM-Translator) provides a library and the __llvm-spirv__ tool for bidirectional translation between LLVM IR and SPIR-V.
1111
* [clspv](https://github.com/google/clspv) compiler and [clvk](https://github.com/kpet/clvk) runtime layer enable OpenCL applications to be executed with Vulkan drivers.
1212
* [SPIR-V Tools](https://github.com/KhronosGroup/SPIRV-Tools) provide a set of utilities to process SPIR-V binaries including __spirv-opt__ optimizer, __spirv-link__ linker, __spirv-dis__/__spirv-as__ (dis-)assembler, and __spirv-val__ validator.
@@ -31,23 +31,23 @@ If you want to try the above compilation flow for yourself, after installing the
3131

3232
##### Compile for OpenCL runtime
3333

34-
__(i)__ Compiling OpenCL C/C++ for OpenCL file into SPIR flavor LLVM IR (for 32 bit targets) formats:
34+
__(i)__ Compiling OpenCL C/C++ for OpenCL file into SPIR-V flavor LLVM IR (for 32 bit targets) formats:
3535

3636
```
37-
clang -c -target spir -O0 -emit-llvm -o test.bc test.cl
37+
clang -c -target spirv32 -O0 -emit-llvm -o test.bc test.cl
3838
```
3939
Using `-cl-std` changes the language version compiled for.
4040

4141
To compile C++ for OpenCL source pass `-cl-std=CLC++` or use the file extension `.clcpp`.
4242

4343
```
44-
clang -cl-std=CLC++ -c -target spir -O0 -emit-llvm -o test.bc test.cl
45-
clang -c -target spir -O0 -emit-llvm -o test.bc test.clcpp
44+
clang -cl-std=CLC++ -c -target spirv32 -O0 -emit-llvm -o test.bc test.cl
45+
clang -c -target spirv32 -O0 -emit-llvm -o test.bc test.clcpp
4646
```
4747
If debugging support is needed then the `-g` flag can be used in the clang invocation:
4848

4949
```
50-
clang -c test.cl -target spir -o test.bc -g
50+
clang -c test.cl -target spirv32 -o test.bc -g
5151
```
5252

5353
__Note:__ In clang releases up to 12.0, calling most builtin functions requires the extra flags `-Xclang -finclude-default-header` to be passed to clang. Refer to the release documentation for more details.

0 commit comments

Comments
 (0)