Skip to content

Commit 15d2953

Browse files
committed
Manually check error code from zeDeviceGetRootDevice calls.
1 parent bc711f4 commit 15d2953

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

source/adapters/level_zero/device.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,16 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGet(
8888
if (!isCombinedMode) {
8989
ze_device_handle_t RootDev = nullptr;
9090
// Query Root Device
91-
ZE2UR_CALL(zeDeviceGetRootDevice, (D->ZeDevice, &RootDev));
91+
// We cannot use ZE2UR_CALL because under some circumstances this call may
92+
// return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, and ZE2UR_CALL will abort
93+
// because it's not UR_RESULT_SUCCESS. Instead, we use ZE_CALL_NOCHECK and
94+
// we check manually that the result is either ZE_RESULT_SUCCESS or
95+
// ZE_RESULT_ERROR_UNSUPPORTED_FEATURE.
96+
auto errc =
97+
ZE_CALL_NOCHECK(zeDeviceGetRootDevice, (D->ZeDevice, &RootDev));
98+
if (errc != ZE_RESULT_SUCCESS &&
99+
errc != ZE_RESULT_ERROR_UNSUPPORTED_FEATURE)
100+
return ze2urResult(errc);
92101
// For COMPOSITE and FLAT modes, RootDev will always be nullptr. Thus a
93102
// single device returning RootDev != nullptr means we are in COMBINED
94103
// mode.

source/adapters/level_zero/platform.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,18 @@ ur_result_t ur_platform_handle_t_::populateDeviceCacheIfNeeded() {
423423
// through zeDeviceGetRootDevice. We need to cache the card device
424424
// handle too, such that it is readily visible to the
425425
// urDeviceCreateWithNativeHandle.
426-
ze_device_handle_t RootDevice;
427-
ZE2UR_CALL(zeDeviceGetRootDevice, (Device->ZeDevice, &RootDevice));
426+
ze_device_handle_t RootDevice = nullptr;
427+
// We cannot use ZE2UR_CALL because under some circumstances this call may
428+
// return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, and ZE2UR_CALL will abort
429+
// because it's not UR_RESULT_SUCCESS. Instead, we use ZE_CALL_NOCHECK and
430+
// we check manually that the result is either ZE_RESULT_SUCCESS or
431+
// ZE_RESULT_ERROR_UNSUPPORTED_FEATURE.
432+
auto errc = ZE_CALL_NOCHECK(zeDeviceGetRootDevice,
433+
(Device->ZeDevice, &RootDevice));
434+
if (errc != ZE_RESULT_SUCCESS &&
435+
errc != ZE_RESULT_ERROR_UNSUPPORTED_FEATURE)
436+
return ze2urResult(errc);
437+
428438
if (RootDevice) {
429439
if (std::find_if(URDevicesCache.begin(), URDevicesCache.end(),
430440
[&](auto &Dev) {

0 commit comments

Comments
 (0)