OpenMP AMD GPU Offloading
Cordell Bloor
cgmb at slerp.xyz
Thu Feb 5 20:34:21 GMT 2026
Hi folks,
I discovered recently that OpenMP GPU offloading has been packaged by
the LLVM Team. On Debian Testing or Unstable you will need the following
packages installed:
hipcc libomp-21-dev liboffload-21-dev
If you have a sample program, like veccopy.c [1], it can be built with
the command:
clang-21 -O2 -fopenmp --offload-arch=native veccopy.c -o veccopy
You can test that it's correctly offloading to the GPU by running the
test with an environment variable to disable CPU fallback:
OMP_TARGET_OFFLOAD=MANDATORY ./veccopy
I wonder if we should have a metapackage that installs the necessary
requirements for OpenMP GPU offloading? That might be something to
consider for src:rocm.
I've found that it's possible to use OpenMP GPU offloading on Trixie
with ROCm 5.7 and LLVM 17, but the reorganization of the packaging for
liboffload in later LLVM versions fixed some library path problems, so
the newer versions are easier to use. On Trixie, you'll need to use a
custom LD_LIBRARY_PATH to get it working. I should probably put
instructions for all this in the ROCm section of the Debian wiki.
I haven't found a lot of "Getting Started" documentation for these
features, but I did come across a great presentation by Jan-Patrick Lehr
at SC23 on "OpenMP Target Offloading for AMD GPUs" [2].
The LLVM Team seems to have gotten this working without any great
fanfare. A big thanks to them!
Sincerely,
Cory Bloor
[1]:
https://github.com/ROCm/aomp/blob/rocm-7.2.0/test/smoke/veccopy/veccopy.c
[2]: https://www.youtube.com/watch?v=m0MqPYmlGbM
More information about the Pkg-llvm-team
mailing list