Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CUDA][HIP] incorrect linkage of shadow variable for inline device variable #90749

Closed
yxsamliu opened this issue May 1, 2024 · 1 comment
Closed
Assignees
Labels
cuda question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

Comments

@yxsamliu
Copy link
Collaborator

yxsamliu commented May 1, 2024

C++17 inline variables have weak linkage in ELF files, which means multiple copies in different translation units are merged into one copy by the linker.

nvcc emits it as weak in both device and host:

https://godbolt.org/z/n8EjvWKxe

currently clang only emits it as weak in device but not host. This causes multiple shadow variables registered for the same device variable.

https://godbolt.org/z/Maz7aMhcP

This caused issue in HIP:

ROCm/HIP#3463

@yxsamliu yxsamliu self-assigned this May 1, 2024
@yxsamliu
Copy link
Collaborator Author

yxsamliu commented May 1, 2024

sorry I missed -fgpu-rdc when compiling using clang. when -fgpu-rdc is used, the linkage is weak for inline variables:

https://godbolt.org/z/K7vd8EGqa

So clang does not have the issue.

@yxsamliu yxsamliu closed this as completed May 1, 2024
@EugeneZelenko EugeneZelenko added the question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! label May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cuda question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Projects
None yet
Development

No branches or pull requests

2 participants