commit | a45130f85aab87ee1824ce926d9c3d2957275d9a | [log] [tgz] |
---|---|---|
author | David Spickett <david.spickett@linaro.org> | Wed Oct 09 09:13:26 2024 +0100 |
committer | Copybara-Service <copybara-worker@google.com> | Wed Oct 09 01:15:11 2024 -0700 |
tree | e17173ea1aa06ffd60a0f4d0dda941b7fbcf147f | |
parent | 47929e7acc164760da741f5c5a474a210f37635a [diff] |
[libclc] Give a helpful error when an unknown target is requested (#111528) I just tried using LLVM backend names here e.g. NVPTX but libclc want's targets more like triples. This change adds a mesasge to tell you that. Before you got: ``` libclc target 'AMDGCN' is enabled CMake Error at CMakeLists.txt:253 (list): list index: 1 out of range (-1, 0) CMake Error at CMakeLists.txt:254 (list): list index: 2 out of range (-1, 0) Configuring incomplete, errors occurred! ``` Now you get: ``` CMake Error at CMakeLists.txt:145 (message): Unknown target in LIBCLC_TARGETS_TO_BUILD: "AMDGCN" Valid targets are: amdgcn--;amdgcn--amdhsa;clspv--;clspv64--;r600--;nvptx--;nvptx64--;nvptx--nvidiacl;nvptx64--nvidiacl;amdgcn-mesa-mesa3d ``` Some of the targets are dynamic based on what is installed, so spirv isn't here for me because I don't have llvm-spirv installed yet. So this is not perfect but it's an improvement on the current behaviour. GitOrigin-RevId: a4de127086ba4e39effb28642973edbb758e9656
libclc is an open source implementation of the library requirements of the OpenCL C programming language, as specified by the OpenCL 1.1 Specification. The following sections of the specification impose library requirements:
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.
libclc currently supports PTX, AMDGPU, SPIRV and CLSPV targets, but support for more targets is welcome.
(in the following instructions you can use make
or ninja
)
For an in-tree build, Clang must also be built at the same time:
$ cmake <path-to>/llvm-project/llvm/CMakeLists.txt -DLLVM_ENABLE_PROJECTS="libclc;clang" \ -DCMAKE_BUILD_TYPE=Release -G Ninja $ ninja
Then install:
$ ninja install
Note you can use the DESTDIR
Makefile variable to do staged installs.
$ DESTDIR=/path/for/staged/install ninja install
To build out of tree, or in other words, against an existing LLVM build or install:
$ cmake <path-to>/llvm-project/libclc/CMakeLists.txt -DCMAKE_BUILD_TYPE=Release \ -G Ninja -DLLVM_DIR=$(<path-to>/llvm-config --cmakedir) $ ninja
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 is all
.
In both cases, the LLVM used must include the targets you want libclc support for (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 available. Either build this in-tree, or place it in the directory pointed to by LLVM_TOOLS_BINARY_DIR
.