This is an archive of the discontinued LLVM Phabricator instance.

[CUDA][HIP] Externalize kernels in anonymous name space
ClosedPublic

Authored by yaxunl on Apr 7 2022, 8:07 PM.

Details

Summary

kernels in anonymous name space needs to have unique name
to avoid duplicate symbols.

Fixes: https://github.com/llvm/llvm-project/issues/54560

Diff Detail

Event Timeline

yaxunl created this revision.Apr 7 2022, 8:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 7 2022, 8:07 PM
yaxunl requested review of this revision.Apr 7 2022, 8:07 PM
mkuron added a subscriber: mkuron.Apr 8 2022, 1:11 AM
tra added inline comments.Apr 8 2022, 11:17 AM
clang/test/CodeGenCUDA/kernel-in-anon-ns.cu
14

Will the externalized names be uniquified as well?

E.g. if we compile with -fgpu-rdc, we do want the kernels to be externally visible, but we also don't want the names to clash if we have two TUs having the same external name for them.

yaxunl marked an inline comment as done.Apr 8 2022, 11:52 AM
yaxunl added inline comments.
clang/test/CodeGenCUDA/kernel-in-anon-ns.cu
14

Yes, the kernel name is uniquified with a hash of the source path and compile options.

tra accepted this revision.Apr 8 2022, 2:17 PM

LGTM overall.

clang/test/CodeGenCUDA/kernel-in-anon-ns.cu
14

Then we should probably include the unique suffix in the CHECK line. The RUN lines already provide specific cuid, so the fuffix will always be the same.

This revision is now accepted and ready to land.Apr 8 2022, 2:17 PM
yaxunl marked 2 inline comments as done.Apr 9 2022, 6:39 AM
yaxunl added inline comments.
clang/test/CodeGenCUDA/kernel-in-anon-ns.cu
14

will do when committing

This revision was landed with ongoing or failed builds.Apr 10 2022, 6:56 PM
This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Herald added a project: Restricted Project. · View Herald TranscriptApr 10 2022, 6:56 PM