-
Notifications
You must be signed in to change notification settings - Fork 801
[Driver] Set default value for opaque pointers in offload bundler #9933
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
Closed
GeorgeWeb
wants to merge
13
commits into
intel:sycl
from
GeorgeWeb:georgi/sycl_fix_opaque_ptrs_offload_bundler
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c7db9d6
[SYCL] Set default value for opaque pointers in offload bundler
c96918c
Add tests to verify clang-offload-bundler bundle won't fail allowing …
ec1f09e
Merge remote-tracking branch 'upstream/sycl' into georgi/sycl_fix_opa…
69a3d82
Update driver test.
93fa364
Merge remote-tracking branch 'upstream/sycl' into georgi/sycl_fix_opa…
6e4eb68
Update test.
af2022e
Merge remote-tracking branch 'upstream/sycl' into georgi/sycl_fix_opa…
ce453d3
Merge remote-tracking branch 'upstream/sycl' into georgi/sycl_fix_opa…
0744ea6
Try fixing the test.
52ccb85
Update test since spir targets output support opaque ptrs
6b85d26
Remove unsued commented code
1c7b777
[WIP] Fixup for simpler device code emitting.
3fa4db3
Make the driver test independent of sycl mode.#
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
clang/test/Driver/sycl-clang-offload-bundler-opaque-pointers.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /// | ||
| /// Checks that opaque-pointers are being set for llvm context used accordingly | ||
| /// to the bundle targets and clang-offload-bundler is able to read the bitcode. | ||
| /// | ||
|
|
||
| // REQUIRES: x86-registered-target | ||
| // UNSUPPORTED: system-windows | ||
|
|
||
| void foo(int *p) { | ||
| *p = 1; | ||
| } | ||
|
|
||
| // | ||
| // Generate inputs for clang-offload-bundler. | ||
| // | ||
| // RUN: %clangxx -target openmp-x86_64-pc-linux-gnu -Xclang -no-opaque-pointers %s -S -emit-llvm -o %s.tgt1.ll | ||
| // RUN: %clangxx -target openmp-x86_64-pc-linux-gnu -Xclang -no-opaque-pointers %s -c -emit-llvm -o %s.tgt1.bc | ||
| // RUN: %clangxx -target openmp-nvptx64-nvidia-cuda %s -S -emit-llvm -o %s.tgt2.ll | ||
| // RUN: %clangxx -target openmp-nvptx64-nvidia-cuda %s -c -emit-llvm -o %s.tgt2.bc | ||
| // RUN: %clangxx -target x86_64-unknown-linux-gnu %s -c -o %s.host.o | ||
|
|
||
| // | ||
| // Check clang-offload-bundler obj for opaque pointers support error when typed | ||
| // pointer module is the first input target, followed by an opaque pointers one. | ||
| // | ||
| // RUN: clang-offload-bundler -type=o -targets=openmp-x86_64-pc-linux-gnu,openmp-nvptx64-nvidia-cuda,host-x86_64-unknown-linux-gnu -output=%s.bundle.o -input=%s.tgt1.bc -input=%s.tgt2.bc -input=%s.host.o 2>&1 \ | ||
| // RUN: | FileCheck %s -check-prefix=CHECK-STD --allow-empty | ||
| // CHECK-STD-NOT: error: Opaque pointers are only supported in -opaque-pointers mode | ||
|
|
||
| // | ||
| // Verify the target 1 module contains typed pointers (set -no-opaque-pointers). | ||
| // | ||
| // RUN: FileCheck %s --check-prefix CHECK-TYPED_POINTERS_TARGET --input-file=%s.tgt1.ll | ||
| // CHECK-TYPED_POINTERS_TARGET: target triple = "x86_64-pc-linux-gnu-openmp" | ||
| // CHECK-TYPED_POINTERS_TARGET: i32* noundef | ||
| // CHECK-TYPED_POINTERS_TARGET-NOT: ptr noundef | ||
|
|
||
| // | ||
| // Verify the target 2 module contains opaque pointers. | ||
| // | ||
| // RUN: FileCheck %s --check-prefix CHECK-OPAQUE_POINTERS_TARGET --input-file=%s.tgt2.ll | ||
| // CHECK-OPAQUE_POINTERS_TARGET: target triple = "nvptx64-nvidia-cuda-openmp" | ||
| // CHECK-OPAQUE_POINTERS_TARGET: ptr noundef | ||
| // CHECK-OPAQUE_POINTERS_TARGET-NOT: i32* noundef |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
After poking around in more detail (I don't regularly develop this tool), I've come to the conclusion that this code is an elaborate way to set
Context.setOpaquePointers(true). The host is included inTargetNames, and can't be SPIRV anyways, so there's always a non-SPIR-V module to cause it to be set to true. This of course obscures the failure modes of what would happen ifUseOpaquePointerswere false, since there's no realistic mode where it could be false.Given that SPIRV_ENABLE_OPAQUE_POINTERS is enabled now and we're starting to remove support for typed pointers, I'm not sure there's any need for this PR anymore.
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 you mean
LLVMContext Context;uses opaque pointers by default and don't need to switch to non-opaque mode anymore?@GeorgeWeb, are you okay to drop this change?
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.
#10888 means INTEL_SYCL_OPAQUEPOINTER_READY is now true and therefore everything is always in opaque pointer mode.
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.
Always?
Why do we add ifdef like this:
?
Shouldn't we just remove this code?
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.
In principle, it's a cmake option you can turn off. However, I suspect it doesn't actually work anymore. And I also suspect @jsji is likely to start ripping the code out in the near future, after the code bakes for a little bit more (the PR landed only yesterday).
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.
Yes, the plan is to remove the code in #ifndef INTEL_SYCL_OPAQUEPOINTER_READY once our downstream code works well.
ETA 1-2 weeks.
Keep it by guarding it within macros just in case we need to compare to INTEL_SYCL_OPAQUEPOINTER_READY=0 in some case for now.
Uh oh!
There was an error while loading. Please reload this page.
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.
Yes. Also I believe
setOpaquePointersis now an assert, so don't call it anymore.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! So, assuming
INTEL_SYCL_OPAQUEPOINTER_READYgoes away soon-ish then it's all gonna look cleaner. My patch was I guess really a temporary mitigation for an awkward issue and from the insights of this discussion - thanks @jsji and @jcranmer-intel I am happy to close this PR as it seems unneeded forintel:sycl. 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.
@bader If you are convinced too, I am happy to close this given the future direction.