|
3 | 3 |
|
4 | 4 | #include <sycl/sycl.hpp>
|
5 | 5 |
|
| 6 | +using namespace sycl; |
6 | 7 | using namespace sycl::ext::oneapi::experimental;
|
7 | 8 |
|
| 9 | +using device_has_all = |
| 10 | + decltype(device_has< |
| 11 | + aspect::host, aspect::cpu, aspect::gpu, aspect::accelerator, |
| 12 | + aspect::custom, aspect::fp16, aspect::fp64, aspect::image, |
| 13 | + aspect::online_compiler, aspect::online_linker, |
| 14 | + aspect::queue_profiling, aspect::usm_device_allocations, |
| 15 | + aspect::usm_host_allocations, aspect::usm_shared_allocations, |
| 16 | + aspect::usm_restricted_shared_allocations, |
| 17 | + aspect::usm_system_allocations, aspect::ext_intel_pci_address, |
| 18 | + aspect::ext_intel_gpu_eu_count, |
| 19 | + aspect::ext_intel_gpu_eu_simd_width, aspect::ext_intel_gpu_slices, |
| 20 | + aspect::ext_intel_gpu_subslices_per_slice, |
| 21 | + aspect::ext_intel_gpu_eu_count_per_subslice, |
| 22 | + aspect::ext_intel_max_mem_bandwidth, aspect::ext_intel_mem_channel, |
| 23 | + aspect::usm_atomic_host_allocations, |
| 24 | + aspect::usm_atomic_shared_allocations, aspect::atomic64, |
| 25 | + aspect::ext_intel_device_info_uuid, aspect::ext_oneapi_srgb, |
| 26 | + aspect::ext_oneapi_native_assert, aspect::host_debuggable, |
| 27 | + aspect::ext_intel_gpu_hw_threads_per_eu, |
| 28 | + aspect::ext_oneapi_cuda_async_barrier, aspect::ext_oneapi_bfloat16, |
| 29 | + aspect::ext_intel_free_memory, aspect::ext_intel_device_id>); |
| 30 | + |
| 31 | +template <aspect Aspect> inline void singleAspectDeviceHasChecks() { |
| 32 | + static_assert(is_property_value<decltype(device_has<Aspect>)>::value); |
| 33 | + static_assert(std::is_same_v<device_has_key, |
| 34 | + typename decltype(device_has<Aspect>)::key_t>); |
| 35 | + static_assert(decltype(device_has<Aspect>)::value.size() == 1); |
| 36 | + static_assert(decltype(device_has<Aspect>)::value[0] == Aspect); |
| 37 | +} |
| 38 | + |
8 | 39 | int main() {
|
9 | 40 | static_assert(is_property_key<work_group_size_key>::value);
|
10 | 41 | static_assert(is_property_key<work_group_size_hint_key>::value);
|
11 | 42 | static_assert(is_property_key<sub_group_size_key>::value);
|
| 43 | + static_assert(is_property_key<device_has_key>::value); |
12 | 44 |
|
13 | 45 | static_assert(is_property_value<decltype(work_group_size<1>)>::value);
|
14 | 46 | static_assert(is_property_value<decltype(work_group_size<2, 2>)>::value);
|
@@ -52,5 +84,96 @@ int main() {
|
52 | 84 | static_assert(std::is_same_v<decltype(sub_group_size<28>)::value_t,
|
53 | 85 | std::integral_constant<uint32_t, 28>>);
|
54 | 86 |
|
| 87 | + singleAspectDeviceHasChecks<aspect::host>(); |
| 88 | + singleAspectDeviceHasChecks<aspect::cpu>(); |
| 89 | + singleAspectDeviceHasChecks<aspect::gpu>(); |
| 90 | + singleAspectDeviceHasChecks<aspect::accelerator>(); |
| 91 | + singleAspectDeviceHasChecks<aspect::custom>(); |
| 92 | + singleAspectDeviceHasChecks<aspect::fp16>(); |
| 93 | + singleAspectDeviceHasChecks<aspect::fp64>(); |
| 94 | + singleAspectDeviceHasChecks<aspect::image>(); |
| 95 | + singleAspectDeviceHasChecks<aspect::online_compiler>(); |
| 96 | + singleAspectDeviceHasChecks<aspect::online_linker>(); |
| 97 | + singleAspectDeviceHasChecks<aspect::queue_profiling>(); |
| 98 | + singleAspectDeviceHasChecks<aspect::usm_device_allocations>(); |
| 99 | + singleAspectDeviceHasChecks<aspect::usm_host_allocations>(); |
| 100 | + singleAspectDeviceHasChecks<aspect::usm_shared_allocations>(); |
| 101 | + singleAspectDeviceHasChecks<aspect::usm_restricted_shared_allocations>(); |
| 102 | + singleAspectDeviceHasChecks<aspect::usm_system_allocations>(); |
| 103 | + singleAspectDeviceHasChecks<aspect::ext_intel_pci_address>(); |
| 104 | + singleAspectDeviceHasChecks<aspect::ext_intel_gpu_eu_count>(); |
| 105 | + singleAspectDeviceHasChecks<aspect::ext_intel_gpu_eu_simd_width>(); |
| 106 | + singleAspectDeviceHasChecks<aspect::ext_intel_gpu_slices>(); |
| 107 | + singleAspectDeviceHasChecks<aspect::ext_intel_gpu_subslices_per_slice>(); |
| 108 | + singleAspectDeviceHasChecks<aspect::ext_intel_gpu_eu_count_per_subslice>(); |
| 109 | + singleAspectDeviceHasChecks<aspect::ext_intel_max_mem_bandwidth>(); |
| 110 | + singleAspectDeviceHasChecks<aspect::ext_intel_mem_channel>(); |
| 111 | + singleAspectDeviceHasChecks<aspect::usm_atomic_host_allocations>(); |
| 112 | + singleAspectDeviceHasChecks<aspect::usm_atomic_shared_allocations>(); |
| 113 | + singleAspectDeviceHasChecks<aspect::atomic64>(); |
| 114 | + singleAspectDeviceHasChecks<aspect::ext_intel_device_info_uuid>(); |
| 115 | + singleAspectDeviceHasChecks<aspect::ext_oneapi_srgb>(); |
| 116 | + singleAspectDeviceHasChecks<aspect::ext_oneapi_native_assert>(); |
| 117 | + singleAspectDeviceHasChecks<aspect::host_debuggable>(); |
| 118 | + singleAspectDeviceHasChecks<aspect::ext_intel_gpu_hw_threads_per_eu>(); |
| 119 | + singleAspectDeviceHasChecks<aspect::ext_oneapi_cuda_async_barrier>(); |
| 120 | + singleAspectDeviceHasChecks<aspect::ext_oneapi_bfloat16>(); |
| 121 | + singleAspectDeviceHasChecks<aspect::ext_intel_free_memory>(); |
| 122 | + singleAspectDeviceHasChecks<aspect::ext_intel_device_id>(); |
| 123 | + |
| 124 | + static_assert(is_property_value<decltype(device_has<>)>::value); |
| 125 | + static_assert(std::is_same_v<device_has_key, decltype(device_has<>)::key_t>); |
| 126 | + static_assert(decltype(device_has<>)::value.size() == 0); |
| 127 | + |
| 128 | + static_assert(is_property_value<device_has_all>::value); |
| 129 | + static_assert(std::is_same_v<device_has_key, device_has_all::key_t>); |
| 130 | + static_assert(device_has_all::value.size() == 36); |
| 131 | + static_assert(device_has_all::value[0] == aspect::host); |
| 132 | + static_assert(device_has_all::value[1] == aspect::cpu); |
| 133 | + static_assert(device_has_all::value[2] == aspect::gpu); |
| 134 | + static_assert(device_has_all::value[3] == aspect::accelerator); |
| 135 | + static_assert(device_has_all::value[4] == aspect::custom); |
| 136 | + static_assert(device_has_all::value[5] == aspect::fp16); |
| 137 | + static_assert(device_has_all::value[6] == aspect::fp64); |
| 138 | + static_assert(device_has_all::value[7] == aspect::image); |
| 139 | + static_assert(device_has_all::value[8] == aspect::online_compiler); |
| 140 | + static_assert(device_has_all::value[9] == aspect::online_linker); |
| 141 | + static_assert(device_has_all::value[10] == aspect::queue_profiling); |
| 142 | + static_assert(device_has_all::value[11] == aspect::usm_device_allocations); |
| 143 | + static_assert(device_has_all::value[12] == aspect::usm_host_allocations); |
| 144 | + static_assert(device_has_all::value[13] == aspect::usm_shared_allocations); |
| 145 | + static_assert(device_has_all::value[14] == |
| 146 | + aspect::usm_restricted_shared_allocations); |
| 147 | + static_assert(device_has_all::value[15] == aspect::usm_system_allocations); |
| 148 | + static_assert(device_has_all::value[16] == aspect::ext_intel_pci_address); |
| 149 | + static_assert(device_has_all::value[17] == aspect::ext_intel_gpu_eu_count); |
| 150 | + static_assert(device_has_all::value[18] == |
| 151 | + aspect::ext_intel_gpu_eu_simd_width); |
| 152 | + static_assert(device_has_all::value[19] == aspect::ext_intel_gpu_slices); |
| 153 | + static_assert(device_has_all::value[20] == |
| 154 | + aspect::ext_intel_gpu_subslices_per_slice); |
| 155 | + static_assert(device_has_all::value[21] == |
| 156 | + aspect::ext_intel_gpu_eu_count_per_subslice); |
| 157 | + static_assert(device_has_all::value[22] == |
| 158 | + aspect::ext_intel_max_mem_bandwidth); |
| 159 | + static_assert(device_has_all::value[23] == aspect::ext_intel_mem_channel); |
| 160 | + static_assert(device_has_all::value[24] == |
| 161 | + aspect::usm_atomic_host_allocations); |
| 162 | + static_assert(device_has_all::value[25] == |
| 163 | + aspect::usm_atomic_shared_allocations); |
| 164 | + static_assert(device_has_all::value[26] == aspect::atomic64); |
| 165 | + static_assert(device_has_all::value[27] == |
| 166 | + aspect::ext_intel_device_info_uuid); |
| 167 | + static_assert(device_has_all::value[28] == aspect::ext_oneapi_srgb); |
| 168 | + static_assert(device_has_all::value[29] == aspect::ext_oneapi_native_assert); |
| 169 | + static_assert(device_has_all::value[30] == aspect::host_debuggable); |
| 170 | + static_assert(device_has_all::value[31] == |
| 171 | + aspect::ext_intel_gpu_hw_threads_per_eu); |
| 172 | + static_assert(device_has_all::value[32] == |
| 173 | + aspect::ext_oneapi_cuda_async_barrier); |
| 174 | + static_assert(device_has_all::value[33] == aspect::ext_oneapi_bfloat16); |
| 175 | + static_assert(device_has_all::value[34] == aspect::ext_intel_free_memory); |
| 176 | + static_assert(device_has_all::value[35] == aspect::ext_intel_device_id); |
| 177 | + |
55 | 178 | return 0;
|
56 | 179 | }
|
0 commit comments