-
Notifications
You must be signed in to change notification settings - Fork 769
[sycl-post-link] Don't remove llvm.compiler.used for NVPTX #15224
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
Conversation
3cfff78
to
8ca0294
Compare
8ca0294
to
9784bb5
Compare
@@ -0,0 +1,29 @@ | |||
// Tests that the llvm.compiler.used symbol, which is used to implement static |
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 sycl/test
instead of sycl-post-link
test?
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.
It's a bit of a mess but the llvm.used
symbol is handled in different parts of the compilation depending on backend. So it's important to make sure that the tests are working for an entire compilation pipeline, not just for a particular stage of the action.
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.
What is the latest stage it is being removed? Why can't we have test for that component? Is the "mess" final, or do we expect pipelines to be unified?
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.
llvm.used
should survive to final linking, llvm.compiler.used
is okay for intermediary tools to drop: https://llvm.org/docs/LangRef.html#the-llvm-used-global-variable
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.
Do we need a test when programmer uses __attribute__((used))
on something to ensure that something isn't being dropped?
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.
Device image compression will be optional (#15124) - unless you specify
--offload-compress
in CLI, by default, we won't compress images. So, image compression might not be an issue for this particular test.
If image compression is "opt-in" and we will not opt in in this test, then why is this an issue @aelovikov-intel ? It seems unlikely that binary formatting is going to change drastically in the next while, and if it does then I think this test will be the least of our problems.
I am using strings
as it's a simpler, more portable way to find a global symbol, using the current device code formats, than using proprietary binutils that are likely to belong to proprietary toolkits. For instance cuobjdump
is not necessarily distributed in every CUDA version. Relying on a tool like this may break CI with a CUDA toolkit version change. Likewise I don't want to rely on a tool like spirv-dis
which often breaks and doesn't keep up to date with the latest spir-v features.
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.
Thanks for response @uditagarwal97 :)
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've updated the test to use llvm-strings
instead of strings
. Is this sufficient @aelovikov-intel ?
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.
If I just delete the test will you approve this PR? I don't think this discussion is going anywhere
Yes.
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.
If image compression is "opt-in" and we will not opt in in this test, then why is this an issue @aelovikov-intel ?
Because that's an implementation detail of something unrelated to your test and it must not make any assumptions of it.
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.
Looks good overall. Few minor comments. Thanks
These are removed automatically during lowering.
This is removed at lowering for NVPTX/AMDGCN. TODO: check that this is working for SPIR-V.
18fe1c6
to
74fa7ba
Compare
sycl post link no longer removes llvm.compiler.used.
For spirv remove the llvm.compiler.used symbol at sycl-post-link. This is because we use llvm-spirv for lowering, not the SPIR-V backend.
eeff007
to
4b06c76
Compare
// used inside the device code after they have been removed from | ||
// "llvm.compiler.used" they can be erased safely. | ||
Modified |= removeDeviceGlobalFromCompilerUsed(*M.get()); | ||
// to keep the optimizer from wrongfully removing them. llvm.compiler.used |
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 intend to replace the translator with SPIR-V backend eventually. Can we remove the check at that point of time?
Thanks
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.
Once the SPIRV backend is being used instead of llvm-spirv
I think it'd be better to remove the llvm.compiler.used
symbol in the backend, instead of in sycl-post-link
, although some might disagree. I think it's OK to keep the current behaviour for the moment unless it becomes a problem later.
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.
Changes look good to me. Just one clarification requested. Thanks
Make sure that `strings` can successfully detect the symbol in an object file.
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'd prefer the test to be removed, but if you really want to keep it so be it.
Thanks @aelovikov-intel I'd like to keep it in if possible. I can remove at any point in time if it becomes a problem. Ping @intel/llvm-gatekeepers this can be merged, thanks. |
@hdelan The test is failing on HIP in postcommit, can you take a look and disable the test if the fix isn't quick? Thx https://github.com/intel/llvm/actions/runs/10735485792/job/29773246908
|
llvm.compiler.used
is a global symbol which tells the compiler not to touch some other global symbols until backend lowering. Thellvm.compiler.used
symbol itself is thus removed automatically during lowering for NVPTX and AMDGCN. Removal atsycl-post-link
, prior to lowering, was causing issues for these backends, where symbols protected byllvm.compiler.used
were getting removed aftersycl-post-link
and before lowering.We retain the current behaviour for SPIR-V, as SPIR-V generation is handled in
llvm-spirv
anyway, not in the LLVM SPIR-V backend.Also adds tests to make sure static device_globals are handled properly for NVPTX/AMDGCN.