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

Commit a49d9f6

Browse files
committed
fix SYCL/Plugin/interop-level-zero.cpp
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent 329de39 commit a49d9f6

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

SYCL/Plugin/interop-level-zero-keep-ownership.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// REQUIRES: level_zero,level_zero_headers
2-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -I %sycl_source_dir %s -o %t.out
2+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -I %sycl_source_dir %s -o %t.out -lze_loader
33
// RUN: env SYCL_BE=PI_LEVEL_ZERO %GPU_RUN_PLACEHOLDER %t.out
44

55
// Test for Level Zero interop API where SYCL RT doesn't take ownership

SYCL/Plugin/interop-level-zero.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// REQUIRES: level_zero,level_zero_headers
2-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -I %sycl_source_dir %s -o %t.out
2+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -I %sycl_source_dir %s -o %t.out -lze_loader
33
// RUN: env SYCL_BE=PI_LEVEL_ZERO %GPU_RUN_PLACEHOLDER %t.out
44

55
// Test for Level Zero interop API
@@ -24,17 +24,24 @@ int main() {
2424
auto ZeContext = Context.get_native<backend::level_zero>();
2525
auto ZeQueue = Queue.get_native<backend::level_zero>();
2626

27+
// Create native Level-Zero context.
28+
// It then will be owned/destroyed by SYCL RT.
29+
ze_context_handle_t ZeContextInterop{};
30+
ze_context_desc_t ZeContextDesc =
31+
{ZE_STRUCTURE_TYPE_CONTEXT_DESC, nullptr, 0};
32+
zeContextCreate(ZePlatform, &ZeContextDesc, &ZeContextInterop);
33+
2734
// Re-create SYCL objects from native Level Zero handles
2835
auto PlatformInterop = level_zero::make<platform>(ZePlatform);
2936
auto DeviceInterop = level_zero::make<device>(PlatformInterop, ZeDevice);
3037
auto ContextInterop =
31-
level_zero::make<context>(PlatformInterop.get_devices(), ZeContext);
38+
level_zero::make<context>(PlatformInterop.get_devices(), ZeContextInterop);
3239
auto QueueInterop = level_zero::make<queue>(ContextInterop, ZeQueue);
3340

3441
// Check native handles
3542
assert(ZePlatform == PlatformInterop.get_native<backend::level_zero>());
3643
assert(ZeDevice == DeviceInterop.get_native<backend::level_zero>());
37-
assert(ZeContext == ContextInterop.get_native<backend::level_zero>());
44+
assert(ZeContextInterop == ContextInterop.get_native<backend::level_zero>());
3845
assert(ZeQueue == QueueInterop.get_native<backend::level_zero>());
3946

4047
// Verify re-created objects

0 commit comments

Comments
 (0)