From 4aaa02c3329cb5dc11001ada2cde551c06b894ab Mon Sep 17 00:00:00 2001 From: Sergey V Maslov Date: Thu, 4 Mar 2021 15:35:32 -0800 Subject: [PATCH] [SYCL] E2E test fot interop_task with Level-Zero using get_mem() Signed-off-by: Sergey V Maslov --- .../interop-level-zero-interop-task-mem.cpp | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 SYCL/Plugin/interop-level-zero-interop-task-mem.cpp diff --git a/SYCL/Plugin/interop-level-zero-interop-task-mem.cpp b/SYCL/Plugin/interop-level-zero-interop-task-mem.cpp new file mode 100644 index 0000000000..d4475f3e87 --- /dev/null +++ b/SYCL/Plugin/interop-level-zero-interop-task-mem.cpp @@ -0,0 +1,43 @@ +// REQUIRES: level_zero, level_zero_dev_kit +// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %level_zero_options %s -o %t.out +// RUN: env SYCL_BE=PI_LEVEL_ZERO %GPU_RUN_PLACEHOLDER %t.out + +// Test for Level Zero interop_task + +#include +// clang-format off +#include +#include +// clang-format on + +class my_selector : public cl::sycl::device_selector { +public: + int operator()(const cl::sycl::device &dev) const override { + return (dev.get_platform().get_backend() == cl::sycl::backend::level_zero) + ? 1 + : 0; + } +}; + +int main() { + sycl::queue sycl_queue = sycl::queue(my_selector()); + + ze_context_handle_t ze_context = + sycl_queue.get_context().get_native(); + std::cout << "zeContextGetStatus = " << zeContextGetStatus(ze_context) + << std::endl; + + auto buf = cl::sycl::buffer(1024); + sycl_queue.submit([&](cl::sycl::handler &cgh) { + auto acc = buf.get_access(cgh); + cgh.interop_task([&](const cl::sycl::interop_handler &ih) { + void *device_ptr = ih.get_mem(acc); + ze_memory_allocation_properties_t memAllocProperties{}; + zeMemGetAllocProperties(ze_context, device_ptr, &memAllocProperties, + nullptr); + std::cout << "Memory type = " << memAllocProperties.type << std::endl; + }); + }); + + return 0; +}