Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit f436da1

Browse files
[SYCL][L0] Check that sub-device free memory does not exceed root-device one (#1453)
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent 4d1861b commit f436da1

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

SYCL/Plugin/level_zero_device_free_mem.cpp

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %level_zero_options %s -o %t.out
66
// RUN: env ZES_ENABLE_SYSMAN=1 %GPU_RUN_PLACEHOLDER %t.out 2>&1 %GPU_CHECK_PLACEHOLDER
77
//
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
99
// backend
1010
//
11-
// CHECK: Free device memory
11+
// CHECK: Root-device free memory
1212

1313
#include <iostream>
1414
#include <sycl/sycl.hpp>
@@ -21,8 +21,37 @@ int main() {
2121
std::cout << "Device: " << dev.get_info<info::device::name>() << std::endl;
2222

2323
if (!dev.is_host() && dev.has(aspect::ext_intel_free_memory)) {
24+
auto TotalMemory = dev.get_info<sycl::info::device::global_mem_size>();
2425
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+
2655
} else {
2756
std::cout
2857
<< "Query ext_intel_device_info_free_memory not supported by the device"

0 commit comments

Comments
 (0)