diff --git a/SYCL/Plugin/interop-level-zero.cpp b/SYCL/Plugin/interop-level-zero.cpp index dbad7c95ca..e37327a81c 100644 --- a/SYCL/Plugin/interop-level-zero.cpp +++ b/SYCL/Plugin/interop-level-zero.cpp @@ -7,22 +7,26 @@ #include // clang-format off #include -#include +#include // clang-format on using namespace cl::sycl; int main() { +#ifdef SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO queue Queue{}; + + auto Event = Queue.single_task([=]() {}); auto Context = Queue.get_info(); auto Device = Queue.get_info(); auto Platform = Device.get_info(); // Get native Level Zero handles - auto ZePlatform = Platform.get_native(); - auto ZeDevice = Device.get_native(); - auto ZeContext = Context.get_native(); - auto ZeQueue = Queue.get_native(); + auto ZePlatform = get_native(Platform); + auto ZeDevice = get_native(Device); + auto ZeContext = get_native(Context); + auto ZeQueue = get_native(Queue); + auto ZeEvent = get_native(Event); // Create native Level-Zero context. // It then will be owned/destroyed by SYCL RT. @@ -32,17 +36,33 @@ int main() { zeContextCreate(ZePlatform, &ZeContextDesc, &ZeContextInterop); // Re-create SYCL objects from native Level Zero handles - auto PlatformInterop = level_zero::make(ZePlatform); - auto DeviceInterop = level_zero::make(PlatformInterop, ZeDevice); - auto ContextInterop = level_zero::make(PlatformInterop.get_devices(), - ZeContextInterop); - auto QueueInterop = level_zero::make(ContextInterop, ZeQueue); + auto PlatformInterop = + make_platform(ZePlatform); + auto DeviceInterop = make_device(ZeDevice); + + backend_input_t ContextInteropInput = + {ZeContextInterop, Context.get_devices()}; + auto ContextInterop = + make_context(ContextInteropInput); + + backend_input_t QueueInteropInput = { + ZeQueue}; + auto QueueInterop = make_queue( + QueueInteropInput, ContextInterop); + + backend_input_t EventInteropInput = { + ZeEvent}; + auto EventInterop = make_event( + EventInteropInput, ContextInterop); // Check native handles - assert(ZePlatform == PlatformInterop.get_native()); - assert(ZeDevice == DeviceInterop.get_native()); - assert(ZeContextInterop == ContextInterop.get_native()); - assert(ZeQueue == QueueInterop.get_native()); + assert(ZePlatform == + get_native(PlatformInterop)); + assert(ZeDevice == get_native(DeviceInterop)); + assert(ZeContextInterop == + get_native(ContextInterop)); + assert(ZeQueue == get_native(QueueInterop)); + assert(ZeEvent == get_native(EventInterop)); // Verify re-created objects int Arr[] = {2}; @@ -54,6 +74,9 @@ int main() { }); } assert(Arr[0] == 6); - +#else + std::cout << "Test skipped due to missing support for Level-Zero backend." + << std::endl; +#endif return 0; }