c++clangopenmpnvidiaoffloading

Do I have to build clang-11 from source on Ubuntu 18.04 to have OpenMP GPU target offload?


I installed clang-11 from https://apt.llvm.org/ on Ubuntu 18.04 and I have OpenMP host device functionality working in my C++ test project, but omp_get_num_devices() returns 0, even though I have Nvidia GPU and working CUDA 11 toolkit. Do I have to build a special version of Clang from source in order to get OpenMP GPU offload working, as described here: https://hpc-wiki.info/hpc/Building_LLVM/Clang_with_OpenMP_Offloading_to_NVIDIA_GPUs ?


Solution

  • The Debian/Ubuntue packages for LLVM do not come with OpenMP offload support for GPUs [0] (at least until LLVM 11) . Packaging this is a bit tricky but we are working on it. One of the tricky parts, for now, is that for reasonable performance it requires a two stage build and you need(ed) to specify what GPU architectures you are targeting. The latter requirement is partially gone in LLVM now as we look at the build machine configuration and make a reasonable guess but was still there in the LLVM 11 release (IIRC). We are working on eliminating the two stage requirement as well, among other things.

    While pretty new and mostly empty, these things will eventually be described here: http://openmp.llvm.org/docs

    Also, if you have questions or concerns, don't hesitate to send an email to openmp-dev@lists.llvm.org :)

    Lastly, at first glance the script by @ouankou looks pretty good, except that I usually recommend the latest top-of-trunk over a release. It can be unstable but, TBH, for OpenMP offload support it is probably not any less stable than a release.

    [0] CMake excerpt: https://paste.debian.net/1171752/ (thanks Sylvestre!)