[flang] [clang] [Flang][Driver] Enable gpulibc/nogpulibc options for Flang, which allows linking of GPU LIBC for the fortran and OpenMP runtime (PR #77135)

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 5 12:25:13 PST 2024


https://github.com/jhuber6 approved this pull request.

Accepting this with Fortran makes sense. This option basically controls whether or not the GPU toolchain will implicitly include the `libcgpu.a` static library via `-lcgpu`. It defaults to on if it finds the `libc` wrapper headers in the `clang` resource directory, `lib/clang/18/include/llvm_libc_wrappers/llvm-libc-decls`. I'm assuming that Fortran doesn't have this?

It's supposed to wrap around the C standard headers so the compiler knows that we have certain `libc` functions on the GPU. However, OpenMP will pretty much just assume anything referenced on the GPU is implicitly on the device so it will likely work for most functions without the wrapper headers. The important exception is `stdout` and  friends. Because this is a global, OpenMP by default will try to map the host value rather than use the one present in `libcgpu` so we need to declare it on the GPU so it avoids the implicit map.

I'd be very interested in troubleshooting anything to get this working on Fortran.

https://github.com/llvm/llvm-project/pull/77135


More information about the cfe-commits mailing list