Skip to content

Commit 25cec26

Browse files
[SYCL] add deep copy for annotated_ref assignment operator (#10765)
annotated_ref assignment should copy the underneath pointer --------- Co-authored-by: Kseniya Tikhomirova <[email protected]>
1 parent 06eca6f commit 25cec26

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

sycl/doc/extensions/experimental/sycl_ext_oneapi_annotated_ptr.asciidoc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ class annotated_ref {
566566
annotated_ref(const annotated_ref&) = default;
567567
operator T() const;
568568
annotated_ref& operator=(const T &);
569-
annotated_ref& operator=(const annotated_ref&) = default;
569+
annotated_ref& operator=(const annotated_ref&);
570570
};
571571
} // namespace sycl::ext::oneapi::experimental
572572
```
@@ -610,10 +610,11 @@ applying the annotations when the object is stored to memory.
610610
a|
611611
[source,c++]
612612
----
613-
annotated_ref& operator=(const annotated_ref&) = default;
613+
annotated_ref& operator=(const annotated_ref&);
614614
----
615615
|
616-
Assign from another `annotated_ref` object.
616+
Copy an object of type `T` from another `annotated_ref<T, ...>` object.
617+
Applying the annotations when the object is loaded from and stored to memory.
617618

618619
|===
619620

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class annotated_ref {
107107
template <typename T, typename... Props>
108108
class annotated_ref<T, detail::properties_t<Props...>> {
109109
using property_list_t = detail::properties_t<Props...>;
110+
using this_t = annotated_ref<T, detail::properties_t<Props...>>;
110111

111112
private:
112113
T *m_Ptr;
@@ -125,7 +126,7 @@ class annotated_ref<T, detail::properties_t<Props...>> {
125126
#endif
126127
}
127128

128-
annotated_ref &operator=(const T &Obj) {
129+
this_t &operator=(const T &Obj) {
129130
#ifdef __SYCL_DEVICE_ONLY__
130131
*__builtin_intel_sycl_ptr_annotation(
131132
m_Ptr, detail::PropertyMetaInfo<Props>::name...,
@@ -136,7 +137,19 @@ class annotated_ref<T, detail::properties_t<Props...>> {
136137
return *this;
137138
}
138139

139-
annotated_ref &operator=(const annotated_ref &) = default;
140+
this_t &operator=(const this_t &Obj) {
141+
const T &t = Obj;
142+
this->operator=(t);
143+
return *this;
144+
}
145+
146+
template <typename... OtherProperties>
147+
this_t &operator=(
148+
const annotated_ref<T, detail::properties_t<OtherProperties...>> &Obj) {
149+
const T &t = Obj;
150+
this->operator=(t);
151+
return *this;
152+
}
140153

141154
PROPAGATE_OP(+=)
142155
PROPAGATE_OP(-=)

0 commit comments

Comments
 (0)