Skip to content

Commit 7c8a2ac

Browse files
[SYCL][DOC] Change device_global property definitions (#5691)
With the recent change to the compile-time property extension, properties must follow a different structure and naming to the one used by the device_global extension. This commit makes the device_global extension adhere to the new requirements and adds additional non-template variants of templated properties, e.g. `host_access_read` as a shorthand for `host_access<host_access_enum::read>`. Signed-off-by: Steffen Larsen <[email protected]>
1 parent 2741010 commit 7c8a2ac

File tree

1 file changed

+76
-38
lines changed

1 file changed

+76
-38
lines changed

sycl/doc/extensions/proposed/sycl_ext_oneapi_device_global.asciidoc

+76-38
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ around copyability and constructors/destructors.
3636

3737
== Notice
3838

39-
Copyright (c) 2021 Intel Corporation. All rights reserved.
39+
Copyright (c) 2021 - 2022 Intel Corporation. All rights reserved.
4040

4141
NOTE: Khronos(R) is a registered trademark and SYCL(TM) and SPIR(TM) are
4242
trademarks of The Khronos Group Inc. OpenCL(TM) is a trademark of Apple Inc.
@@ -79,7 +79,7 @@ Roland Schulz, Intel
7979

8080
This extension is written against the SYCL 2020 specification, revision 3.
8181

82-
It also depends on the `SYCL_EXT_ONEAPI_PROPERTY_LIST` extension.
82+
It also depends on the `SYCL_EXT_ONEAPI_PROPERTIES` extension.
8383

8484
== Overview
8585

@@ -172,7 +172,7 @@ A `device_global` on a given device maintains its state (address of the allocati
172172
[source,c++]
173173
----
174174
namespace sycl::ext::oneapi::experimental {
175-
template <typename T, typename PropertyListT = property_list<>>
175+
template <typename T, typename PropertyListT = properties<>>
176176
class device_global {
177177
...
178178
----
@@ -203,7 +203,7 @@ The section below and the table following describe the constructors, member func
203203
----
204204
namespace sycl::ext::oneapi::experimental {
205205
206-
template <typename T, typename PropertyListT = property_list<>>
206+
template <typename T, typename PropertyListT = properties<>>
207207
class device_global {
208208
using subscript_return_t =
209209
std::remove_reference_t<decltype(std::declval<T>()[std::ptrdiff_t{}])>;
@@ -378,7 +378,7 @@ template<typename propertyT>
378378
static constexpr bool has_property();
379379
----
380380
| Returns true if the `PropertyListT` contains the property specified by `propertyT`. Returns false if it does not.
381-
Available only if `sycl::is_property_of_v<propertyT, sycl::ext::oneapi::experimental::device_global>` is true.
381+
Available only if `sycl::is_property_key_of_v<propertyT, sycl::ext::oneapi::experimental::device_global>` is true.
382382

383383
// --- ROW BREAK ---
384384
a|
@@ -389,7 +389,7 @@ static constexpr auto get_property();
389389
----
390390
| Returns an object of the class used to represent the value of property `propertyT`.
391391
Must produce a compiler diagnostic if `PropertyListT` does not contain a `propertyT` property.
392-
Available only if `sycl::is_property_of_v<propertyT, sycl::ext::oneapi::experimental::device_global>` is true.
392+
Available only if `sycl::is_property_key_of_v<propertyT, sycl::ext::oneapi::experimental::device_global>` is true.
393393

394394
|===
395395

@@ -491,8 +491,8 @@ parameter as shown in this example:
491491
----
492492
using namespace sycl::ext::oneapi::experimental;
493493
494-
device_global<MyClass, property_list_t<device_image_scope::value_t>> dm1;
495-
device_global<int[4], property_list_t<host_access::value_t<host_access::access::read>> dm2;
494+
device_global<MyClass, decltype(properties(device_image_scope))> dm1;
495+
device_global<int[4], decltype(properties(host_access_read))> dm2;
496496
----
497497

498498
The following code synopsis shows the set of supported properties, and the
@@ -502,45 +502,83 @@ following table describes their effect.
502502
----
503503
namespace sycl::ext::oneapi::experimental {
504504
505-
struct device_image_scope {
506-
using value_t = property_value<device_image_scope>;
505+
struct device_image_scope_key {
506+
using value_t = property_value<device_image_scope_key>;
507507
};
508508
509-
struct host_access {
510-
enum class access: /*unspecified*/ {
511-
read,
512-
write,
513-
read_write,
514-
none
515-
};
516-
template<access A>
517-
using value_t = property_value<host_access, std::integral_constant<access, A>>;
518-
519-
struct init_mode {
520-
enum class trigger: /*unspecified*/ {
521-
reprogram,
522-
reset
523-
};
524-
template<trigger T>
525-
using value_t = property_value<init_mode, std::integral_constant<trigger, T>>;
509+
enum class host_access_enum : /* unspecified */ {
510+
read,
511+
write,
512+
read_write,
513+
none
526514
};
527515
528-
struct implement_in_csr {
529-
template <bool Enable>
530-
using value_t = property_value<implement_in_csr, std::bool_constant<Enable>>;
516+
struct host_access_key {
517+
template <host_access_enum Access>
518+
using value_t =
519+
property_value<host_access_key,
520+
std::integral_constant<host_access_enum, Access>>;
531521
};
532522
523+
enum class init_mode_enum : /* unspecified */ {
524+
reprogram,
525+
reset
526+
};
533527
534-
inline constexpr device_image_scope::value_t device_image_scope_v;
528+
struct init_mode_key {
529+
template <init_mode_enum Trigger>
530+
using value_t =
531+
property_value<init_mode_key,
532+
std::integral_constant<init_mode_enum, Trigger>>;
533+
};
535534
536-
template<host_access::access A>
537-
inline constexpr host_access::value_t<A> host_access_v;
535+
struct implement_in_csr_key {
536+
template <bool Enable>
537+
using value_t =
538+
property_value<implement_in_csr_key, std::bool_constant<Enable>>;
539+
};
538540
539-
template<init_mode::trigger T>
540-
inline constexpr init_mode::value_t<T> init_mode_v;
541+
inline constexpr device_image_scope_key::value_t device_image_scope;
542+
543+
template <host_access_enum Access>
544+
inline constexpr host_access_key::value_t<Access> host_access;
545+
inline constexpr host_access_key::value_t<host_access_enum::read>
546+
host_access_read;
547+
inline constexpr host_access_key::value_t<host_access_enum::write>
548+
host_access_write;
549+
inline constexpr host_access_key::value_t<host_access_enum::read_write>
550+
host_access_read_write;
551+
inline constexpr host_access_key::value_t<host_access_enum::none>
552+
host_access_none;
553+
554+
template <init_mode_enum Trigger>
555+
inline constexpr init_mode_key::value_t<Trigger> init_mode;
556+
inline constexpr init_mode_key::value_t<init_mode_enum::reprogram>
557+
init_mode_reprogram;
558+
inline constexpr init_mode_key::value_t<init_mode_enum::reset> init_mode_reset;
559+
560+
template <bool Enable>
561+
inline constexpr implement_in_csr_key::value_t<Enable> implement_in_csr;
562+
inline constexpr implement_in_csr_key::value_t<true> implement_in_csr_on;
563+
inline constexpr implement_in_csr_key::value_t<false> implement_in_csr_off;
564+
565+
template <> struct is_property_key<device_image_scope_key> : std::true_type {};
566+
template <> struct is_property_key<host_access_key> : std::true_type {};
567+
template <> struct is_property_key<init_mode_key> : std::true_type {};
568+
template <> struct is_property_key<implement_in_csr_key> : std::true_type {};
541569
542-
template<bool Enable>
543-
inline constexpr implement_in_csr::value_t<Enable> implement_in_csr_v;
570+
template <typename T, typename PropertyListT>
571+
struct is_property_key_of<device_image_scope_key, device_global<T, PropertyListT>>
572+
: std::true_type {};
573+
template <typename T, typename PropertyListT>
574+
struct is_property_key_of<host_access_key, device_global<T, PropertyListT>>
575+
: std::true_type {};
576+
template <typename T, typename PropertyListT>
577+
struct is_property_key_of<init_mode_key, device_global<T, PropertyListT>>
578+
: std::true_type {};
579+
template <typename T, typename PropertyListT>
580+
struct is_property_key_of<implement_in_csr_key, device_global<T, PropertyListT>>
581+
: std::true_type {};
544582
545583
} // namespace sycl::ext::oneapi::experimental
546584
----
@@ -1078,7 +1116,7 @@ A sketch of the anticipated constructor interface is:
10781116
----
10791117
namespace sycl::ext::oneapi::experimental {
10801118
1081-
template <typename T, typename PropertyListT = property_list<>>
1119+
template <typename T, typename PropertyListT = properties<>>
10821120
class device_global {
10831121
public:
10841122
using element_type = std::remove_extent_t<T>;

0 commit comments

Comments
 (0)