From 8e4d0e123fbe9f67c13ad0f14a6d72aa4defdeb6 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Fri, 8 Mar 2024 09:49:26 +0000 Subject: [PATCH 1/3] Revert "Merge pull request #1392 from pbalcer/event-cache-different-fix" This reverts commit eda62c4735353de0b3c4ec2edf36db30b715852a. --- source/adapters/level_zero/context.cpp | 14 +++-- source/adapters/level_zero/context.hpp | 78 +++++++++++++++++--------- source/adapters/level_zero/queue.cpp | 43 ++++++++++---- source/adapters/level_zero/queue.hpp | 5 +- 4 files changed, 94 insertions(+), 46 deletions(-) diff --git a/source/adapters/level_zero/context.cpp b/source/adapters/level_zero/context.cpp index f36442b491..130d0aba28 100644 --- a/source/adapters/level_zero/context.cpp +++ b/source/adapters/level_zero/context.cpp @@ -398,27 +398,29 @@ ur_result_t ur_context_handle_t_::finalize() { if (!DisableEventsCaching) { std::scoped_lock Lock(EventCacheMutex); - for (auto &EventCache : EventCaches) { - for (auto &Event : EventCache) { + for (auto EventCache : EventCaches) { + for (auto Event : *EventCache) { auto ZeResult = ZE_CALL_NOCHECK(zeEventDestroy, (Event->ZeEvent)); // Gracefully handle the case that L0 was already unloaded. if (ZeResult && ZeResult != ZE_RESULT_ERROR_UNINITIALIZED) return ze2urResult(ZeResult); delete Event; } - EventCache.clear(); + EventCache->clear(); + delete EventCache; } } { std::scoped_lock Lock(ZeEventPoolCacheMutex); - for (auto &ZePoolCache : ZeEventPoolCache) { - for (auto &ZePool : ZePoolCache) { + for (auto ZePoolCache : ZeEventPoolCache) { + for (auto ZePool : *ZePoolCache) { auto ZeResult = ZE_CALL_NOCHECK(zeEventPoolDestroy, (ZePool)); // Gracefully handle the case that L0 was already unloaded. if (ZeResult && ZeResult != ZE_RESULT_ERROR_UNINITIALIZED) return ze2urResult(ZeResult); } - ZePoolCache.clear(); + ZePoolCache->clear(); + delete ZePoolCache; } } diff --git a/source/adapters/level_zero/context.hpp b/source/adapters/level_zero/context.hpp index 8cb1d5369f..09605c0643 100644 --- a/source/adapters/level_zero/context.hpp +++ b/source/adapters/level_zero/context.hpp @@ -141,8 +141,9 @@ struct ur_context_handle_t_ : _ur_object { // head. // // Cache of event pools to which host-visible events are added to. - std::vector> ZeEventPoolCache{4}; - std::vector> + std::vector *> ZeEventPoolCache; + std::vector *>> ZeEventPoolCacheDeviceMap{4}; // This map will be used to determine if a pool is full or not @@ -164,9 +165,9 @@ struct ur_context_handle_t_ : _ur_object { ur_mutex EventCacheMutex; // Caches for events. - using EventCache = std::vector>; - EventCache EventCaches{4}; - std::vector> + std::vector *> EventCaches; + std::vector< + std::unordered_map *>> EventCachesDeviceMap{4}; // Initialize the PI context. @@ -204,22 +205,31 @@ struct ur_context_handle_t_ : _ur_object { // Add ur_event_handle_t to cache. void addEventToContextCache(ur_event_handle_t); - std::list * - getZeEventPoolCache(bool HostVisible, bool WithProfiling, - ze_device_handle_t ZeDevice) { + auto getZeEventPoolCache(bool HostVisible, bool WithProfiling, + ze_device_handle_t ZeDevice) { + // Adding 4 initial global caches for provided scope and profiling modes: + // Host Scope, Device Scope, with Profiling, without Profiling. + if (ZeEventPoolCache.empty()) { + for (int i = 0; i < 4; i++) { + std::list *deviceZeEventPoolCache = + new std::list; + ZeEventPoolCache.push_back(deviceZeEventPoolCache); + } + } if (HostVisible) { if (ZeDevice) { auto ZeEventPoolCacheMap = WithProfiling ? &ZeEventPoolCacheDeviceMap[0] : &ZeEventPoolCacheDeviceMap[1]; if (ZeEventPoolCacheMap->find(ZeDevice) == ZeEventPoolCacheMap->end()) { - ZeEventPoolCache.emplace_back(); - ZeEventPoolCacheMap->insert( - std::make_pair(ZeDevice, ZeEventPoolCache.size() - 1)); + std::list *deviceZeEventPoolCache = + new std::list; + ZeEventPoolCache.push_back(deviceZeEventPoolCache); + (*ZeEventPoolCacheMap)[ZeDevice] = deviceZeEventPoolCache; } - return &ZeEventPoolCache[(*ZeEventPoolCacheMap)[ZeDevice]]; + return (*ZeEventPoolCacheMap)[ZeDevice]; } else { - return WithProfiling ? &ZeEventPoolCache[0] : &ZeEventPoolCache[1]; + return WithProfiling ? ZeEventPoolCache[0] : ZeEventPoolCache[1]; } } else { if (ZeDevice) { @@ -227,13 +237,14 @@ struct ur_context_handle_t_ : _ur_object { ? &ZeEventPoolCacheDeviceMap[2] : &ZeEventPoolCacheDeviceMap[3]; if (ZeEventPoolCacheMap->find(ZeDevice) == ZeEventPoolCacheMap->end()) { - ZeEventPoolCache.emplace_back(); - ZeEventPoolCacheMap->insert( - std::make_pair(ZeDevice, ZeEventPoolCache.size() - 1)); + std::list *deviceZeEventPoolCache = + new std::list; + ZeEventPoolCache.push_back(deviceZeEventPoolCache); + (*ZeEventPoolCacheMap)[ZeDevice] = deviceZeEventPoolCache; } - return &ZeEventPoolCache[(*ZeEventPoolCacheMap)[ZeDevice]]; + return (*ZeEventPoolCacheMap)[ZeDevice]; } else { - return WithProfiling ? &ZeEventPoolCache[2] : &ZeEventPoolCache[3]; + return WithProfiling ? ZeEventPoolCache[2] : ZeEventPoolCache[3]; } } } @@ -276,31 +287,42 @@ struct ur_context_handle_t_ : _ur_object { // Get the cache of events for a provided scope and profiling mode. auto getEventCache(bool HostVisible, bool WithProfiling, ur_device_handle_t Device) { + // Adding 4 initial global caches for provided scope and profiling modes: + // Host Scope, Device Scope, with Profiling, without Profiling. + if (EventCaches.empty()) { + for (int i = 0; i < 4; i++) { + std::list *deviceEventCache = + new std::list; + EventCaches.push_back(deviceEventCache); + } + } if (HostVisible) { if (Device) { auto EventCachesMap = WithProfiling ? &EventCachesDeviceMap[0] : &EventCachesDeviceMap[1]; if (EventCachesMap->find(Device) == EventCachesMap->end()) { - EventCaches.emplace_back(); - EventCachesMap->insert( - std::make_pair(Device, EventCaches.size() - 1)); + std::list *deviceEventCache = + new std::list; + EventCaches.push_back(deviceEventCache); + (*EventCachesMap)[Device] = deviceEventCache; } - return &EventCaches[(*EventCachesMap)[Device]]; + return (*EventCachesMap)[Device]; } else { - return WithProfiling ? &EventCaches[0] : &EventCaches[1]; + return WithProfiling ? EventCaches[0] : EventCaches[1]; } } else { if (Device) { auto EventCachesMap = WithProfiling ? &EventCachesDeviceMap[2] : &EventCachesDeviceMap[3]; if (EventCachesMap->find(Device) == EventCachesMap->end()) { - EventCaches.emplace_back(); - EventCachesMap->insert( - std::make_pair(Device, EventCaches.size() - 1)); + std::list *deviceEventCache = + new std::list; + EventCaches.push_back(deviceEventCache); + (*EventCachesMap)[Device] = deviceEventCache; } - return &EventCaches[(*EventCachesMap)[Device]]; + return (*EventCachesMap)[Device]; } else { - return WithProfiling ? &EventCaches[2] : &EventCaches[3]; + return WithProfiling ? EventCaches[2] : EventCaches[3]; } } } diff --git a/source/adapters/level_zero/queue.cpp b/source/adapters/level_zero/queue.cpp index 164b349781..c83afffa46 100644 --- a/source/adapters/level_zero/queue.cpp +++ b/source/adapters/level_zero/queue.cpp @@ -1261,17 +1261,28 @@ ur_queue_handle_t_::resetDiscardedEvent(ur_command_list_ptr_t CommandList) { } ur_result_t ur_queue_handle_t_::addEventToQueueCache(ur_event_handle_t Event) { + // Adding 2 initial global caches for provided scope: + // Host Scope, Device Scope. + if (EventCaches.empty()) { + for (int i = 0; i < 2; i++) { + std::list *deviceEventCache = + new std::list; + EventCaches.push_back(deviceEventCache); + } + } if (!Event->IsMultiDevice && Event->UrQueue) { auto Device = Event->UrQueue->Device; auto EventCachesMap = Event->isHostVisible() ? &EventCachesDeviceMap[0] : &EventCachesDeviceMap[1]; if (EventCachesMap->find(Device) == EventCachesMap->end()) { - EventCaches.emplace_back(); - EventCachesMap->insert(std::make_pair(Device, EventCaches.size() - 1)); + std::list *deviceEventCache = + new std::list; + EventCaches.push_back(deviceEventCache); + (*EventCachesMap)[Device] = deviceEventCache; } - EventCaches[EventCachesMap->at(Device)].emplace_back(Event); + (*EventCachesMap)[Device]->emplace_back(Event); } else { - auto Cache = Event->isHostVisible() ? &EventCaches[0] : &EventCaches[1]; + auto Cache = Event->isHostVisible() ? EventCaches[0] : EventCaches[1]; Cache->emplace_back(Event); } return UR_RESULT_SUCCESS; @@ -1295,10 +1306,12 @@ ur_result_t urQueueReleaseInternal(ur_queue_handle_t Queue) { if (!UrQueue->RefCount.decrementAndTest()) return UR_RESULT_SUCCESS; - for (auto &Cache : UrQueue->EventCaches) { - for (auto &Event : Cache) + for (auto Cache : UrQueue->EventCaches) { + for (auto Event : *Cache) { UR_CALL(urEventReleaseInternal(Event)); - Cache.clear(); + } + Cache->clear(); + delete Cache; } if (UrQueue->OwnZeCommandQueue) { @@ -1456,15 +1469,25 @@ ur_event_handle_t ur_queue_handle_t_::getEventFromQueueCache(bool IsMultiDevice, bool HostVisible) { std::list *Cache; + // Adding 2 initial global caches for provided scope: + // Host Scope, Device Scope. + if (EventCaches.empty()) { + for (int i = 0; i < 2; i++) { + std::list *deviceEventCache = + new std::list; + EventCaches.push_back(deviceEventCache); + } + } + if (!IsMultiDevice) { auto Device = this->Device; - Cache = HostVisible ? &EventCaches[EventCachesDeviceMap[0][Device]] - : &EventCaches[EventCachesDeviceMap[1][Device]]; + Cache = HostVisible ? EventCachesDeviceMap[0][Device] + : EventCachesDeviceMap[1][Device]; if (!Cache) { return nullptr; } } else { - Cache = HostVisible ? &EventCaches[0] : &EventCaches[1]; + Cache = HostVisible ? EventCaches[0] : EventCaches[1]; } // If we don't have any events, return nullptr. diff --git a/source/adapters/level_zero/queue.hpp b/source/adapters/level_zero/queue.hpp index 06751e03c1..b437a87fd9 100644 --- a/source/adapters/level_zero/queue.hpp +++ b/source/adapters/level_zero/queue.hpp @@ -342,8 +342,9 @@ struct ur_queue_handle_t_ : _ur_object { // requested type of event. Each list contains events which can be reused // inside all command lists in the queue as described in the 2-event model. // Leftover events in the cache are relased at the queue destruction. - std::vector> EventCaches{2}; - std::vector> + std::vector *> EventCaches; + std::vector< + std::unordered_map *>> EventCachesDeviceMap{2}; // adjust the queue's batch size, knowing that the current command list From 668fd78dc27c97b44691ec6be8fd229eadb72a30 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Fri, 8 Mar 2024 09:48:44 +0000 Subject: [PATCH 2/3] Merge pull request #1419 from nrspruit/main_l0_adapter_release_lib [L0] Create/Destroy Adapter Handle during lib init --- source/adapters/level_zero/CMakeLists.txt | 9 ++- source/adapters/level_zero/adapter.cpp | 72 ++++++++++++++----- source/adapters/level_zero/adapter.hpp | 2 +- .../level_zero/adapter_lib_init_linux.cpp | 25 +++++++ source/adapters/level_zero/device.cpp | 4 +- source/adapters/level_zero/platform.cpp | 6 +- source/adapters/level_zero/queue.cpp | 2 +- 7 files changed, 93 insertions(+), 27 deletions(-) create mode 100644 source/adapters/level_zero/adapter_lib_init_linux.cpp diff --git a/source/adapters/level_zero/CMakeLists.txt b/source/adapters/level_zero/CMakeLists.txt index 52fc2f1f56..e4543f52d0 100644 --- a/source/adapters/level_zero/CMakeLists.txt +++ b/source/adapters/level_zero/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2022 Intel Corporation +# Copyright (C) 2022-2024 Intel Corporation # Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception @@ -119,6 +119,13 @@ add_ur_adapter(${TARGET_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.cpp ) +if(NOT WIN32) + target_sources(ur_adapter_level_zero + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/adapter_lib_init_linux.cpp + ) +endif() + # TODO: fix level_zero adapter conversion warnings target_compile_options(${TARGET_NAME} PRIVATE $<$:/wd4805 /wd4244> diff --git a/source/adapters/level_zero/adapter.cpp b/source/adapters/level_zero/adapter.cpp index 1097101035..91f7b66773 100644 --- a/source/adapters/level_zero/adapter.cpp +++ b/source/adapters/level_zero/adapter.cpp @@ -11,6 +11,14 @@ #include "adapter.hpp" #include "ur_level_zero.hpp" +// Due to multiple DLLMain definitions with SYCL, Global Adapter is init at +// variable creation. +#if defined(_WIN32) +ur_adapter_handle_t_ *GlobalAdapter = new ur_adapter_handle_t_(); +#else +ur_adapter_handle_t_ *GlobalAdapter; +#endif + UR_APIEXPORT ur_result_t UR_APICALL urInit(ur_device_init_flags_t DeviceFlags, ///< [in] device initialization flags. @@ -48,8 +56,7 @@ ur_result_t initPlatforms(PlatformVec &platforms) noexcept try { ur_result_t adapterStateInit() { return UR_RESULT_SUCCESS; } ur_adapter_handle_t_::ur_adapter_handle_t_() { - - Adapter.PlatformCache.Compute = [](Result &result) { + PlatformCache.Compute = [](Result &result) { static std::once_flag ZeCallCountInitialized; try { std::call_once(ZeCallCountInitialized, []() { @@ -63,7 +70,7 @@ ur_adapter_handle_t_::ur_adapter_handle_t_() { } // initialize level zero only once. - if (Adapter.ZeResult == std::nullopt) { + if (GlobalAdapter->ZeResult == std::nullopt) { // Setting these environment variables before running zeInit will enable // the validation layer in the Level Zero loader. if (UrL0Debug & UR_L0_DEBUG_VALIDATION) { @@ -82,20 +89,21 @@ ur_adapter_handle_t_::ur_adapter_handle_t_() { // We must only initialize the driver once, even if urPlatformGet() is // called multiple times. Declaring the return value as "static" ensures // it's only called once. - Adapter.ZeResult = ZE_CALL_NOCHECK(zeInit, (ZE_INIT_FLAG_GPU_ONLY)); + GlobalAdapter->ZeResult = + ZE_CALL_NOCHECK(zeInit, (ZE_INIT_FLAG_GPU_ONLY)); } - assert(Adapter.ZeResult != + assert(GlobalAdapter->ZeResult != std::nullopt); // verify that level-zero is initialized PlatformVec platforms; // Absorb the ZE_RESULT_ERROR_UNINITIALIZED and just return 0 Platforms. - if (*Adapter.ZeResult == ZE_RESULT_ERROR_UNINITIALIZED) { + if (*GlobalAdapter->ZeResult == ZE_RESULT_ERROR_UNINITIALIZED) { result = std::move(platforms); return; } - if (*Adapter.ZeResult != ZE_RESULT_SUCCESS) { + if (*GlobalAdapter->ZeResult != ZE_RESULT_SUCCESS) { urPrint("zeInit: Level Zero initialization failure\n"); - result = ze2urResult(*Adapter.ZeResult); + result = ze2urResult(*GlobalAdapter->ZeResult); return; } @@ -108,7 +116,11 @@ ur_adapter_handle_t_::ur_adapter_handle_t_() { }; } -ur_adapter_handle_t_ Adapter{}; +void globalAdapterOnDemandCleanup() { + if (GlobalAdapter) { + delete GlobalAdapter; + } +} ur_result_t adapterStateTeardown() { bool LeakFound = false; @@ -195,6 +207,11 @@ ur_result_t adapterStateTeardown() { } if (LeakFound) return UR_RESULT_ERROR_INVALID_MEM_OBJECT; + // Due to multiple DLLMain definitions with SYCL, register to cleanup the + // Global Adapter after refcnt is 0 +#if defined(_WIN32) + std::atexit(globalAdapterOnDemandCleanup); +#endif return UR_RESULT_SUCCESS; } @@ -221,11 +238,23 @@ UR_APIEXPORT ur_result_t UR_APICALL urAdapterGet( ///< adapters available. ) { if (NumEntries > 0 && Adapters) { - std::lock_guard Lock{Adapter.Mutex}; - if (Adapter.RefCount++ == 0) { - adapterStateInit(); + if (GlobalAdapter) { + std::lock_guard Lock{GlobalAdapter->Mutex}; + if (GlobalAdapter->RefCount++ == 0) { + adapterStateInit(); + } + } else { + // If the GetAdapter is called after the Library began or was torndown, + // then temporarily create a new Adapter handle and register a new + // cleanup. + GlobalAdapter = new ur_adapter_handle_t_(); + std::lock_guard Lock{GlobalAdapter->Mutex}; + if (GlobalAdapter->RefCount++ == 0) { + adapterStateInit(); + } + std::atexit(globalAdapterOnDemandCleanup); } - *Adapters = &Adapter; + *Adapters = GlobalAdapter; } if (NumAdapters) { @@ -236,17 +265,22 @@ UR_APIEXPORT ur_result_t UR_APICALL urAdapterGet( } UR_APIEXPORT ur_result_t UR_APICALL urAdapterRelease(ur_adapter_handle_t) { - std::lock_guard Lock{Adapter.Mutex}; - if (--Adapter.RefCount == 0) { - return adapterStateTeardown(); + // Check first if the Adapter pointer is valid + if (GlobalAdapter) { + std::lock_guard Lock{GlobalAdapter->Mutex}; + if (--GlobalAdapter->RefCount == 0) { + return adapterStateTeardown(); + } } return UR_RESULT_SUCCESS; } UR_APIEXPORT ur_result_t UR_APICALL urAdapterRetain(ur_adapter_handle_t) { - std::lock_guard Lock{Adapter.Mutex}; - Adapter.RefCount++; + if (GlobalAdapter) { + std::lock_guard Lock{GlobalAdapter->Mutex}; + GlobalAdapter->RefCount++; + } return UR_RESULT_SUCCESS; } @@ -275,7 +309,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetInfo(ur_adapter_handle_t, case UR_ADAPTER_INFO_BACKEND: return ReturnValue(UR_ADAPTER_BACKEND_LEVEL_ZERO); case UR_ADAPTER_INFO_REFERENCE_COUNT: - return ReturnValue(Adapter.RefCount.load()); + return ReturnValue(GlobalAdapter->RefCount.load()); default: return UR_RESULT_ERROR_INVALID_ENUMERATION; } diff --git a/source/adapters/level_zero/adapter.hpp b/source/adapters/level_zero/adapter.hpp index 0942db852a..1fdf3a9294 100644 --- a/source/adapters/level_zero/adapter.hpp +++ b/source/adapters/level_zero/adapter.hpp @@ -25,4 +25,4 @@ struct ur_adapter_handle_t_ { ZeCache> PlatformCache; }; -extern ur_adapter_handle_t_ Adapter; +extern ur_adapter_handle_t_ *GlobalAdapter; diff --git a/source/adapters/level_zero/adapter_lib_init_linux.cpp b/source/adapters/level_zero/adapter_lib_init_linux.cpp new file mode 100644 index 0000000000..bb6f1d4e6d --- /dev/null +++ b/source/adapters/level_zero/adapter_lib_init_linux.cpp @@ -0,0 +1,25 @@ +//===--------- adapter_lib_init_linux.cpp - Level Zero Adapter ------------===// +// +// Copyright (C) 2023 Intel Corporation +// +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM +// Exceptions. See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "adapter.hpp" +#include "ur_level_zero.hpp" + +void __attribute__((constructor)) createAdapterHandle() { + if (!GlobalAdapter) { + GlobalAdapter = new ur_adapter_handle_t_(); + } +} + +void __attribute__((destructor)) deleteAdapterHandle() { + if (GlobalAdapter) { + delete GlobalAdapter; + GlobalAdapter = nullptr; + } +} diff --git a/source/adapters/level_zero/device.cpp b/source/adapters/level_zero/device.cpp index 7633c723f9..89599fdfe3 100644 --- a/source/adapters/level_zero/device.cpp +++ b/source/adapters/level_zero/device.cpp @@ -1321,7 +1321,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( // a valid Level Zero device. ur_device_handle_t Dev = nullptr; - if (const auto *platforms = Adapter.PlatformCache->get_value()) { + if (const auto *platforms = GlobalAdapter->PlatformCache->get_value()) { for (const auto &p : *platforms) { Dev = p->getDeviceFromNativeHandle(ZeDevice); if (Dev) { @@ -1332,7 +1332,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( } } } else { - return Adapter.PlatformCache->get_error(); + return GlobalAdapter->PlatformCache->get_error(); } if (Dev == nullptr) diff --git a/source/adapters/level_zero/platform.cpp b/source/adapters/level_zero/platform.cpp index 1b70f56910..ffe3d2a852 100644 --- a/source/adapters/level_zero/platform.cpp +++ b/source/adapters/level_zero/platform.cpp @@ -29,7 +29,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urPlatformGet( ) { // Platform handles are cached for reuse. This is to ensure consistent // handle pointers across invocations and to improve retrieval performance. - if (const auto *cached_platforms = Adapter.PlatformCache->get_value(); + if (const auto *cached_platforms = GlobalAdapter->PlatformCache->get_value(); cached_platforms) { uint32_t nplatforms = (uint32_t)cached_platforms->size(); if (NumPlatforms) { @@ -41,7 +41,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urPlatformGet( } } } else { - return Adapter.PlatformCache->get_error(); + return GlobalAdapter->PlatformCache->get_error(); } return UR_RESULT_SUCCESS; @@ -133,7 +133,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urPlatformCreateWithNativeHandle( auto ZeDriver = ur_cast(NativePlatform); uint32_t NumPlatforms = 0; - ur_adapter_handle_t AdapterHandle = &Adapter; + ur_adapter_handle_t AdapterHandle = GlobalAdapter; UR_CALL(urPlatformGet(&AdapterHandle, 1, 0, nullptr, &NumPlatforms)); if (NumPlatforms) { diff --git a/source/adapters/level_zero/queue.cpp b/source/adapters/level_zero/queue.cpp index c83afffa46..103ea55000 100644 --- a/source/adapters/level_zero/queue.cpp +++ b/source/adapters/level_zero/queue.cpp @@ -569,7 +569,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueCreateWithNativeHandle( // Maybe this is not completely correct. uint32_t NumEntries = 1; ur_platform_handle_t Platform{}; - ur_adapter_handle_t AdapterHandle = &Adapter; + ur_adapter_handle_t AdapterHandle = GlobalAdapter; UR_CALL(urPlatformGet(&AdapterHandle, 1, NumEntries, &Platform, nullptr)); ur_device_handle_t UrDevice = Device; From e43a2890c6662f2d6a0eb93031ec4d7b327889cd Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Fri, 8 Mar 2024 09:53:23 +0000 Subject: [PATCH 3/3] Set version to v0.8.13 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 61b2525048..6834191f1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR) -project(unified-runtime VERSION 0.8.12) +project(unified-runtime VERSION 0.8.13) include(GNUInstallDirs) include(CheckCXXSourceCompiles)