Openhipify is an OpenCL to HIP transpiler, no longer in active development. This can be used for OpenCL C translation (i.e. OpenCL kernels), and for the OpenCL 3.0 C API.
Openhipify uses LibTooling in clang, and requires LLVM to build and use.
- Download the LLVM source from our LLVM fork. (We use our fork as there are extra AST matching cases which have not been commited into the LLVM trunnk as of yet)
- Clone the openhipify repository into the tools section:
cd /llvm_project/clang/tools
git clone https://github.com/benjmudd/openhipify
- Proceed with standard installation process (Found on LibTooling documentation)
cd /llvm_project
echo "add_clang_subdirectory(openhipify)" > clang/tools/CMakeLists.txt
mkdir build && cd build
cmake -G Ninja ../llvm-project/llvm -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" -DCMAKE_BUILD_TYPE=Release -DLLVM_BUILD_TESTS=ON
ninja openhipify
The binary will be produced in /llvm_project/build/bin
Openhipify can be invoked on OpenCL kernel files (.cl extentions) and OpenCL host files using the OpenCL 3.0 C API.
# Kernel example
openhipify kernel.cl --
#host example
openhipify host.c --
#dual example
openhipify host.c kernel.cl --
Multiple host and kernel files can be inputted in any order into the tool. Each will be translated into a HIP file with the same name, with an extra .cpp extention (i.e. kernel.cl -> kernel.cl.cpp)
Examples of full translation can be found at the Openipify test suite.