Skip to content

Commit dfbaad2

Browse files
committed
add lit & update spec
1 parent 3ebd695 commit dfbaad2

File tree

6 files changed

+55
-25
lines changed

6 files changed

+55
-25
lines changed

llvm/lib/SYCLLowerIR/CompileTimePropertiesPass.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -780,11 +780,6 @@ bool CompileTimePropertiesPass::transformSYCLPropertiesAnnotation(
780780
bool CacheProp = false;
781781
bool FPGAProp = false;
782782
for (const auto &[PropName, PropVal] : Properties) {
783-
// sycl-alignment is converted to align on
784-
// previous parseAlignmentAndApply(), dropping here
785-
if (PropName == "sycl-alignment")
786-
continue;
787-
788783
auto DecorIt = SpirvDecorMap.find(*PropName);
789784
if (DecorIt == SpirvDecorMap.end())
790785
continue;

sycl/doc/extensions/experimental/sycl_ext_oneapi_annotated_ptr.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ a|
476476
T* get() const noexcept;
477477
----
478478
|
479-
Returns the underlying raw pointer. The raw pointer will not retain the
480-
annotations.
479+
Returns the underlying raw pointer. Implementations are free to propagate information from properties of
480+
an annotated_ptr to the raw pointer.
481481

482482
// --- ROW BREAK ---
483483
a|

sycl/include/sycl/ext/intel/experimental/fpga_annotated_properties.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,9 @@ struct is_valid_property<T, stable_key::value_t> : std::true_type {};
356356
// buffer_location is applied on PtrAnnotation
357357
template <>
358358
struct propagateToPtrAnnotation<buffer_location_key> : std::true_type {};
359+
template <int K>
360+
struct propagateToPtrAnnotation<buffer_location_key::value_t<K>>
361+
: std::true_type {};
359362

360363
//===----------------------------------------------------------------------===//
361364
// Utility for FPGA properties

sycl/include/sycl/ext/oneapi/experimental/annotated_ptr/annotated_ptr.hpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,6 @@ struct annotationHelper<I, detail::properties_t<P...>> {
7575
detail::PropertyMetaInfo<P>::value...);
7676
}
7777

78-
// static I load(I *ptr) {
79-
// return *annotate(ptr);
80-
// }
81-
82-
// template <class O> static I store(I *ptr, O &&Obj) {
83-
// return *annotate(ptr) = std::forward<O>(Obj);
84-
// }
85-
8678
static I load(I *ptr) {
8779
return *__builtin_intel_sycl_ptr_annotation(
8880
ptr, detail::PropertyMetaInfo<P>::name...,
@@ -138,16 +130,6 @@ class annotated_ref<T, detail::properties_t<Props...>> {
138130
return *this = t2;
139131
}
140132

141-
// address-of operator
142-
T *operator&() const {
143-
#ifdef __SYCL_DEVICE_ONLY__
144-
return annotationHelper<T, detail::annotation_filter<Props...>>::annotate(
145-
m_Ptr);
146-
#else
147-
return *m_Ptr;
148-
#endif
149-
}
150-
151133
// propagate compound operators
152134
#define PROPAGATE_OP(op) \
153135
template <class O, typename = std::enable_if_t<!detail::is_ann_ref_v<O>>> \

sycl/include/sycl/ext/oneapi/experimental/common_annotated_properties/properties.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ struct is_property_key_of<alignment_key, annotated_arg<T, PropertyListT>>
8383
: std::true_type {};
8484

8585
template <> struct propagateToPtrAnnotation<alignment_key> : std::true_type {};
86+
template <int K>
87+
struct propagateToPtrAnnotation<alignment_key::value_t<K>> : std::true_type {};
8688

8789
namespace detail {
8890

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// RUN: %clangxx -fsycl-device-only -fsycl-targets=spir64_fpga -S -emit-llvm %s -o - | FileCheck %s
2+
3+
// Tests that `@llvm.ptr.annotation` is inserted when calling
4+
// `annotated_ptr::get()`
5+
6+
#include "sycl/sycl.hpp"
7+
#include <sycl/ext/intel/fpga_extensions.hpp>
8+
9+
#include <iostream>
10+
11+
// clang-format on
12+
13+
using namespace sycl;
14+
using namespace ext::oneapi::experimental;
15+
using namespace ext::intel::experimental;
16+
17+
// CHECK: @[[AnnStr:.*]] = private unnamed_addr addrspace(1) constant [19 x i8] c"{5921:\220\22}{44:\228\22}\00"
18+
19+
using ann_ptr_t1 =
20+
annotated_ptr<int, decltype(properties(buffer_location<0>, alignment<8>))>;
21+
22+
struct MyIP {
23+
ann_ptr_t1 a;
24+
25+
MyIP(int *a_) : a(a_) {}
26+
27+
void operator()() const {
28+
// CHECK: %ptr.addr = alloca ptr addrspace(4), align 8
29+
// CHECK: store ptr addrspace(4) %ptr, ptr %ptr.addr, align 8
30+
// CHECK: %[[LoadPtr:.*]] = load ptr addrspace(4), ptr %ptr.addr, align 8
31+
// CHECK: %[[AnnPtr:.*]] = call ptr addrspace(4) @llvm.ptr.annotation.p4.p1(ptr addrspace(4) %[[LoadPtr]], ptr addrspace(1) @[[AnnStr]]
32+
// CHECK: ret ptr addrspace(4) %[[AnnPtr]]
33+
int *ptr = a.get(); // llvm.ptr.annotation is inserted
34+
*ptr = 15;
35+
}
36+
};
37+
38+
void TestVectorAddWithAnnotatedMMHosts() {
39+
sycl::queue q;
40+
auto raw = malloc_shared<int>(5, q);
41+
q.submit([&](handler &h) { h.single_task(MyIP{raw}); }).wait();
42+
free(raw, q);
43+
}
44+
45+
int main() {
46+
TestVectorAddWithAnnotatedMMHosts();
47+
return 0;
48+
}

0 commit comments

Comments
 (0)