From e8128302262deaaf945a6d8e1598240f7c936d7a Mon Sep 17 00:00:00 2001 From: kweronsx Date: Thu, 23 Jul 2026 09:48:52 +0200 Subject: [PATCH] [UR] Plug conformance device tests back into CI Fixes https://github.com/intel/llvm/issues/22025 --- .../adapters/level_zero/common/device.cpp | 16 ++++---- .../device/urDeviceCreateWithNativeHandle.cpp | 4 -- .../device/urDeviceGetSelected.cpp | 40 ++++++++++++++++--- 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/unified-runtime/source/adapters/level_zero/common/device.cpp b/unified-runtime/source/adapters/level_zero/common/device.cpp index 4adf7d1611535..9da72d8a9133d 100644 --- a/unified-runtime/source/adapters/level_zero/common/device.cpp +++ b/unified-runtime/source/adapters/level_zero/common/device.cpp @@ -1457,18 +1457,17 @@ ur_result_t urDeviceGetInfo( if (FanCount == 0) return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; - if (!ParamValue) { - // If ParamValue is nullptr, then we are only interested in the size of - // the value. - return ReturnValue(int32_t{0}); - } - std::vector ZeFanHandles(FanCount); ZE2UR_CALL(zesDeviceEnumFans, (ZesDevice, &FanCount, ZeFanHandles.data())); int32_t Speed = -1; for (auto Fan : ZeFanHandles) { int32_t CurSpeed; - ZE2UR_CALL(zesFanGetState, (Fan, ZES_FAN_SPEED_UNITS_PERCENT, &CurSpeed)); + auto result = ze2urResult(ZE_CALL_NOCHECK( + zesFanGetState, (Fan, ZES_FAN_SPEED_UNITS_PERCENT, &CurSpeed))); + if (result != UR_RESULT_SUCCESS) + return result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE + ? UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION + : result; Speed = std::max(Speed, CurSpeed); } return ReturnValue(Speed); @@ -1785,7 +1784,8 @@ ur_result_t urDeviceCreateWithNativeHandle( ur_device_handle_t Dev = nullptr; for (const auto &p : common_cast(AdapterOpque)->Platforms) { - Dev = p->getDeviceFromNativeHandle(ZeDevice); + if (auto devHandle = p->getDeviceFromNativeHandle(ZeDevice); devHandle) + Dev = devHandle; } if (Dev == nullptr) diff --git a/unified-runtime/test/conformance/device/urDeviceCreateWithNativeHandle.cpp b/unified-runtime/test/conformance/device/urDeviceCreateWithNativeHandle.cpp index 06bd5f085841e..61846c8fb8822 100644 --- a/unified-runtime/test/conformance/device/urDeviceCreateWithNativeHandle.cpp +++ b/unified-runtime/test/conformance/device/urDeviceCreateWithNativeHandle.cpp @@ -9,8 +9,6 @@ using urDeviceCreateWithNativeHandleTest = uur::urDeviceTest; UUR_INSTANTIATE_DEVICE_TEST_SUITE(urDeviceCreateWithNativeHandleTest); TEST_P(urDeviceCreateWithNativeHandleTest, Success) { - // Related issue: #22025 - UUR_KNOWN_FAILURE_ON(uur::LevelZeroV2{}); ur_native_handle_t native_handle = 0; UUR_ASSERT_SUCCESS_OR_UNSUPPORTED( @@ -35,8 +33,6 @@ TEST_P(urDeviceCreateWithNativeHandleTest, Success) { TEST_P(urDeviceCreateWithNativeHandleTest, SuccessWithExplicitUnOwnedNativeHandle) { - // Related issue: #22025 - UUR_KNOWN_FAILURE_ON(uur::LevelZeroV2{}); ur_native_handle_t native_handle = 0; UUR_ASSERT_SUCCESS_OR_UNSUPPORTED( urDeviceGetNativeHandle(device, &native_handle)); diff --git a/unified-runtime/test/conformance/device/urDeviceGetSelected.cpp b/unified-runtime/test/conformance/device/urDeviceGetSelected.cpp index f0d617b41d2dd..73c4c3313713c 100644 --- a/unified-runtime/test/conformance/device/urDeviceGetSelected.cpp +++ b/unified-runtime/test/conformance/device/urDeviceGetSelected.cpp @@ -5,6 +5,8 @@ #include +#include + #ifdef _MSC_VER #include #endif @@ -40,6 +42,32 @@ struct urDeviceGetSelectedTest : uur::urPlatformTest { GTEST_SKIP() << "Platform has no devices"; } } + + // Computes device offset for a given platform, since the first device + // of platform 2 may not be 0. + uint32_t getDeviceIndexOffset() { + ur_adapter_handle_t adapter = nullptr; + EXPECT_SUCCESS(urPlatformGetInfo(platform, UR_PLATFORM_INFO_ADAPTER, + sizeof(adapter), &adapter, nullptr)); + + uint32_t numPlatforms = 0; + EXPECT_SUCCESS(urPlatformGet(adapter, 0, nullptr, &numPlatforms)); + std::vector platforms(numPlatforms); + EXPECT_SUCCESS( + urPlatformGet(adapter, numPlatforms, platforms.data(), nullptr)); + + uint32_t offset = 0; + for (auto p : platforms) { + if (p == platform) { + break; + } + uint32_t deviceCount = 0; + EXPECT_SUCCESS( + urDeviceGet(p, UR_DEVICE_TYPE_ALL, 0, nullptr, &deviceCount)); + offset += deviceCount; + } + return offset; + } }; UUR_INSTANTIATE_PLATFORM_TEST_SUITE(urDeviceGetSelectedTest); @@ -108,9 +136,8 @@ TEST_P(urDeviceGetSelectedTest, SuccessSelected_StarColonStar) { } TEST_P(urDeviceGetSelectedTest, SuccessSelected_StarColonZero) { - // Related issue: #22025 - UUR_KNOWN_FAILURE_ON(uur::LevelZeroV2{}); - uur::set_env("ONEAPI_DEVICE_SELECTOR", "*:0"); + const std::string selector = "*:" + std::to_string(getDeviceIndexOffset()); + uur::set_env("ONEAPI_DEVICE_SELECTOR", selector.c_str()); uint32_t count = 0; ASSERT_SUCCESS( urDeviceGetSelected(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count)); @@ -155,9 +182,10 @@ TEST_P(urDeviceGetSelectedTest, SuccessSelected_SelectAndDiscard) { TEST_P(urDeviceGetSelectedTest, SuccessSelected_SelectSomethingAndDiscardSomethingElse) { - // Related issue: #22025 - UUR_KNOWN_FAILURE_ON(uur::LevelZeroV2{}); - uur::set_env("ONEAPI_DEVICE_SELECTOR", "*:0;!*:1"); + const uint32_t offset = getDeviceIndexOffset(); + const std::string selector = + "*:" + std::to_string(offset) + ";!*:" + std::to_string(offset + 1); + uur::set_env("ONEAPI_DEVICE_SELECTOR", selector.c_str()); uint32_t count = 0; ASSERT_SUCCESS( urDeviceGetSelected(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));