2024-10-08 16:58:02 +01:00
|
|
|
# libclc
|
2012-01-08 22:09:58 +00:00
|
|
|
|
2024-10-07 15:26:04 +01:00
|
|
|
libclc is an open source implementation of the library
|
2012-01-08 22:09:58 +00:00
|
|
|
requirements of the OpenCL C programming language, as specified by the
|
|
|
|
OpenCL 1.1 Specification. The following sections of the specification
|
|
|
|
impose library requirements:
|
|
|
|
|
2024-10-08 16:58:02 +01:00
|
|
|
* 6.1: Supported Data Types
|
|
|
|
* 6.2.3: Explicit Conversions
|
|
|
|
* 6.2.4.2: Reinterpreting Types Using as_type() and as_typen()
|
|
|
|
* 6.9: Preprocessor Directives and Macros
|
|
|
|
* 6.11: Built-in Functions
|
|
|
|
* 9.3: Double Precision Floating-Point
|
|
|
|
* 9.4: 64-bit Atomics
|
|
|
|
* 9.5: Writing to 3D image memory objects
|
|
|
|
* 9.6: Half Precision Floating-Point
|
2012-01-08 22:09:58 +00:00
|
|
|
|
|
|
|
libclc is intended to be used with the Clang compiler's OpenCL frontend.
|
|
|
|
|
|
|
|
libclc is designed to be portable and extensible. To this end, it provides
|
|
|
|
generic implementations of most library requirements, allowing the target
|
|
|
|
to override the generic implementation at the granularity of individual
|
|
|
|
functions.
|
|
|
|
|
2024-10-08 16:23:42 +01:00
|
|
|
libclc currently supports PTX, AMDGPU, SPIRV and CLSPV targets, but support for
|
|
|
|
more targets is welcome.
|
2012-01-08 22:09:58 +00:00
|
|
|
|
2024-10-08 16:58:02 +01:00
|
|
|
## Compiling and installing
|
2012-01-08 22:09:58 +00:00
|
|
|
|
2024-10-08 16:58:02 +01:00
|
|
|
(in the following instructions you can use `make` or `ninja`)
|
2014-01-29 20:03:28 +00:00
|
|
|
|
2024-10-08 16:23:42 +01:00
|
|
|
For an in-tree build, Clang must also be built at the same time:
|
2024-10-08 16:58:02 +01:00
|
|
|
```
|
2024-10-08 16:23:42 +01:00
|
|
|
$ cmake <path-to>/llvm-project/llvm/CMakeLists.txt -DLLVM_ENABLE_PROJECTS="libclc;clang" \
|
|
|
|
-DCMAKE_BUILD_TYPE=Release -G Ninja
|
|
|
|
$ ninja
|
2024-10-08 16:58:02 +01:00
|
|
|
```
|
2024-10-08 16:23:42 +01:00
|
|
|
Then install:
|
2024-10-08 16:58:02 +01:00
|
|
|
```
|
2014-01-29 20:03:28 +00:00
|
|
|
$ ninja install
|
2024-10-08 16:58:02 +01:00
|
|
|
```
|
|
|
|
Note you can use the `DESTDIR` Makefile variable to do staged installs.
|
|
|
|
```
|
2014-01-29 20:03:28 +00:00
|
|
|
$ DESTDIR=/path/for/staged/install ninja install
|
2024-10-08 16:58:02 +01:00
|
|
|
```
|
2024-10-08 16:23:42 +01:00
|
|
|
To build out of tree, or in other words, against an existing LLVM build or install:
|
2024-10-08 16:58:02 +01:00
|
|
|
```
|
2024-10-08 16:23:42 +01:00
|
|
|
$ cmake <path-to>/llvm-project/libclc/CMakeLists.txt -DCMAKE_BUILD_TYPE=Release \
|
|
|
|
-G Ninja -DLLVM_DIR=$(<path-to>/llvm-config --cmakedir)
|
|
|
|
$ ninja
|
2024-10-08 16:58:02 +01:00
|
|
|
```
|
2024-10-08 16:23:42 +01:00
|
|
|
Then install as before.
|
|
|
|
|
|
|
|
In both cases this will include all supported targets. You can choose which
|
|
|
|
targets are enabled by passing `-DLIBCLC_TARGETS_TO_BUILD` to CMake. The default
|
2024-10-08 16:58:02 +01:00
|
|
|
is `all`.
|
2024-10-08 16:23:42 +01:00
|
|
|
|
|
|
|
In both cases, the LLVM used must include the targets you want libclc support for
|
2024-10-08 16:58:02 +01:00
|
|
|
(`AMDGPU` and `NVPTX` are enabled in LLVM by default). Apart from `SPIRV` where you do
|
|
|
|
not need an LLVM target but you do need the
|
|
|
|
[llvm-spirv tool](https://github.com/KhronosGroup/SPIRV-LLVM-Translator) available.
|
|
|
|
Either build this in-tree, or place it in the directory pointed to by
|
|
|
|
`LLVM_TOOLS_BINARY_DIR`.
|
2024-10-08 16:23:42 +01:00
|
|
|
|
2024-10-08 16:58:02 +01:00
|
|
|
## Website
|
2012-01-08 22:09:58 +00:00
|
|
|
|
2020-05-28 22:33:14 +02:00
|
|
|
https://libclc.llvm.org/
|