Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion unified-runtime/source/adapters/offload/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
16 changes: 15 additions & 1 deletion unified-runtime/source/adapters/offload/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 20 additions & 0 deletions unified-runtime/source/adapters/offload/queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions unified-runtime/source/adapters/offload/usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}