Skip to content

Commit 8ac0aad

Browse files
committed
[UR] Fix LUID/NODE_MASK handling on unsupported platforms
1 parent 3c34434 commit 8ac0aad

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
12301230
// see sycl/doc/extensions/supported/sycl_ext_intel_device_info.md.
12311231
std::array<char, 8> LUID{};
12321232
unsigned int nodeMask = 0;
1233-
UR_CHECK_ERROR(cuDeviceGetLuid(LUID.data(), &nodeMask, hDevice->get()));
1233+
// Must pass both parameters - CUDA returns SUCCESS with zeros on
1234+
// unsupported platforms
1235+
CUresult Result = cuDeviceGetLuid(LUID.data(), &nodeMask, hDevice->get());
1236+
1237+
// CUDA_ERROR_NOT_SUPPORTED means LUID is not available on this platform
1238+
if (Result == CUDA_ERROR_NOT_SUPPORTED) {
1239+
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
1240+
}
1241+
UR_CHECK_ERROR(Result);
12341242

12351243
bool isAllZeros = true;
12361244
for (char num : LUID) {
@@ -1255,7 +1263,16 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
12551263
// see sycl/doc/extensions/supported/sycl_ext_intel_device_info.md.
12561264
std::array<char, 8> LUID{};
12571265
unsigned int nodeMask = 0;
1258-
UR_CHECK_ERROR(cuDeviceGetLuid(LUID.data(), &nodeMask, hDevice->get()));
1266+
// Must pass both parameters - CUDA returns SUCCESS with zeros on
1267+
// unsupported platforms
1268+
CUresult Result = cuDeviceGetLuid(LUID.data(), &nodeMask, hDevice->get());
1269+
1270+
// CUDA_ERROR_NOT_SUPPORTED means node mask is not available on this
1271+
// platform
1272+
if (Result == CUDA_ERROR_NOT_SUPPORTED) {
1273+
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
1274+
}
1275+
UR_CHECK_ERROR(Result);
12591276

12601277
// If nodeMask is zero, the feature is not supported on this platform
12611278
if (nodeMask == 0) {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
477477
case UR_DEVICE_INFO_GRAPH_RECORD_AND_REPLAY_SUPPORT_EXP:
478478
return ReturnValue(false);
479479

480+
// LUID and NODE_MASK are Windows/D3D12 specific - not applicable on Native
481+
// CPU
482+
case UR_DEVICE_INFO_LUID:
483+
case UR_DEVICE_INFO_NODE_MASK:
484+
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
485+
480486
default:
481487
DIE_NO_IMPLEMENTATION;
482488
}

0 commit comments

Comments
 (0)