5
5
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %level_zero_options %s -o %t.out
6
6
// RUN: env ZES_ENABLE_SYSMAN=1 %GPU_RUN_PLACEHOLDER %t.out 2>&1 %GPU_CHECK_PLACEHOLDER
7
7
//
8
- // The test is to check that the free device memory is reported be Level Zero
8
+ // The test is to check that the free device memory is reported by Level Zero
9
9
// backend
10
10
//
11
- // CHECK: Free device memory
11
+ // CHECK: Root- device free memory
12
12
13
13
#include < iostream>
14
14
#include < sycl/sycl.hpp>
@@ -21,8 +21,37 @@ int main() {
21
21
std::cout << " Device: " << dev.get_info <info::device::name>() << std::endl;
22
22
23
23
if (!dev.is_host () && dev.has (aspect::ext_intel_free_memory)) {
24
+ auto TotalMemory = dev.get_info <sycl::info::device::global_mem_size>();
24
25
auto FreeMemory = dev.get_info <ext::intel::info::device::free_memory>();
25
- std::cout << " Free device memory: " << FreeMemory << std::endl;
26
+ std::cout << " Root-device total memory: " << TotalMemory << std::endl;
27
+ std::cout << " Root-device free memory: " << FreeMemory << std::endl;
28
+ assert (TotalMemory >= FreeMemory);
29
+
30
+ try { // guard for when no partitioning is supported
31
+
32
+ auto sub_devices = dev.create_sub_devices <
33
+ info::partition_property::partition_by_affinity_domain>(
34
+ info::partition_affinity_domain::next_partitionable);
35
+
36
+ int I = 0 ;
37
+ for (auto &sub_device : sub_devices) {
38
+ ++I;
39
+ auto SubDeviceTotalMemory =
40
+ sub_device.get_info <sycl::info::device::global_mem_size>();
41
+ auto SubDeviceFreeMemory =
42
+ sub_device.get_info <ext::intel::info::device::free_memory>();
43
+ std::cout << I << " sub-device total memory: " << SubDeviceTotalMemory
44
+ << std::endl;
45
+ std::cout << I << " sub-device free memory: " << SubDeviceFreeMemory
46
+ << std::endl;
47
+ assert (SubDeviceFreeMemory <= FreeMemory);
48
+ assert (SubDeviceTotalMemory >= SubDeviceFreeMemory);
49
+ assert (SubDeviceTotalMemory <= TotalMemory);
50
+ }
51
+
52
+ } catch (...) {
53
+ }
54
+
26
55
} else {
27
56
std::cout
28
57
<< " Query ext_intel_device_info_free_memory not supported by the device"
0 commit comments