LLVM's HIPSPV Coming Together For AMD HIP To SPIR-V For OpenCL Execution
Written by Michael Larabel in LLVM on 20 December 2021 at 03:45 PM EST. 13 Comments
Last week I wrote about the interesting HIPSPV back-end for LLVM to take AMD HIP code -- which generally starts off as NVIDIA CUDA code to begin with before the HIP-ification -- and to be able to output that from the LLVM compiler stack as the SPIR-V intermediate representation used across OpenCL and Vulkan drivers. The goal with this is to be able to take AMD HIP code and ultimately be able to run it on Intel graphics processors but potentially other vendors/drivers too given the vendor-neutral SPIR-V. More of that HIPSPV work is now hitting mainline LLVM.

HIPSPV is quite interesting for being able to leverage AMD HIP in non-AMD environments or even potentially using say Mesa's Clover OpenCL driver for HIP kernels rather than being bound to the AMD ROCm stack for HIP that doesn't always play well on all Linux distributions and has a limited scope of Radeon GPU support.

How well HIPSPV will work in practice and how robust the support will mature to for taking HIP to SPIR-V kernels remains to be seen, but given that HIP has been about being able to take original CUDA code and HIP'ify it to get it running elsewhere, if HIPSPV works well it could really be a big deal for opening up the access even more.

Tampere University of Technology has been working on this HIPSPV back-end for going to SPIR-V rather than ROCm's HIP approach of going through the LLVM AMDGPU shader back-end. The developers involved with this effort are currently focused on Intel GPU execution with the Intel Compute-Runtime OpenCL / Level Zero stack.

Since originally writing about HIPSPV for throwing light on this project, the actual HIPSPV toolchain has now been merged into upstream LLVM. The HIPSPVToolChain allows for emitting HIP device code as a SPIR-V binary. Currently this toolchain relies on the external SPIRV-LLVM-Translator but as previously covered an LLVM SPIR-V proper back-end is nearing upstream too. Meanwhile merged today is this patch enabling the actual SPIR-V emission for HIP. The code also adds a "--offload" option for being able to specify the offload target -- including adding a new "generic" target.

The fourth and final patch of the series is still pending but looking like it too will be merged shortly and that is adding an option to LLC for emitting SPIR-V.

This initial HIPSPV support will be found in LLVM 14.0 due out around March of 2022 and at that point we'll see how well the support has matured for being practical and useful for more GPUs/drivers.
Related News
About The Author
Author picture

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter or contacted via MichaelLarabel.com.

Popular News This Week