[CUDA] Add wrapper code generation for registering CUDA images
authorJoseph Huber <jhuber6@vols.utk.edu>
Wed, 13 Apr 2022 15:48:07 +0000 (11:48 -0400)
committerJoseph Huber <jhuber6@vols.utk.edu>
Wed, 11 May 2022 11:30:25 +0000 (07:30 -0400)
commitf49d576a882da81292b5730af442fa38899af312
tree8c07c0414fea39c16f87a58553c70ace52812c25
parente7858a9fab8c11a44868ad4e0572c6c7618b219a
[CUDA] Add wrapper code generation for registering CUDA images

This patch adds the necessary code generation to create the wrapper code
that registers all the globals in CUDA. We create the necessary
functions and iterate through the list of
`__start_cuda_offloading_entries` to find which globals must be
registered. This is very similar to the code generation done currently
in Clang for non-rdc builds, but here we are registering a fully linked
fatbinary and finding the globals via the above sections.

With this we should be able to fully support basic RDC / LTO building of CUDA
code.

It's also worth noting that this does not include the necessary PTX to JIT the
image, so to use this support the offloading architecture must match the
system's architecture.

Depends on D123810

Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D123812
clang/test/Driver/linker-wrapper-image.c
clang/test/Driver/linker-wrapper.c
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
clang/tools/clang-linker-wrapper/OffloadWrapper.cpp