[PATCH] D123441: [CUDA][HIP] Fix host used external kernel in archive

2022-04-13 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. yaxunl marked an inline comment as done. Closed by commit rG0424b5115cff: [CUDA][HIP] Fix host used external kernel in archive (authored by yaxunl). Herald added a proj

[PATCH] D123441: [CUDA][HIP] Fix host used external kernel in archive

2022-04-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done. yaxunl added a comment. In D123441#3446719 , @tra wrote: > So, a main TU with just `__global__ void kernel();` would emit a reference > when it's compiled on the GPU side. That, in turn will tell the linker what

[PATCH] D123441: [CUDA][HIP] Fix host used external kernel in archive

2022-04-12 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision. tra added a comment. This revision is now accepted and ready to land. In D123441#3446499 , @yaxunl wrote: > You are talking about a use case that actually needs --whole-archive option. > If the main TU does not reference some

[PATCH] D123441: [CUDA][HIP] Fix host used external kernel in archive

2022-04-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment. Also, I don't see the advantage of resolving this issue through toolchains. You still need to detect kernels and device variables referenced by host code, and generate IR's which introduce artificial references to them. It just becomes more complicated since you have to

[PATCH] D123441: [CUDA][HIP] Fix host used external kernel in archive

2022-04-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment. In D123441#3446478 , @tra wrote: >> This approach will only link in kernels and device variables used by host >> code > > In the absence of the explicit reference info from the host side, GPU-side > linker must link all objects

[PATCH] D123441: [CUDA][HIP] Fix host used external kernel in archive

2022-04-12 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment. > This approach will only link in kernels and device variables used by host code In the absence of the explicit reference info from the host side, GPU-side linker must link all objects with symbols that **may** be used by the host. E.g if we have a library with three object

[PATCH] D123441: [CUDA][HIP] Fix host used external kernel in archive

2022-04-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment. In D123441#3446408 , @tra wrote: > LGTM in principle. This will keep around the GPU code we do need. > > That said, it seems to be a rather blunt hammer. I think we'll end up linking > almost everything in an archive into the fina

[PATCH] D123441: [CUDA][HIP] Fix host used external kernel in archive

2022-04-12 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment. LGTM in principle. This will keep around the GPU code we do need. That said, it seems to be a rather blunt hammer. I think we'll end up linking almost everything in an archive into the final executable as we'll likely have a host-visible symbol in most of the GPU objects (e

[PATCH] D123441: [CUDA][HIP] Fix host used external kernel in archive

2022-04-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision. yaxunl added a reviewer: tra. Herald added a project: All. yaxunl requested review of this revision. For -fgpu-rdc, a host function may call an external kernel which is defined in an archive of bitcode. Since this external kernel is only referenced in host function, t