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
16 changes: 8 additions & 8 deletions unified-runtime/source/adapters/level_zero/common/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1457,18 +1457,17 @@ ur_result_t urDeviceGetInfo(
if (FanCount == 0)
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;

if (!ParamValue) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Early exit in the test when ParamValue == nullptr hid that the query is not supported.

// If ParamValue is nullptr, then we are only interested in the size of
// the value.
return ReturnValue(int32_t{0});
}

std::vector<zes_fan_handle_t> 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(

@kweronsx kweronsx Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also remapping the return value as the macro (ASSERT_SUCCESS_OR_OPTIONAL_QUERY) checks against UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION.

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);
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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));
Expand Down
40 changes: 34 additions & 6 deletions unified-runtime/test/conformance/device/urDeviceGetSelected.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include <uur/fixtures.h>

#include <string>

#ifdef _MSC_VER
#include <Windows.h>
#endif
Expand Down Expand Up @@ -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<ur_platform_handle_t> 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);

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down
Loading