Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/doe300/VC4C
Compiler for the VC4CL OpenCL implementation
https://github.com/doe300/VC4C
c-plus-plus compiler llvm-ir opencl raspberry spir-v
Last synced: 3 months ago
JSON representation
Compiler for the VC4CL OpenCL implementation
- Host: GitHub
- URL: https://github.com/doe300/VC4C
- Owner: doe300
- License: mit
- Created: 2017-10-08T10:11:39.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-05-30T16:11:04.000Z (over 1 year ago)
- Last Synced: 2023-10-20T19:24:26.045Z (over 1 year ago)
- Topics: c-plus-plus, compiler, llvm-ir, opencl, raspberry, spir-v
- Language: C
- Size: 25.9 MB
- Stars: 118
- Watchers: 15
- Forks: 34
- Open Issues: 24
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
- AwesomeCompiler - VC4C
README
# Status
[![CircleCI](https://circleci.com/gh/doe300/VC4C.svg?style=svg)](https://circleci.com/gh/doe300/VC4C)
# VC4C
Compiler for the [VC4CL](https://github.com/doe300/VC4CL) OpenCL-implementation.
This compiler supports OpenCL C (via LLVM or [SPIRV-LLVM](https://github.com/KhronosGroup/SPIRV-LLVM)), LLVM-IR and SPIR-V code, depending on the build configuration.## Required software
- A C++14 capable compiler (Raspbian stretch ships with GCC 6.x, which is supported. GCC 4.9 used by Raspbian jessie is no longer supported! The clang from the Raspbian repository is also okay and can double as OpenCL compiler, see below)
- CMake in version >= 3.13
- A suitable OpenCL 1.2 compiler. Supported versions are the "original" LLVM/CLang (version 3.9 and up, **using this one is recommended**), which can be found in the Raspbian repositories, the Khronos [SPIRV-LLVM Translator](https://github.com/KhronosGroup/SPIRV-LLVM-Translator) built on top of the "original" LLVM/CLang or the deprecated Khronos [SPIRV-LLVM](https://github.com/KhronosGroup/SPIRV-LLVM) with the Khronos [SPIR-V compiler front-end](https://github.com/KhronosGroup/SPIR/tree/spirv-1.0) (only the tools clang and llvm-spirv need to be built).
- The source-code for [VC4CLStdLib](https://github.com/doe300/VC4CLStdLib) for the GPU-side standard-library## Build
The following configuration variables can be set in CMake:
- `BUILD_TESTING` toggles building of test program
- `CMAKE_BUILD_TYPE` set to *Debug*, *Release*, *RelWithDebInfo*, *asan*, *tsan* or *usbsan* to build for the given debug/release mode or with sanitizers enabled
- `VC4CL_STDLIB_DIR` specifies an optional folder where the development headers for the GPU-side [VC4CLStdLib](https://github.com/doe300/VC4CLStdLib) are located, by default looks in `../VC4CLStdLib/include/`
- `CROSS_COMPILE` toggles whether to cross-compile for the Raspberry Pi. NOTE: The [Raspberry Pi cross-compiler](https://github.com/raspberrypi/tools) is no longer supported, since it is based on an ancient GCC 4.9
- `CROSS_COMPILER_PATH` sets the root path to the cross compiler to use
- `SPIRV_FRONTEND` toggles building of the SPIR-V front-end, requires SPIRV-LLVM
- `SPIRV_COMPILER_ROOT` sets the root-path to binaries of the [SPIRV-LLVM](https://github.com/KhronosGroup/SPIRV-LLVM) compiler, defaults to `/opt/SPIRV-LLVM/build/bin/`
- `SPIRV_TRANSLATOR_ROOT` sets the root path to the binaries of the [SPIRV-LLVM Translator](https://github.com/KhronosGroup/SPIRV-LLVM-Translator) compiler, defaults to `/opt/SPIRV-LLVM-Translator/build/tools/llvm-spirv/`. This takes precedence over `SPIRV_COMPILER_ROOT`
- `LLVMLIB_FRONTEND` enables the LLVM library front-end which uses the LLVM library to parse the LLVM IR module generated by the pre-compilation (**recommended!**)
- `CLANG_LIBRARY` enables the experimental clang library precompilation as alternative to running clang as a separate process## Package
Run `cpack -G DEB` to create a debian package.
**NOTE: Any compilation error when packaging can be ignored!**
## Known Issues
If the [VC4CLStdLib](https://github.com/doe300/VC4CLStdLib) is updated, the LLVM pre-compiled header (PCH) needs to be rebuilt. For this to happen, simply delete the file `VC4CLStdLib.h.pch` (located in the source/installation directory of the VC4CLStdLib project, depending on whether it was installed) and rebuild the VC4C compiler (or just the `vc4cl-stdlib` target).
When `BUILD_TESTING` is on, some of the files (`TestConversionFunctions.cpp.o`) have to be compiled in one thread (`make -j 1`).