diff --git a/unified-runtime/source/adapters/offload/device.cpp b/unified-runtime/source/adapters/offload/device.cpp index c9bb6df9224a0..01624a4e60b27 100644 --- a/unified-runtime/source/adapters/offload/device.cpp +++ b/unified-runtime/source/adapters/offload/device.cpp @@ -200,9 +200,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, return ReturnValue(uint32_t{0}); case UR_DEVICE_INFO_QUEUE_PROPERTIES: case UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES: - case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES: return ReturnValue( ur_queue_flags_t{UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE}); + case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES: + return ReturnValue(0); case UR_DEVICE_INFO_KERNEL_LAUNCH_CAPABILITIES: return ReturnValue(0); case UR_DEVICE_INFO_SUPPORTED_PARTITIONS: { diff --git a/unified-runtime/source/adapters/offload/queue.cpp b/unified-runtime/source/adapters/offload/queue.cpp index 26a5d34e2ed0c..2420f6f81c4b9 100644 --- a/unified-runtime/source/adapters/offload/queue.cpp +++ b/unified-runtime/source/adapters/offload/queue.cpp @@ -55,12 +55,26 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueGetInfo(ur_queue_handle_t hQueue, UrReturnHelper ReturnValue(propSize, pPropValue, pPropSizeRet); switch (propName) { + case UR_QUEUE_INFO_CONTEXT: + return ReturnValue(hQueue->UrContext); + case UR_QUEUE_INFO_DEVICE: + return ReturnValue(hQueue->UrContext->Device); + case UR_QUEUE_INFO_EMPTY: { + bool Empty; + OL_RETURN_ON_ERR(hQueue->isEmpty(Empty)); + return ReturnValue(Empty); + } case UR_QUEUE_INFO_FLAGS: return ReturnValue(hQueue->Flags); case UR_QUEUE_INFO_REFERENCE_COUNT: return ReturnValue(hQueue->RefCount.load()); - default: + // These two are not technically optional, but other backends return + // UNSUPPORTED + case UR_QUEUE_INFO_SIZE: + case UR_QUEUE_INFO_DEVICE_DEFAULT: return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; + default: + return UR_RESULT_ERROR_INVALID_ENUMERATION; } return UR_RESULT_SUCCESS; diff --git a/unified-runtime/source/adapters/offload/queue.hpp b/unified-runtime/source/adapters/offload/queue.hpp index a7106b2411939..8561812187e8f 100644 --- a/unified-runtime/source/adapters/offload/queue.hpp +++ b/unified-runtime/source/adapters/offload/queue.hpp @@ -46,6 +46,26 @@ struct ur_queue_handle_t_ : RefCounted { bool isInOrder() const { return OffloadQueues.size() == 1; } + // This queue is empty if and only if all queues are empty + ol_result_t isEmpty(bool &Empty) const { + Empty = true; + + for (auto *Q : OffloadQueues) { + if (!Q) { + continue; + } + if (auto Err = + olGetQueueInfo(Q, OL_QUEUE_INFO_EMPTY, sizeof(Empty), &Empty)) { + return Err; + } + if (!Empty) { + return OL_SUCCESS; + } + } + + return OL_SUCCESS; + } + ol_result_t nextQueueNoLock(ol_queue_handle_t &Handle) { auto &Slot = OffloadQueues[(QueueOffset++) % OffloadQueues.size()]; diff --git a/unified-runtime/source/adapters/offload/ur_interface_loader.cpp b/unified-runtime/source/adapters/offload/ur_interface_loader.cpp index d08875d73401c..5224a8df79517 100644 --- a/unified-runtime/source/adapters/offload/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/offload/ur_interface_loader.cpp @@ -237,7 +237,7 @@ urGetUSMProcAddrTable(ur_api_version_t version, ur_usm_dditable_t *pDdiTable) { } pDdiTable->pfnDeviceAlloc = urUSMDeviceAlloc; pDdiTable->pfnFree = urUSMFree; - pDdiTable->pfnGetMemAllocInfo = nullptr; + pDdiTable->pfnGetMemAllocInfo = urUSMGetMemAllocInfo; pDdiTable->pfnHostAlloc = urUSMHostAlloc; pDdiTable->pfnPoolCreate = nullptr; pDdiTable->pfnPoolRetain = nullptr; diff --git a/unified-runtime/source/adapters/offload/usm.cpp b/unified-runtime/source/adapters/offload/usm.cpp index f427689618d69..e457c59896d53 100644 --- a/unified-runtime/source/adapters/offload/usm.cpp +++ b/unified-runtime/source/adapters/offload/usm.cpp @@ -55,3 +55,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMFree(ur_context_handle_t hContext, hContext->AllocTypeMap.erase(pMem); return offloadResultToUR(olMemFree(pMem)); } + +UR_APIEXPORT ur_result_t UR_APICALL urUSMGetMemAllocInfo( + [[maybe_unused]] ur_context_handle_t hContext, + [[maybe_unused]] const void *pMem, + [[maybe_unused]] ur_usm_alloc_info_t propName, + [[maybe_unused]] size_t propSize, [[maybe_unused]] void *pPropValue, + [[maybe_unused]] size_t *pPropSizeRet) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +}