Clone this repo:
  1. b8f94af add OWNERS file by Romaric Jodin · 3 years, 2 months ago factory-brya-14517.B factory-cherry-14455.B factory-guybrush-14600.B factory-kukui-14374.B firmware-android-brya-14505.782.B firmware-brya-14505.534.B firmware-brya-14505.71.B firmware-brya-14505.B firmware-cherry-14454.B firmware-cr50-stab-14294.B firmware-cr50-stab-mp-14300.B firmware-firmware-android-brya-recipe-test-14505.782.B firmware-guybrush-14500.B main release-R100-14526.B release-R101-14588.B release-R102-14695.B release-R97-14324.B release-R98-14388.B release-R99-14469.B stabilize-14285.B stabilize-14312.B stabilize-14321.B stabilize-14324.13.B stabilize-14324.41.B stabilize-14324.62.B stabilize-14324.72.B stabilize-14333.B stabilize-14336.B stabilize-14345.B stabilize-14385.B stabilize-14388.52.B stabilize-14388.61.B stabilize-14388.62.B stabilize-14395.B stabilize-14396.B stabilize-14411.B stabilize-14438.B stabilize-14442.B stabilize-14469.41.B stabilize-14469.58.B stabilize-14469.8.B stabilize-14469.9.B stabilize-14477.B stabilize-14496.B stabilize-14498.B stabilize-14526.57.B stabilize-14526.67.B stabilize-14526.73.B stabilize-14526.84.B stabilize-14526.89.B stabilize-14528.B stabilize-14532.B stabilize-14536.B stabilize-14588.123.B stabilize-14588.14.B stabilize-14588.98.B stabilize-14589.B stabilize-14616.B stabilize-14633.B stabilize-14682.B stabilize-14695.107.B stabilize-14695.85.B stabilize-quickfix-14526.91.B stabilize-quickfix-14695.124.B stabilize-quickfix-14695.187.B stabilize-voshyr-14637.B stabilize-wristpin-14469.59.B
  2. 56db84f Update LLVM (#762) by alan-baker · 3 years, 3 months ago
  3. a6001ae Update LLVM (#758) by alan-baker · 3 years, 4 months ago
  4. a040e86 Fix type for --max-ubo-size and --max-pushconstant-size options (#756) by Kévin Petit · 3 years, 4 months ago
  5. 448d852 SPIR-V 1.4 fixes (#755) by alan-baker · 3 years, 4 months ago

clspv

Clspv is a prototype compiler for a subset of OpenCL C to Vulkan compute shaders.

It consists of:

  • A set of LLVM Module passes to transform a dialect of LLVM IR into a SPIR-V module containing Vulkan compute shaders.
  • A command line compiler tool called ‘clspv’ to compile a subset of OpenCL C into a Vulkan compute shader.

Clspv depends on external projects:

Legal

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.

Status

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.

Examples

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

Build

Tools

You will need:

  • CMake
  • Python3
  • A C++ compiler
  • git

Getting sources for dependencies

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

Building

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.

Using Ninja to build, and other build options

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.

Test

To run the test suite from within the build directory:

cmake --build . --target check-spirv

Or if you are using Ninja:

ninja check-spirv

Builtin Library

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.

Rebuilding the Library

Required Tools

You will need a pre-built version of LLVM for your system, CMake, and (optionally) Ninja.

Build

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.