commit | 858ff3198ec31e9116ac2bbae0b7d9496488055b | [log] [tgz] |
---|---|---|
author | Marco Antognini <marco.antognini@arm.com> | Wed Aug 26 19:47:40 2020 |
committer | GitHub <noreply@github.com> | Wed Aug 26 19:47:40 2020 |
tree | 7000856b4c43662a934c8ff0ec668a34ae52cb06 | |
parent | ad1a12f27c8eb4c4f26f5b4b5d680b564e6cb132 [diff] |
Various improvements to the compilation process (#621) * Improve support for shared build Fix compilation for clspv-reflection when doing a shared-library build. - Add clspv_passes to the public list of dependencies of clspv_core so that clspv-opt, clspv-reflection and any other target depending on clspv_core don't have to link against the dependencies of clspv_passes. - Remove unnecessary dependencies of clspv-opt now that they are transitively added thanks to the previous point. - Move clangCodeGen dependency to clspv_core because it isn't used by clsvp_passes. - Because SPIRV-Tools-shared has hidden symbol visibility, some symbols are undefined when linking against SPIRV-Tools (which is an alias for SPIRV-Tools-shared or SPIRV-Tools-static based on build options). This is worked around by always linking against SPIRV-Tools-static, regardless of the build options. - Don't explicitly list LLVM components as dependencies as this is resolved automatically by CMake. Signed-off-by: Marco Antognini <marco.antognini@arm.com> * Improve support for static build Use OBJECT library for clspv_passes to ensure all the symbols for global static variables are present in clspv-opt, ensuring passes using a static RegisterPass<> object are registered. This is effectively equivalent to using the linker option --whole-archive for static build, but in a more portable way as not all toolchains support this option. Previously, the output of `clspv-opt --help-hidden` and `clspv --help-hidden` would differ from a shared library build to a static library build. There are still some differences but they seem to be unrelated to clspv passes but rather related to LLVM passes. The MultiVersionUBOFunctionsPass pass is using such a global static object. Update existing test to cover this pass. Bump required CMake version. Chose 3.13.4 as it is required by the latest LLVM and it supports linking against OBJECT libraries. Add a missing dependency of clspv_passes that was identified by using OBJECT library when using a shared build. 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