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

[SYCL][L0] Check that sub-device free memory does not exceed root-device one #1453

Merged
merged 2 commits into from
Jan 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions SYCL/Plugin/level_zero_device_free_mem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %level_zero_options %s -o %t.out
// RUN: env ZES_ENABLE_SYSMAN=1 %GPU_RUN_PLACEHOLDER %t.out 2>&1 %GPU_CHECK_PLACEHOLDER
//
// The test is to check that the free device memory is reported be Level Zero
// The test is to check that the free device memory is reported by Level Zero
// backend
//
// CHECK: Free device memory
// CHECK: Root-device free memory

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

if (!dev.is_host() && dev.has(aspect::ext_intel_free_memory)) {
auto TotalMemory = dev.get_info<sycl::info::device::global_mem_size>();
auto FreeMemory = dev.get_info<ext::intel::info::device::free_memory>();
std::cout << "Free device memory: " << FreeMemory << std::endl;
std::cout << "Root-device total memory: " << TotalMemory << std::endl;
std::cout << "Root-device free memory: " << FreeMemory << std::endl;
assert(TotalMemory >= FreeMemory);

try { // guard for when no partitioning is supported

auto sub_devices = dev.create_sub_devices<
info::partition_property::partition_by_affinity_domain>(
info::partition_affinity_domain::next_partitionable);

int I = 0;
for (auto &sub_device : sub_devices) {
++I;
auto SubDeviceTotalMemory =
sub_device.get_info<sycl::info::device::global_mem_size>();
auto SubDeviceFreeMemory =
sub_device.get_info<ext::intel::info::device::free_memory>();
std::cout << I << " sub-device total memory: " << SubDeviceTotalMemory
<< std::endl;
std::cout << I << " sub-device free memory: " << SubDeviceFreeMemory
<< std::endl;
assert(SubDeviceFreeMemory <= FreeMemory);
assert(SubDeviceTotalMemory >= SubDeviceFreeMemory);
assert(SubDeviceTotalMemory <= TotalMemory);
}

} catch (...) {
}

} else {
std::cout
<< "Query ext_intel_device_info_free_memory not supported by the device"
Expand Down