The Region Vectorizer (RV) is a general-purpose vectorization framework for LLVM. RV provides a library that allows vectorizing llvm functions.
History
RV used to provide a unified interface to vectorize code regions, such as inner and outer loops, up to whole functions. Versions after release/16.x dropped support for most of that, as well as rvTool, which used to pack that functionality into an executable that could run vectorization on an llvm module.Clone this repository and checkout the version that corresponds to the version of LLVM that libRV is going to link against.
Run git submodule update --init to pull the SLEEF submodule.
To (optionally) enable vectorized complex arithmetic through compiler-rt checkout compiler-rt in llvm/runtimes and configure cmake with -DRV_ENABLE_CRT=on.
As a sample for how this library can be used you can visit the AnyDSL project.
Details
Specifically, the AnyDSL meta repository contains a build script (https://github.com/AnyDSL/anydsl/blob/master/setup.sh) that builds LLVM and RV from source. Thorin, AnyDSL's intermediate representation, contains the actual calls into the library: https://github.com/AnyDSL/thorin/blob/master/src/thorin/be/llvm/vectorize.cpp. This can serve as a starting point on how to integrate libRV into other projects.To get a short diagnostic report from every transformation in RV, set the environment variable RV_REPORT to any value but 0.
RV_ENABLE_CRT:BOOLWhether RV should inline and vectorize complex math functions. This makes use of the complex arithmetic implementations in compiler-rt. Requires compiler-rt to live in llvm/projects. Defaults to OFF.RV_TARGETS_TO_BUILD:ListOfTargetsList of LLVM targets, for which the SLEEF vector math library should be built. Same format asLLVM_TARGETS_TO_BUILD. RV uses SLEEF to vectorize math functions. Clang has to be able to (cross-)compile for all of these targets or the build will fail. Defaults to "Native", the host target.RV_DEBUG:BOOLIf enabled, RV will produce (very) verbose debug output and run additional consistency checks. Make sure you compile with assertions. Recommended for debugging only. Defaults to OFF.LLVM_RVPLUG_LINK_INTO_TOOLS:BOOLEnables the LLVM pass plugin mechanism to link RV into all LLVM tools (opt, clang, ..). Obviates the need to load libRV manually as a plugin on the command line.RV_REBUILD_GENBCBuild the builtin BC library (SLEEF, SIMD random, ..) from source (requires the SLEEF submodule). Otw, use the pre-built BC buffers from vecmath/prebuilt_genbc.
The Region Vectorizer is distributed under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT for details.