[PATCH] D47394: [OpenMP][Clang][NVPTX] Replace bundling with partial linking for the OpenMP NVPTX device offloading toolchain

Jonas Hahnfeld via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 31 22:45:34 PDT 2018


Hahnfeld added a comment.

In https://reviews.llvm.org/D47394#1118393, @gtbercea wrote:

> The error is related to lack of device linking, just like you explained two paragraphs down. This is the error I get:
>
>   main.o: In function `__cuda_module_ctor':
>   main.cu:(.text+0x674): undefined reference to `__cudaRegisterLinkedBinary__nv_c5b75865'
>


That's because I didn't implement linking for relocatable device code in CUDA, you have to use `nvcc` for that. Please see https://clang.llvm.org/docs/ReleaseNotes.html#cuda-support-in-clang and the original patch https://reviews.llvm.org/D42922.

> The **OpenMP NVPTX device offloading toolchain** has the advantage that it already calls NVLINK (upstreamed a long time ago). This patch doesn't change that. This patch "fixes" (for a lack of a better word) the way in which objects are created on the device side. By adding the FATBINARY + CLANG++ steps, I ensure that the existing call to NVLINK will be able to "detect" the device-part of object files and archived object files (static libraries). This is not a valid statement in today's compiler in which NVLINK would not be able to do so when passed a static library.
> 
> In general, for offloading toolchains, I don't see the reliance on vendor specific tools as a problem **if and only if** the calls to vendor-specific tools remain confined to a device-speicifc toolchain. This patch respects this condition. All the calls to CUDA tools in this patch are part of the OpenMP NVPTX device offloading toolchain (which is an NVPTX device specific toolchain).

I disagree in this context because this patch currently means that static archives will only work with NVPTX and there is no clear path how to "fix" things for other offloading targets. I'll try to work on my proposal over the next few days (sorry, very busy week...), maybe I can put together a prototype of my idea.


Repository:
  rC Clang

https://reviews.llvm.org/D47394





More information about the cfe-commits mailing list