Skip to content

Commit d058a13

Browse files
authored
[UR][Offload] Make all queue UR CTS tests pass (intel#19918)
With this change, the CTS tests for queues are now all passing. This patch introduces the following changes: * All `UR_DEVICE_INFO_QUEUE` values are handled. * `UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES` now is 0 to match the UR HIP/Nvidia backends. * A stub function for `urUSMGetMemAllocInfo` is implemented. This is required because now `UR_DEVICE_INFO_QUEUE_CONTEXT` is implemented, the validation layer will try to call it.
1 parent f25a248 commit d058a13

File tree

5 files changed

+47
-3
lines changed

5 files changed

+47
-3
lines changed

unified-runtime/source/adapters/offload/device.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
200200
return ReturnValue(uint32_t{0});
201201
case UR_DEVICE_INFO_QUEUE_PROPERTIES:
202202
case UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES:
203-
case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES:
204203
return ReturnValue(
205204
ur_queue_flags_t{UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE});
205+
case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES:
206+
return ReturnValue(0);
206207
case UR_DEVICE_INFO_KERNEL_LAUNCH_CAPABILITIES:
207208
return ReturnValue(0);
208209
case UR_DEVICE_INFO_SUPPORTED_PARTITIONS: {

unified-runtime/source/adapters/offload/queue.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,26 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueGetInfo(ur_queue_handle_t hQueue,
5555
UrReturnHelper ReturnValue(propSize, pPropValue, pPropSizeRet);
5656

5757
switch (propName) {
58+
case UR_QUEUE_INFO_CONTEXT:
59+
return ReturnValue(hQueue->UrContext);
60+
case UR_QUEUE_INFO_DEVICE:
61+
return ReturnValue(hQueue->UrContext->Device);
62+
case UR_QUEUE_INFO_EMPTY: {
63+
bool Empty;
64+
OL_RETURN_ON_ERR(hQueue->isEmpty(Empty));
65+
return ReturnValue(Empty);
66+
}
5867
case UR_QUEUE_INFO_FLAGS:
5968
return ReturnValue(hQueue->Flags);
6069
case UR_QUEUE_INFO_REFERENCE_COUNT:
6170
return ReturnValue(hQueue->RefCount.load());
62-
default:
71+
// These two are not technically optional, but other backends return
72+
// UNSUPPORTED
73+
case UR_QUEUE_INFO_SIZE:
74+
case UR_QUEUE_INFO_DEVICE_DEFAULT:
6375
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
76+
default:
77+
return UR_RESULT_ERROR_INVALID_ENUMERATION;
6478
}
6579

6680
return UR_RESULT_SUCCESS;

unified-runtime/source/adapters/offload/queue.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,26 @@ struct ur_queue_handle_t_ : RefCounted {
4646

4747
bool isInOrder() const { return OffloadQueues.size() == 1; }
4848

49+
// This queue is empty if and only if all queues are empty
50+
ol_result_t isEmpty(bool &Empty) const {
51+
Empty = true;
52+
53+
for (auto *Q : OffloadQueues) {
54+
if (!Q) {
55+
continue;
56+
}
57+
if (auto Err =
58+
olGetQueueInfo(Q, OL_QUEUE_INFO_EMPTY, sizeof(Empty), &Empty)) {
59+
return Err;
60+
}
61+
if (!Empty) {
62+
return OL_SUCCESS;
63+
}
64+
}
65+
66+
return OL_SUCCESS;
67+
}
68+
4969
ol_result_t nextQueueNoLock(ol_queue_handle_t &Handle) {
5070
auto &Slot = OffloadQueues[(QueueOffset++) % OffloadQueues.size()];
5171

unified-runtime/source/adapters/offload/ur_interface_loader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ urGetUSMProcAddrTable(ur_api_version_t version, ur_usm_dditable_t *pDdiTable) {
237237
}
238238
pDdiTable->pfnDeviceAlloc = urUSMDeviceAlloc;
239239
pDdiTable->pfnFree = urUSMFree;
240-
pDdiTable->pfnGetMemAllocInfo = nullptr;
240+
pDdiTable->pfnGetMemAllocInfo = urUSMGetMemAllocInfo;
241241
pDdiTable->pfnHostAlloc = urUSMHostAlloc;
242242
pDdiTable->pfnPoolCreate = nullptr;
243243
pDdiTable->pfnPoolRetain = nullptr;

unified-runtime/source/adapters/offload/usm.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMFree(ur_context_handle_t hContext,
5555
hContext->AllocTypeMap.erase(pMem);
5656
return offloadResultToUR(olMemFree(pMem));
5757
}
58+
59+
UR_APIEXPORT ur_result_t UR_APICALL urUSMGetMemAllocInfo(
60+
[[maybe_unused]] ur_context_handle_t hContext,
61+
[[maybe_unused]] const void *pMem,
62+
[[maybe_unused]] ur_usm_alloc_info_t propName,
63+
[[maybe_unused]] size_t propSize, [[maybe_unused]] void *pPropValue,
64+
[[maybe_unused]] size_t *pPropSizeRet) {
65+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
66+
}

0 commit comments

Comments
 (0)