-
Notifications
You must be signed in to change notification settings - Fork 184
[CIR][CUDA][HIP] Set internal linkage for device variable shadows #2041
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
base: main
Are you sure you want to change the base?
Conversation
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
|
I have some concerns with this. Some of the functionality you perform here should be done during lowering to LLVM IR (
|
| /// Keeps track of variable containing handle of GPU binary. Populated by | ||
| /// ModuleCtorFunction() and used to create corresponding cleanup calls in | ||
| /// ModuleDtorFunction() | ||
| llvm::GlobalVariable *gpuBinaryHandle = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see this being used at CodeGen. We handle the "gpuBinaryHandle" during "lowering". Why do you think we need this here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, this is merely an artifact from bringing the skeleton from OG, Will remove.
| DeviceVarFlags flags; | ||
| }; | ||
|
|
||
| llvm::SmallVector<VarInfo, 16> deviceVars; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need this? Does this exist in OG?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you are mixing CUDA and HIP tests here. This is ok, but we had historically split them between CUDA/HIP directories.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good Point, I'll make sure to split both things from now on.
| @@ -1,4 +1,4 @@ | |||
| #include "cuda.h" | |||
| #include "../Inputs/cuda.h" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We prefer on not having a relative path here #include <cuda.h> :D. We give th path through the -I%S/../Inputs/ flag we pass to CC1.
Okay, it took me some time. But I realize I misled with the initial title of this PR, Registration was recently handled in your PR (thanks for that!). The vector stored in the runtime See how OG handles the clangir/clang/lib/CodeGen/CGCUDANV.cpp Line 681 in 16cabe9
The equivalent we have to bookkeep globals in CIR is:
If you look at the way we're currently handling the variables to be shadowed on the host in CIR:
I believe we somehow need to preserve the information coming from VarInfo, specifically in DeviceVarFlags. Doing that allows us to give special handling to the different types of globals as seen in OG: clangir/clang/lib/CodeGen/CGCUDANV.cpp Line 687 in 16cabe9
|
The way I see it, we have two paths:
Let me know what you think |
Device variables (
__device__,__constant__) now have internal linkage for their host-side shadow variables (non-RDC mode), matching OG behavior.