LLVM Working On "HIPSPV" So AMD HIP Code Can Turn Into SPIR-V And Run On OpenCL
AMD's HIP is their C++ Runtime API and kernel language for portable applications on AMD and NVIDIA GPUs from a single source tree. HIP has been AMD's answer to NVIDIA's CUDA by aiming to make it easy to port CUDA code to run on AMD Radeon / Instinct hardware. With tools like their open-source HIPIFY they even aim to make it easy and automated as possible for converting CUDA sources to HIP.
HIP is part of AMD's Radeon Open eCosystem "ROCm" driver stack for GPU computing. HIP/ROCm leverages the open-source LLVM compiler stack and from there generates AMD GPU device code for execution.
Being worked on now by other developers is "HIPSPV" as a new complementary HIP toolchain for LLVM. With HIPSPV rather than going to the AMDGPU back-end, HIPSPV aims to generate SPIR-V code from HIP. Those generated SPIR-V modules in turn could then run atop an OpenCL driver assuming all the necessary extensions and other requirements are in place. SPIR-V, of course, being The Khronos Group's modern intermediate representation for compute/graphics used now across OpenCL / OpenGL / Vulkan across vendors.
There has been prior efforts around converting HIP to SPIR-V for Intel GPU execution while now HIPSPV is working its way toward upstream LLVM. Henry Linjamäki of Tampere University of Technology in Finland has been leading this HIPSPV effort with more details via this llvm-dev posting.
Yesterday this HIP toolchain refactoring work landed as a prerequisite for landing HIPSPV. The actual HIPSPV work and related patches are still pending.
HIPSPV intends to make use of LLVM's new SPIR-V back-end that should soon be merged while for the moment it's making use of the external LLVM SPIR-V translator.
It will be very interesting to see how well HIPSPV works in practice and how robust the toolchain support is for getting HIP converted to SPIR-V and how easily it will run atop OpenCL environments. Besides being beneficial to Intel with their Compute-Runtime / Level Zero for then handling HIP/CUDA codes, HIPSPV could also be beneficial for HIP on other open-source OpenCL drivers potentially like Mesa's Clover and the like. With software like Blender now offering AMD HIP support, it will be interesting to see if HIPSPV could work here, etc. Interesting times ahead and great seeing all the continued open-source innovations around LLVM.