commit | 7e3384083dea346970464d4ae3dfe90c9013a98d | [log] [tgz] |
---|---|---|
author | Marco Antognini <marco.antognini@arm.com> | Mon Mar 15 12:48:37 2021 |
committer | GitHub <noreply@github.com> | Mon Mar 15 12:48:37 2021 |
tree | d7ebad34001b3a8caa35cb15c1a5cf6c94471425 | |
parent | 869cd683ddee9c12fce442e1e0c920263a447ca5 [diff] |
Fix compilation for 32-bit systems (#717) * Fix compilation for 32-bit systems Include HandleLLVMOptions to ensure LLVM and clspv components are compiled using the same defines (for example -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE). This essentially fixes this undefined reference to clang::FileManager::getVirtualFile(llvm::StringRef, long, long) while the following was actually defined clang::FileManager::getVirtualFile(llvm::StringRef, long long, long) . As a consequence, the compilation and link options are updated and require fixes to the dependency lists of clspv_passes and clspv_core. Signed-off-by: Marco Antognini <marco.antognini@arm.com> * Address warnings With the previous update, additional warnings are generated by default. This patch addresses these: * -Wunused-function: use `inline` instead of `static` in header. * -Wunused-but-set-variable: code is protected in #ifndef NDEBUG when it is only used for the purpose of assertions. * -Wunused-function and -Wunused-but-set-variable: dead code is removed. * -Wsign-compare: uses of `auto` are replaced with `unsigned` or `size_t`, or use `static_cast`. * -Wimplicit-fallthrough: this warning is silenced using special comments. * -Wpedantic: remove extra `;` on closing brace for namespace. * -Woverflow: use types explicitly sized (e.g. std::uint64_t) and appropriate macros for minimum-width integer constants instead of size_t. Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Clspv is a prototype compiler for a subset of OpenCL C to Vulkan compute shaders.
It consists of:
Clspv depends on external projects:
Clspv is licensed under the terms of the Apache 2.0 license. The AUTHORS file lists the copyright owners, while individual credit is given in the CONTRIBUTORS file. To contribute, see CONTRIBUTING.md.
Materials in projects Clspv depends on are licensed under their own terms.
Clspv is not an official Google product.
The compiler is an incomplete prototype, with many rough edges.
The input language is a subset of OpenCL C version 1.2. The OpenCL C on Vulkan Specification describes the specific subset, and also the mapping into Vulkan compute shaders.
Compile a set of kernels into a SPIR-V binary module:
clspv foo.cl -o foo.spv
Emit the binary as a C initializer list, for easy embedding of a shader in in a C or C++ program source:
clspv -mfmt=c foo.cl -o -
Predefine some preprocessor symbols:
clspv -DWIDTH=32 -DHEIGHT=64 foo.cl -o foo.spv
Use OpenCL compiler options:
clspv -cl-fast-relaxed-math -cl-single-precision-constant foo.cl -o foo.spv
Show help:
clspv -help
You will need:
Clspv depends on the sources for other projects, at specific commits. Run the following command to download those dependencies, and place them in the third_party
directory:
python3 utils/fetch_sources.py
Then, create a build directory:
cd <clspv-dir> mkdir build cd build
Then configure and build the code:
cmake <clspv-dir> cmake --build .
This will build the clspv
command line compiler and place it in location bin/clspv
under the build directory.
We recommend you use the Ninja build tool if it's available. To do so, replace the last two commands with:
cmake -G Ninja <clspv-dir> ninja
Other useful configuration options (the first cmake
command):
-DCMAKE_BUILD_TYPE=RelWithDebInfo
: Build in release mode, with debugging information. Default is a debug build.See the CMake documentation for more generic options.
To run the test suite from within the build directory:
cmake --build . --target check-spirv
Or if you are using Ninja:
ninja check-spirv
Clspv includes an LLVM IR library (cmake/clspv--.bc) containing implementations of some OpenCL builtin functions. This file is distributed under the LLVM license (included in LICENSE) as it is generated from the LLVM sub-project libclc. Refer to the source for the relevant copyrights.
You will need a pre-built version of LLVM for your system, CMake, and (optionally) Ninja.
To rebuild the library run the following commands:
cmake -GNinja -DLIBCLC_TARGETS_TO_BUILD=“clspv--” -DLLVM_CONFIG= ninja
Copy the resulting clspv--.bc
into the cmake/ directory and rebuild clspv.