Skip to content

Commit 9b1d33e

Browse files
author
Chen, Brox
committed
added template deductions, fixed minor errors
1 parent 3fdeabd commit 9b1d33e

File tree

2 files changed

+38
-48
lines changed

2 files changed

+38
-48
lines changed

sycl/doc/extensions/proposed/sycl_ext_oneapi_annotated_arg.asciidoc

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,15 @@ the following types:
175175
* sycl::half
176176

177177
The properties supported with `annotated_arg` may be defined in
178-
separate extensions.
178+
separate extensions. Please note that there cannot be duplicated property in a
179+
properties list. Otherwise, a compiler time error is triggered.
179180

180181
The section below describes the constructors and member functions for
181182
`annotated_arg`.
182183

183184
The template parameter `T` in the definition of `annotated_arg` template below
184-
must be a legal parameter type as defined by the SYCL specification.
185+
must be a legal parameter type as defined by the SYCL specification. Given `annotated_arg<T, ...>`,
186+
`T` must be a trivially copy-able type.
185187

186188
[source,c++]
187189
----
@@ -190,7 +192,7 @@ template <typename T, typename PropertyListT = properties<>>
190192
class annotated_arg {
191193
public:
192194
annotated_arg() noexcept;
193-
annotated_arg(const T& v_, const properties<PropertyListT> &P = properties{}) noexcept;
195+
annotated_arg(const T& v_, const PropertyListT &P = properties{}) noexcept;
194196
template<typename... PropertyValueTs>
195197
annotated_arg(const T& v_, PropertyValueTs... props) noexcept;
196198
@@ -204,19 +206,13 @@ class annotated_arg {
204206
annotated_arg& operator=(annotated_arg&) = default;
205207
206208
// Conversion operator to convert to the underlying type
207-
operator T&() noexcept;
208-
operator const T&() const noexcept;
209+
operator T() noexcept;
210+
operator const T() const noexcept;
209211
210212
// Available if the operator[] is valid for objects of type T, return
211213
// type will match the return type of T::operator[](std::ptrdiff_t)
212214
/* ... */ operator[](std::ptrdiff_t idx) const noexcept;
213215
214-
// Available if the operator() is valid for objects of type T, return
215-
// type will match the return type of
216-
// template<typename... Args> T::operator()(Args... args)
217-
template<typename... Args> /* ... */ operator()(Args... args) noexcept;
218-
template<typename... Args> /* ... */ operator()(Args... args) const noexcept;
219-
220216
template<typename propertyT>
221217
static constexpr bool has_property();
222218
@@ -228,12 +224,16 @@ class annotated_arg {
228224
229225
//Deduction guides
230226
template <typename T, typename... Args>
231-
annotated_arg(T, Args... args) -> annotated_arg<T, detail::properties_t<Args...>>;
227+
annotated_arg(T, Args... args) ->
228+
annotated_arg<T, detail::properties_t<Args...>>;
232229
233-
template <typename T, typename oldProp, typename otherProp>
234-
annotated_arg(annotated_arg<T, oldProp>, otherProp other)
235-
-> annotated_arg<T, detail::merged_properties_t<oldProp, otherProp>>;
230+
template <typename T, typename... Args>
231+
annotated_arg(T, properties<std::tuple<Args...>>) ->
232+
annotated_arg<T, detail::properties_t<Args...>>;
236233
234+
template <typename T, typename old, typename... Args>
235+
annotated_arg(annotated_arg<T, old>, properties<std::tuple<Args...>>) ->
236+
annotated_arg<T, detail::merged_properties_t<old, detail::properties_t<Args...>>>;
237237
} // namespace sycl::ext::oneapi::experimental
238238
----
239239

@@ -260,7 +260,6 @@ annotated_arg(const T& v_, const PropertyListT &P = properties{}) noexcept;
260260
Constructs an `annotated_arg` object from the input object `v_`.
261261

262262
The new property set `PropertyListT` contains all properties in `P`.
263-
If there are duplicate properties present in the property list of `P`, the values of the duplicate properties must be the same.
264263

265264
// --- ROW BREAK ---
266265
a|
@@ -269,11 +268,10 @@ a|
269268
template<typename... PropertyValueTs>
270269
annotated_arg(const T& v_, const PropertyValueTs... props) noexcept;
271270
----
272-
|
271+
| Not available in device code.
273272
Constructs an `annotated_arg` object from the input object `v_`.
274273

275-
The new property set `PropertyListT` contains all properties in `P`.
276-
If there are duplicate properties present in the property list of `P`, the values of the duplicate properties must be the same.
274+
The new property set `PropertyListT` contains all properties listed in `props`.
277275

278276
// --- ROW BREAK ---
279277
a|
@@ -282,7 +280,7 @@ a|
282280
template <typename T2, typename P> explicit annotated_arg(
283281
const annotated_arg<T2, P> &ConvertFrom);
284282
----
285-
|
283+
| Not available in device code.
286284
Constructs the `annotated_arg` object from the `ConvertFrom` object if
287285
the list of properties in `PropertyListT` is a superset of the list of
288286
properties in `P`.
@@ -297,7 +295,7 @@ template <typename T2, typename PropertyListU, typename PropertyListV>
297295
explicit annotated_arg(const annotated_arg<T2, PropertyListU>& v_,
298296
properties<PropertyListV> P) noexcept;
299297
----
300-
|
298+
| Not available in device code.
301299
Constructs the `annotated_arg` object from the input object `v_`.
302300

303301
The new `PropertyListT` is the union of all properties contained within
@@ -307,13 +305,13 @@ properties with the same value (or no value) are allowed.
307305

308306
`T2` must be implicitly convertible to `T`.
309307

310-
311308
// --- ROW BREAK ---
312309
a|
313310
[source,c++]
314311
----
315312
annotated_arg(const annotated_arg&) = default;
316313
----
314+
| Not available in device code.
317315
Compiler generated copy constructor.
318316

319317
// --- ROW BREAK ---
@@ -322,7 +320,7 @@ a|
322320
----
323321
annotated_arg& operator=(annotated_arg&) = default;
324322
----
325-
Compiler generated assignment operator.
323+
| Compiler generated assignment operator.
326324

327325
// --- ROW BREAK ---
328326
a|
@@ -343,17 +341,6 @@ a|
343341
Available if the `operator[]` is valid for objects of type `T`. This function
344342
will call the subscript operator defined for `T`.
345343

346-
// --- ROW BREAK ---
347-
a|
348-
[source,c++]
349-
----
350-
template<typename... Args> /* ... */ operator()(Args... args) noexcept;
351-
template<typename... Args> /* ... */ operator()(Args... args) const noexcept;
352-
----
353-
|
354-
Available if the `operator()` is valid for objects of type `T`. This function
355-
will call the 'call operator' defined for `T`.
356-
357344
// --- ROW BREAK ---
358345
a|
359346
[source,c++]

sycl/doc/extensions/proposed/sycl_ext_oneapi_annotated_ptr.asciidoc

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ class annotated_ptr {
217217

218218
`PropertyListT` enables properties to be associated with an `annotated_ptr`.
219219
Properties may be specified for an `annotated_ptr` to provide semantic
220-
modification or optimization hint information.
220+
modification or optimization hint information. Please note that there cannot
221+
be duplicated property in a properties list. Otherwise, a compiler time error is triggered.
221222

222223
Here's an example of how a property could be used:
223224

@@ -307,12 +308,16 @@ class annotated_ptr {
307308
308309
//Deduction guides
309310
template <typename T, typename... Args>
310-
annotated_ptr(T, Args... args) -> annotated_ptr<T, detail::properties_t<Args...>>;
311+
annotated_arg(T, Args... args) ->
312+
annotated_arg<T, detail::properties_t<Args...>>;
311313
312-
template <typename T, typename oldProp, typename otherProp>
313-
annotated_ptr(annotated_arg<T, oldProp>, otherProp other)
314-
-> annotated_ptr<T, detail::merged_properties_t<oldProp, otherProp>>;
314+
template <typename T, typename... Args>
315+
annotated_arg(T, properties<std::tuple<Args...>>) ->
316+
annotated_arg<T, detail::properties_t<Args...>>;
315317
318+
template <typename T, typename old, typename... Args>
319+
annotated_arg(annotated_arg<T, old>, properties<std::tuple<Args...>>) ->
320+
annotated_arg<T, detail::merged_properties_t<old, detail::properties_t<Args...>>>;
316321
} // namespace sycl::ext::oneapi::experimental
317322
----
318323

@@ -341,7 +346,6 @@ Constructs an `annotated_ptr` object. Does not allocate new storage. The
341346
underlying pointer is initialized with `Ptr`.
342347

343348
The new property set `PropertyListT` contains all properties in `P`.
344-
If there are duplicate properties present in the property list of `P`, the values of the duplicate properties must be the same.
345349

346350
// --- ROW BREAK ---
347351
a|
@@ -355,7 +359,6 @@ Constructs an `annotated_ptr` object. Does not allocate new storage. The
355359
underlying pointer is initialized with `Ptr`.
356360

357361
The new property set `PropertyListT` contains all properties in `P`.
358-
If there are duplicate properties present in the property list of `P`, the values of the duplicate properties must be the same.
359362

360363
// --- ROW BREAK ---
361364
a|
@@ -384,9 +387,9 @@ Constructs an `annotated_ptr` object. Does not allocate new storage. The
384387
underlying pointer is initialized with `Ptr`.
385388

386389
The new `PropertyListT` is the union of all properties contained within
387-
`PropertyListU` and `PropertyListV`. If there are any common properties in the
388-
two lists with different values, a compile-time error is triggered. Common
389-
properties with the same value (or no value) are allowed.
390+
`PropertyListU` and `PropertyListV`. If there are any common properties
391+
in the two lists with different values, a compile-time error is triggered.
392+
Common properties with the same value (or no value) are allowed.
390393

391394
`T2*` must be implicitly convertible to `T*`.
392395

@@ -564,8 +567,8 @@ class annotated_ref {
564567
public:
565568
annotated_ref(const annotated_ref&) = default;
566569
operator T() const;
567-
void operator=(const T&) const;
568-
void operator=(const annotated_ref&) const = default;
570+
annotated_ref& operator=(const T&) const;
571+
annotated_ref& operator=(const annotated_ref&) const = default;
569572
};
570573
} // namespace sycl::ext::oneapi::experimental
571574
```
@@ -599,7 +602,7 @@ annotations when the object is loaded from memory.
599602
a|
600603
[source,c++]
601604
----
602-
void operator=(const T &) const;
605+
annotated_ref& operator=(const T &) const;
603606
----
604607
|
605608
Writes an object of type `T` to the location referenced by this wrapper,
@@ -609,7 +612,7 @@ applying the annotations when the object is stored to memory.
609612
a|
610613
[source,c++]
611614
----
612-
void operator=(const annotated_ref&) const = default;
615+
annotated_ref& operator=(const annotated_ref&) const = default;
613616
----
614617
|
615618
Assign from another `annotated_ref` object.

0 commit comments

Comments
 (0)