[PATCH] D137154: Adding nvvm_reflect clang builtin
Yaxun Liu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 3 10:09:41 PDT 2022
yaxunl added a comment.
In D137154#3904810 <https://reviews.llvm.org/D137154#3904810>, @hdelan wrote:
> In DPC++ for CUDA we use libclc as a wrapper around CUDA SDK's libdevice. Like libdevice we want to precompile libclc to bc for the CUDA backend without specializing for a particular arch, so that we can call different __nv funcs based on the arch. For this reason we use the `__nvvm_reflect` llvm intrinsic.
>
> Without a clang builtin a number of workarounds are necessary to get the desired behaviour from `__nvvm_reflect`.
>
> 1. We must declare `__nvvm_reflect` in source code everywhere where it is used.
> 2. Some addrspace casting is necessary in openCL, since strings are in the__constant address space. We must use an IR wrapper function to ensure the correct behaviour. See https://github.com/intel/llvm/blob/sycl/libclc/ptx-nvidiacl/libspirv/reflect.ll
>
> We agree that `__nvvm_reflect` is not a perfect solution, but it is something we must use because of libdevice. Adding the clang builtin would enable us to write libdevice-like libraries without having to resort to the methods mentioned above.
LLVM does not maintain bitcode backward compatibility between major releases. How do you make sure the clang/LLVM you are using is compatible with libdevice?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137154/new/
https://reviews.llvm.org/D137154
More information about the llvm-commits
mailing list