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

Commit 4aaa02c

Browse files
committed
[SYCL] E2E test fot interop_task with Level-Zero using get_mem()
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent 304433f commit 4aaa02c

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// REQUIRES: level_zero, level_zero_dev_kit
2+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %level_zero_options %s -o %t.out
3+
// RUN: env SYCL_BE=PI_LEVEL_ZERO %GPU_RUN_PLACEHOLDER %t.out
4+
5+
// Test for Level Zero interop_task
6+
7+
#include <CL/sycl.hpp>
8+
// clang-format off
9+
#include <level_zero/ze_api.h>
10+
#include <CL/sycl/backend/level_zero.hpp>
11+
// clang-format on
12+
13+
class my_selector : public cl::sycl::device_selector {
14+
public:
15+
int operator()(const cl::sycl::device &dev) const override {
16+
return (dev.get_platform().get_backend() == cl::sycl::backend::level_zero)
17+
? 1
18+
: 0;
19+
}
20+
};
21+
22+
int main() {
23+
sycl::queue sycl_queue = sycl::queue(my_selector());
24+
25+
ze_context_handle_t ze_context =
26+
sycl_queue.get_context().get_native<sycl::backend::level_zero>();
27+
std::cout << "zeContextGetStatus = " << zeContextGetStatus(ze_context)
28+
<< std::endl;
29+
30+
auto buf = cl::sycl::buffer<uint8_t, 1>(1024);
31+
sycl_queue.submit([&](cl::sycl::handler &cgh) {
32+
auto acc = buf.get_access<cl::sycl::access::mode::write>(cgh);
33+
cgh.interop_task([&](const cl::sycl::interop_handler &ih) {
34+
void *device_ptr = ih.get_mem<sycl::backend::level_zero>(acc);
35+
ze_memory_allocation_properties_t memAllocProperties{};
36+
zeMemGetAllocProperties(ze_context, device_ptr, &memAllocProperties,
37+
nullptr);
38+
std::cout << "Memory type = " << memAllocProperties.type << std::endl;
39+
});
40+
});
41+
42+
return 0;
43+
}

0 commit comments

Comments
 (0)