-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Insert annotation in annotated_ptr::get()
#12343
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e35dd53
insert annotation in annotated_ptr::get()
wangdi4 efb363e
fix comment & test failure
wangdi4 246b1ef
Merge remote-tracking branch 'origin/sycl' into attach_annotation_to_get
wangdi4 0457819
Merge remote-tracking branch 'origin/sycl' into attach_annotation_to_get
wangdi4 88fe720
code refactor
wangdi4 3ebd695
Merge commit '8959c3cf987f94f8514d30fc82923c662088cad3' into attach_a…
wangdi4 dfbaad2
add lit & update spec
wangdi4 4b2b904
fix lit
wangdi4 a0597c8
add test case for CompileTimePropertiesPass
wangdi4 4b63406
Merge branch 'sycl' of https://github.com/intel/llvm into attach_anno…
wangdi4 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
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
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
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
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
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
48 changes: 48 additions & 0 deletions
48
sycl/test/extensions/annotated_ptr/annotation_insertion.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,48 @@ | ||
// RUN: %clangxx -fsycl-device-only -fsycl-targets=spir64_fpga -S -emit-llvm %s -o - | FileCheck %s | ||
|
||
// Tests that `@llvm.ptr.annotation` is inserted when calling | ||
// `annotated_ptr::get()` | ||
|
||
#include "sycl/sycl.hpp" | ||
#include <sycl/ext/intel/fpga_extensions.hpp> | ||
|
||
#include <iostream> | ||
|
||
// clang-format on | ||
|
||
using namespace sycl; | ||
using namespace ext::oneapi::experimental; | ||
using namespace ext::intel::experimental; | ||
|
||
// CHECK: @[[AnnStr:.*]] = private unnamed_addr addrspace(1) constant [19 x i8] c"{5921:\220\22}{44:\228\22}\00" | ||
|
||
using ann_ptr_t1 = | ||
annotated_ptr<int, decltype(properties(buffer_location<0>, alignment<8>))>; | ||
|
||
struct MyIP { | ||
ann_ptr_t1 a; | ||
|
||
MyIP(int *a_) : a(a_) {} | ||
|
||
void operator()() const { | ||
// CHECK: %ptr.addr = alloca ptr addrspace(4), align 8 | ||
// CHECK: store ptr addrspace(4) %ptr, ptr %ptr.addr, align 8 | ||
// CHECK: %[[LoadPtr:.*]] = load ptr addrspace(4), ptr %ptr.addr, align 8 | ||
// CHECK: %[[AnnPtr:.*]] = call ptr addrspace(4) @llvm.ptr.annotation.p4.p1(ptr addrspace(4) %[[LoadPtr]], ptr addrspace(1) @[[AnnStr]] | ||
// CHECK: ret ptr addrspace(4) %[[AnnPtr]] | ||
int *ptr = a.get(); // llvm.ptr.annotation is inserted | ||
*ptr = 15; | ||
} | ||
}; | ||
|
||
void TestVectorAddWithAnnotatedMMHosts() { | ||
sycl::queue q; | ||
auto raw = malloc_shared<int>(5, q); | ||
q.submit([&](handler &h) { h.single_task(MyIP{raw}); }).wait(); | ||
free(raw, q); | ||
} | ||
|
||
int main() { | ||
TestVectorAddWithAnnotatedMMHosts(); | ||
return 0; | ||
} |
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
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.
This raises an interesting question. Is there a guaranteed way to get a raw pointer that does not have the annotations? This might be important for an annotation that somehow changes the semantic of the program (i.e. not a "hint" annotation).
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.
Right now there is no member function/operator that guarantees to get the underlying raw pointer with none annotation attached. A possible solution for this is to enable explict conversion from
annotated_ptr<T>
toT*
.Also I'm wondering if it's really needed. If user explicitly creates an
annotated_ptr
instance with a non-hint annotation, is it legal to get the underlying pointer without that annotation? Since not having this annotation changes the semantic, I would expect the compiler to issue a warning or even error if it detects the risk of losing the information.