77#include < CL/sycl.hpp>
88// clang-format off
99#include < level_zero/ze_api.h>
10- #include < CL/ sycl/backend/level_zero.hpp>
10+ #include < sycl/ext/oneapi /backend/level_zero.hpp>
1111// clang-format on
1212
1313using namespace cl ::sycl;
1414
1515int main () {
16+ #ifdef SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO
1617 queue Queue{};
18+
19+ auto Event = Queue.single_task ([=]() {});
1720 auto Context = Queue.get_info <info::queue::context>();
1821 auto Device = Queue.get_info <info::queue::device>();
1922 auto Platform = Device.get_info <info::device::platform>();
2023
2124 // Get native Level Zero handles
22- auto ZePlatform = Platform.get_native <backend::level_zero>();
23- auto ZeDevice = Device.get_native <backend::level_zero>();
24- auto ZeContext = Context.get_native <backend::level_zero>();
25- auto ZeQueue = Queue.get_native <backend::level_zero>();
25+ auto ZePlatform = get_native<backend::ext_oneapi_level_zero>(Platform);
26+ auto ZeDevice = get_native<backend::ext_oneapi_level_zero>(Device);
27+ auto ZeContext = get_native<backend::ext_oneapi_level_zero>(Context);
28+ auto ZeQueue = get_native<backend::ext_oneapi_level_zero>(Queue);
29+ auto ZeEvent = get_native<backend::ext_oneapi_level_zero>(Event);
2630
2731 // Create native Level-Zero context.
2832 // It then will be owned/destroyed by SYCL RT.
@@ -32,17 +36,33 @@ int main() {
3236 zeContextCreate (ZePlatform, &ZeContextDesc, &ZeContextInterop);
3337
3438 // Re-create SYCL objects from native Level Zero handles
35- auto PlatformInterop = level_zero::make<platform>(ZePlatform);
36- auto DeviceInterop = level_zero::make<device>(PlatformInterop, ZeDevice);
37- auto ContextInterop = level_zero::make<context>(PlatformInterop.get_devices (),
38- ZeContextInterop);
39- auto QueueInterop = level_zero::make<queue>(ContextInterop, ZeQueue);
39+ auto PlatformInterop =
40+ make_platform<backend::ext_oneapi_level_zero>(ZePlatform);
41+ auto DeviceInterop = make_device<backend::ext_oneapi_level_zero>(ZeDevice);
42+
43+ backend_input_t <backend::ext_oneapi_level_zero, context> ContextInteropInput =
44+ {ZeContextInterop, Context.get_devices ()};
45+ auto ContextInterop =
46+ make_context<backend::ext_oneapi_level_zero>(ContextInteropInput);
47+
48+ backend_input_t <backend::ext_oneapi_level_zero, queue> QueueInteropInput = {
49+ ZeQueue};
50+ auto QueueInterop = make_queue<backend::ext_oneapi_level_zero>(
51+ QueueInteropInput, ContextInterop);
52+
53+ backend_input_t <backend::ext_oneapi_level_zero, event> EventInteropInput = {
54+ ZeEvent};
55+ auto EventInterop = make_event<backend::ext_oneapi_level_zero>(
56+ EventInteropInput, ContextInterop);
4057
4158 // Check native handles
42- assert (ZePlatform == PlatformInterop.get_native <backend::level_zero>());
43- assert (ZeDevice == DeviceInterop.get_native <backend::level_zero>());
44- assert (ZeContextInterop == ContextInterop.get_native <backend::level_zero>());
45- assert (ZeQueue == QueueInterop.get_native <backend::level_zero>());
59+ assert (ZePlatform ==
60+ get_native<backend::ext_oneapi_level_zero>(PlatformInterop));
61+ assert (ZeDevice == get_native<backend::ext_oneapi_level_zero>(DeviceInterop));
62+ assert (ZeContextInterop ==
63+ get_native<backend::ext_oneapi_level_zero>(ContextInterop));
64+ assert (ZeQueue == get_native<backend::ext_oneapi_level_zero>(QueueInterop));
65+ assert (ZeEvent == get_native<backend::ext_oneapi_level_zero>(EventInterop));
4666
4767 // Verify re-created objects
4868 int Arr[] = {2 };
@@ -54,6 +74,9 @@ int main() {
5474 });
5575 }
5676 assert (Arr[0 ] == 6 );
57-
77+ #else
78+ std::cout << " Test skipped due to missing support for Level-Zero backend."
79+ << std::endl;
80+ #endif
5881 return 0 ;
5982}
0 commit comments