[PATCH] D137154: Adding nvvm_reflect clang builtin

Joseph Huber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 9 12:26:36 PST 2022


jhuber6 added a comment.

In D137154#3917752 <https://reviews.llvm.org/D137154#3917752>, @tra wrote:

> As for the code specialization, why not build for individual GPUs? To me it looks like this use case is a good match for the "new-driver" offloading that's been recently implemented in clang. It allows compiling/linking GPU side code and that should obviate the need for shipping bitcode and relying on `__nvvm_reflect` for specialization.

Dealing with the relative compatibility of GPU targets is a never-ending endeavor so I'm a proponent of just compiling the source for every single architecture, this is what we do with the `libomptarget` device libraries and is how the future `libm` and `libc` libraries will work.

> The downside is that it's a recent feature, so it would not be available in older clang versions. @jhuber6 : I'm also not sure if OpenCL is supported by the new driver.

It's not currently, I could put some cycles into that if needed. Also I'm wondering if it might be time to start an RFC for moving CUDA to the new driver by default. The one downside would be losing compatibility with CUDA's method of RDC compilation but I don't think that was ever a goal.

> With the new driver, you in theory should be able to compile the source with `--offload-arch=A --offload-arch=B` and it would produce an object file with GPU-specific bitcode or object file which can then be transparently linked into the final executable, where clang would also perform final linking of GPU binaries, as well.

Part of me wonders if  we should supply `--offload-arch=all` if people start doing this a lot.

> I realize that it may be hard or not feasible for your project right now. I'm OK with allowing limited nvvm_reflect use for the time being, but please do consider making things work w/o it or libdevice, if possible.




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137154/new/

https://reviews.llvm.org/D137154



More information about the cfe-commits mailing list