commit | 3dc76a474f7124a198230dab091f9c5ecb05f170 | [log] [tgz] |
---|---|---|
author | Fraser Cormack <fraser@codeplay.com> | Tue Nov 12 16:18:33 2024 +0000 |
committer | Copybara-Service <copybara-worker@google.com> | Tue Nov 12 08:19:31 2024 -0800 |
tree | 820056b2e8fbd7ae1022f83b5fbe703f7cbd95eb | |
parent | a0a4f277f7b0f83156c3a41c7957ac538cad584a [diff] |
[libclc] Use builtin_convertvector to convert between vector types (#115865) This keeps values in vectors, rather than scalarizing them and then reconstituting the vector. The builtin is identical to performing a C-style cast on each element, which is what we were doing by recursively splitting the vector down to calling the "base" conversion function on each element. GitOrigin-RevId: 0d2ef7af1956b463b87a09500bd87bd4147616d4
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
.