Skip to content

Commit 33eb5ea

Browse files
authored
Merge pull request #1678 from steffenlarsen/steffen/composite_devices_not_supported_and_empty
Fix return of component and composite device info queries
2 parents a53f89d + 58f6851 commit 33eb5ea

File tree

6 files changed

+19
-12
lines changed

6 files changed

+19
-12
lines changed

source/adapters/cuda/device.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -1073,8 +1073,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
10731073
return ReturnValue(false);
10741074
case UR_DEVICE_INFO_COMPONENT_DEVICES:
10751075
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
1076-
// These two are exclusive of L0.
1077-
return ReturnValue(0);
10781076
case UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS:
10791077
case UR_DEVICE_INFO_GPU_EU_COUNT:
10801078
case UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH:

source/adapters/hip/device.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -879,14 +879,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
879879
return ReturnValue(false);
880880
case UR_DEVICE_INFO_ESIMD_SUPPORT:
881881
return ReturnValue(false);
882-
case UR_DEVICE_INFO_COMPONENT_DEVICES:
883-
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
884-
// These two are exclusive of L0.
885-
return ReturnValue(0);
886882
case UR_DEVICE_INFO_TIMESTAMP_RECORDING_SUPPORT_EXP:
887883
return ReturnValue(true);
888884

889885
// TODO: Investigate if this information is available on HIP.
886+
case UR_DEVICE_INFO_COMPONENT_DEVICES:
887+
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
890888
case UR_DEVICE_INFO_GPU_EU_COUNT:
891889
case UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH:
892890
case UR_DEVICE_INFO_GPU_EU_SLICES:

source/adapters/level_zero/device.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
888888
// First call to get SubDeviceCount.
889889
ZE2UR_CALL(zeDeviceGetSubDevices, (DevHandle, &SubDeviceCount, nullptr));
890890
if (SubDeviceCount == 0)
891-
return ReturnValue(0);
891+
return ReturnValue(std::nullopt);
892892

893893
std::vector<ze_device_handle_t> SubDevs(SubDeviceCount);
894894
// Second call to get the actual list of devices.

source/adapters/native_cpu/device.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
309309
case UR_DEVICE_INFO_COMPONENT_DEVICES:
310310
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
311311
// These two are exclusive of L0.
312-
return ReturnValue(0);
312+
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
313313

314314
CASE_UR_UNSUPPORTED(UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH);
315315
case UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT:

source/adapters/opencl/device.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -975,14 +975,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
975975
return ReturnValue(UUID);
976976
}
977977

978-
case UR_DEVICE_INFO_COMPONENT_DEVICES:
979-
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
980-
// These two are exclusive of L0.
981-
return ReturnValue(0);
982978
/* TODO: Check regularly to see if support is enabled in OpenCL. Intel GPU
983979
* EU device-specific information extensions. Some of the queries are
984980
* enabled by cl_intel_device_attribute_query extension, but it's not yet in
985981
* the Registry. */
982+
case UR_DEVICE_INFO_COMPONENT_DEVICES:
983+
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
986984
case UR_DEVICE_INFO_PCI_ADDRESS:
987985
case UR_DEVICE_INFO_GPU_EU_COUNT:
988986
case UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH:

source/ur/ur.hpp

+13
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <functional>
1717
#include <iostream>
1818
#include <mutex>
19+
#include <optional>
1920
#include <shared_mutex>
2021
#include <string>
2122
#include <thread>
@@ -263,6 +264,12 @@ getInfo<const char *>(size_t param_value_size, void *param_value,
263264
return getInfoArray(strlen(value) + 1, param_value_size, param_value,
264265
param_value_size_ret, value);
265266
}
267+
268+
inline ur_result_t getInfoEmpty(size_t param_value_size, void *param_value,
269+
size_t *param_value_size_ret) {
270+
return getInfoImpl(param_value_size, param_value, param_value_size_ret, 0, 0,
271+
[](void *, int, size_t) {});
272+
}
266273
} // namespace ur
267274

268275
class UrReturnHelper {
@@ -296,6 +303,12 @@ class UrReturnHelper {
296303
param_value_size_ret, t);
297304
}
298305

306+
// Special case when there is no return value
307+
ur_result_t operator()(std::nullopt_t) {
308+
return ur::getInfoEmpty(param_value_size, param_value,
309+
param_value_size_ret);
310+
}
311+
299312
protected:
300313
size_t param_value_size;
301314
void *param_value;

0 commit comments

Comments
 (0)