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

[SYCL] Support query of free device memory extension #1162

Merged
merged 5 commits into from
Sep 6, 2022
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
31 changes: 31 additions & 0 deletions SYCL/Plugin/level_zero_device_free_mem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// REQUIRES: level_zero, level_zero_dev_kit

// 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
// backend
//
// CHECK: Free device memory

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CHECK will pass only if ext_intel_device_info_free_memory is supported by the device. I think we expect the test to pass even if device doesn't support it. The only option I see is to remove this CHECK, I guess we don't have dynamic checks.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we expect that ALL Level Zero devices support this extension.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@againull : are you OK with the test? we need this to complete the new feature (the compiler fix was merged)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I am ok with the test, thanks for clarification.


#include <iostream>
#include <sycl/sycl.hpp>
using namespace sycl;

int main() {

queue Queue;
auto dev = Queue.get_device();
std::cout << "Device: " << dev.get_info<info::device::name>() << std::endl;

if (!dev.is_host() && dev.has(aspect::ext_intel_free_memory)) {
auto FreeMemory = dev.get_info<info::device::ext_intel_free_memory>();
std::cout << "Free device memory: " << FreeMemory << std::endl;
} else {
std::cout
<< "Query ext_intel_device_info_free_memory not supported by the device"
<< std::endl;
}

return 0;
}