Skip to content

Commit 832161b

Browse files
[SYCL] Add assert for device_global without device_image_scope (intel#6791)
device_global is currently not fully supported but for backends that support it, they should be usable on device only when the device_image_scope property is present. This commit adds a temporary static assert to avoid prevent the use of device_global without device_image_scope until proper initialization has been implemented. Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
1 parent 0f579ba commit 832161b

File tree

2 files changed

+47
-32
lines changed

2 files changed

+47
-32
lines changed

sycl/include/sycl/ext/oneapi/device_global/device_global.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ class
101101
static_assert(is_property_list<property_list_t>::value,
102102
"Property list is invalid.");
103103

104+
// TODO: Remove when support has been added for device_global without the
105+
// device_image_scope property.
106+
static_assert(
107+
property_list_t::template has_property<device_image_scope_key>(),
108+
"device_global without the device_image_scope property is currently "
109+
"unavailable.");
110+
104111
device_global() = default;
105112

106113
device_global(const device_global &) = delete;

sycl/test/extensions/device_global/device_global_properties.cpp

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,25 @@
55

66
using namespace sycl::ext::oneapi::experimental;
77

8-
static device_global<int> DeviceGlobal1;
8+
// TODO: device_global currently requires device_image_scope. When this
9+
// requirement is lifted the tests should include a case without any properties
10+
// and DeviceGlobal2, DeviceGlobal3, and DeviceGlobal4 should have
11+
// device_image_scope removed.
912
static device_global<int, decltype(properties(device_image_scope))>
13+
DeviceGlobal1;
14+
static device_global<int,
15+
decltype(properties(device_image_scope, host_access_none))>
1016
DeviceGlobal2;
11-
static device_global<int, decltype(properties(host_access_none))> DeviceGlobal3;
12-
static device_global<int, decltype(properties(init_mode_reset))> DeviceGlobal4;
13-
static device_global<int, decltype(properties(implement_in_csr_on))>
14-
DeviceGlobal5;
17+
static device_global<int,
18+
decltype(properties(device_image_scope, init_mode_reset))>
19+
DeviceGlobal3;
20+
static device_global<int, decltype(properties(device_image_scope,
21+
implement_in_csr_on))>
22+
DeviceGlobal4;
1523
static device_global<int, decltype(properties(
1624
implement_in_csr_off, host_access_write,
1725
device_image_scope, init_mode_reprogram))>
18-
DeviceGlobal6;
26+
DeviceGlobal5;
1927

2028
// Checks is_property_key_of and is_property_value_of for T.
2129
template <typename T> void checkIsPropertyOf() {
@@ -53,54 +61,54 @@ int main() {
5361
static_assert(is_property_value<decltype(implement_in_csr_off)>::value);
5462

5563
checkIsPropertyOf<decltype(DeviceGlobal1)>();
56-
static_assert(!DeviceGlobal1.has_property<device_image_scope_key>());
64+
static_assert(DeviceGlobal1.has_property<device_image_scope_key>());
5765
static_assert(!DeviceGlobal1.has_property<host_access_key>());
5866
static_assert(!DeviceGlobal1.has_property<init_mode_key>());
5967
static_assert(!DeviceGlobal1.has_property<implement_in_csr_key>());
68+
static_assert(DeviceGlobal1.get_property<device_image_scope_key>() ==
69+
device_image_scope);
6070

6171
checkIsPropertyOf<decltype(DeviceGlobal2)>();
6272
static_assert(DeviceGlobal2.has_property<device_image_scope_key>());
63-
static_assert(!DeviceGlobal2.has_property<host_access_key>());
73+
static_assert(DeviceGlobal2.has_property<host_access_key>());
6474
static_assert(!DeviceGlobal2.has_property<init_mode_key>());
6575
static_assert(!DeviceGlobal2.has_property<implement_in_csr_key>());
6676
static_assert(DeviceGlobal2.get_property<device_image_scope_key>() ==
6777
device_image_scope);
78+
static_assert(DeviceGlobal2.get_property<host_access_key>().value ==
79+
host_access_enum::none);
6880

6981
checkIsPropertyOf<decltype(DeviceGlobal3)>();
70-
static_assert(!DeviceGlobal3.has_property<device_image_scope_key>());
71-
static_assert(DeviceGlobal3.has_property<host_access_key>());
72-
static_assert(!DeviceGlobal3.has_property<init_mode_key>());
82+
static_assert(DeviceGlobal3.has_property<device_image_scope_key>());
83+
static_assert(!DeviceGlobal3.has_property<host_access_key>());
84+
static_assert(DeviceGlobal3.has_property<init_mode_key>());
7385
static_assert(!DeviceGlobal3.has_property<implement_in_csr_key>());
74-
static_assert(DeviceGlobal3.get_property<host_access_key>().value ==
75-
host_access_enum::none);
86+
static_assert(DeviceGlobal3.get_property<device_image_scope_key>() ==
87+
device_image_scope);
88+
static_assert(DeviceGlobal3.get_property<init_mode_key>().value ==
89+
init_mode_enum::reset);
7690

7791
checkIsPropertyOf<decltype(DeviceGlobal4)>();
78-
static_assert(!DeviceGlobal4.has_property<device_image_scope_key>());
92+
static_assert(DeviceGlobal4.has_property<device_image_scope_key>());
7993
static_assert(!DeviceGlobal4.has_property<host_access_key>());
80-
static_assert(DeviceGlobal4.has_property<init_mode_key>());
81-
static_assert(!DeviceGlobal4.has_property<implement_in_csr_key>());
82-
static_assert(DeviceGlobal4.get_property<init_mode_key>().value ==
83-
init_mode_enum::reset);
94+
static_assert(!DeviceGlobal4.has_property<init_mode_key>());
95+
static_assert(DeviceGlobal4.has_property<implement_in_csr_key>());
96+
static_assert(DeviceGlobal4.get_property<device_image_scope_key>() ==
97+
device_image_scope);
98+
static_assert(DeviceGlobal4.get_property<implement_in_csr_key>().value);
8499

85100
checkIsPropertyOf<decltype(DeviceGlobal5)>();
86-
static_assert(!DeviceGlobal5.has_property<device_image_scope_key>());
87-
static_assert(!DeviceGlobal5.has_property<host_access_key>());
88-
static_assert(!DeviceGlobal5.has_property<init_mode_key>());
101+
static_assert(DeviceGlobal5.has_property<device_image_scope_key>());
102+
static_assert(DeviceGlobal5.has_property<host_access_key>());
103+
static_assert(DeviceGlobal5.has_property<init_mode_key>());
89104
static_assert(DeviceGlobal5.has_property<implement_in_csr_key>());
90-
static_assert(DeviceGlobal5.get_property<implement_in_csr_key>().value);
91-
92-
checkIsPropertyOf<decltype(DeviceGlobal6)>();
93-
static_assert(DeviceGlobal6.has_property<device_image_scope_key>());
94-
static_assert(DeviceGlobal6.has_property<host_access_key>());
95-
static_assert(DeviceGlobal6.has_property<init_mode_key>());
96-
static_assert(DeviceGlobal6.has_property<implement_in_csr_key>());
97-
static_assert(DeviceGlobal6.get_property<device_image_scope_key>() ==
105+
static_assert(DeviceGlobal5.get_property<device_image_scope_key>() ==
98106
device_image_scope);
99-
static_assert(DeviceGlobal6.get_property<host_access_key>().value ==
107+
static_assert(DeviceGlobal5.get_property<host_access_key>().value ==
100108
host_access_enum::write);
101-
static_assert(DeviceGlobal6.get_property<init_mode_key>().value ==
109+
static_assert(DeviceGlobal5.get_property<init_mode_key>().value ==
102110
init_mode_enum::reprogram);
103-
static_assert(!DeviceGlobal6.get_property<implement_in_csr_key>().value);
111+
static_assert(!DeviceGlobal5.get_property<implement_in_csr_key>().value);
104112

105113
return 0;
106114
}

0 commit comments

Comments
 (0)