Clava is a C/C++/CUDA/OpenCL source-to-source compiler. It applies analysis and transformations written in TypeScript/JavaScript scripts.
If you have used Clava, please consider filling the Clava User Experience Feedback form (it's short, really!)
Clava is currently distributed as an NPM package. Please check the Clava template repository for instructions on how to run Clava.
To call Clava from within CMake, please click here.
To build the Java part of Clava, please check the ClavaWeaver project folder. The JAR can be used to generate configuration files.
Currently Clava requires Java 17 and Node 18 or 20.
Although Clava is mainly a Java program, which should run on any compatible Java runtime, it also uses compiled binaries. These have operating system restrictions. Currently Clava is supported in Windows 10, Ubuntu 20.04, CentOS 7 and MacOS 11 (Big Sur).
Clava Web-based Tutorial - 2022 - Tutorial on how to use Clava, based on the online demo version.
Language Specification - List of all join points, attributes and actions available in Clava.
API Documentation - List of LARA APIs available in Clava.
API Slides - Introduction to Clava and the LARA Framework APIs.
For a sample of Clava examples, please check the Unit Tests.
Clava already supports the following transformations:
- Automatic insertion of OpenMP pragmas
- Function inlining
- Function outlining
- Array flattening
- Constant folding and propagation
- Struct decomposition
- Function voidification
- Normalizing code to a subset of the language, including:
- Conversion of switch statements to ifs
- Loop conversion (for to while, do to while)
- Ensure there is a single return in a function
- Remove variable shadowing
- Simplify ternary operator
- Simplify compound assignments
Check if you have at least Java 17 installed, this is the minimum version.
On Fedora >28 systems this can be solved by installing the package ncurses-compat-libs
Install libz package (e.g., in Ubuntu sudo apt-get install libz-dev
)
If you want to reference Clava in your work, please use the following publication:
João Bispo, and João MP Cardoso. Clava: C/C++ source-to-source compilation using LARA. SoftwareX, Volume 12, 2020, Article 100565. [ScienceDirect] [bibtex]
This work has been partially funded by the ANTAREX project through the EU H2020 FET-HPC program under grant no. 671623. João Bispo acknowledges the support provided by Fundação para a Ciência e a Tecnologia, Portugal, under Post-Doctoral grant SFRH/BPD/118211/2016.