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

Commit 329de39

Browse files
committed
[SYC] E2E test for interop that keeps ownership in the app
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent 18c9f1d commit 329de39

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// REQUIRES: level_zero,level_zero_headers
2+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -I %sycl_source_dir %s -o %t.out
3+
// RUN: env SYCL_BE=PI_LEVEL_ZERO %GPU_RUN_PLACEHOLDER %t.out
4+
5+
// Test for Level Zero interop API where SYCL RT doesn't take ownership
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+
using namespace cl::sycl;
14+
15+
int main() {
16+
17+
// Creat SYCL platform/device
18+
device Device(gpu_selector{});
19+
platform Platform = Device.get_info<info::device::platform>();
20+
21+
// Create native Level-Zero context
22+
ze_context_handle_t ZeContext;
23+
ze_context_desc_t ZeContextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC, nullptr,
24+
0};
25+
auto ZeDriver = Platform.get_native<backend::level_zero>();
26+
auto ZeDevice = Device.get_native<backend::level_zero>();
27+
zeContextCreate(ZeDriver, &ZeContextDesc, &ZeContext);
28+
29+
{ // Scope in which SYCL interop context object is live
30+
vector_class<device> Devices{};
31+
Devices.push_back(Device);
32+
auto ContextInterop = level_zero::make<context>(
33+
Devices, ZeContext, level_zero::ownership::keep);
34+
}
35+
36+
// Verifies that Level-Zero context is not destroyed by SYCL RT yet.
37+
zeContextDestroy(ZeContext);
38+
return 0;
39+
}

0 commit comments

Comments
 (0)