[llvm] [Offload] Refactor device/platform info queries (PR #146345)
Joseph Huber via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 30 05:32:48 PDT 2025
================
@@ -315,14 +322,45 @@ Error olGetDeviceInfoImplDetail(ol_device_handle_t Device,
return Error::success();
}
+Error olGetDeviceInfoImplDetailHost(ol_device_handle_t Device,
+ ol_device_info_t PropName, size_t PropSize,
+ void *PropValue, size_t *PropSizeRet) {
+ assert(Device == OffloadContext::get().HostDevice());
+ InfoWriter Info(PropSize, PropValue, PropSizeRet);
+
+ switch (PropName) {
+ case OL_DEVICE_INFO_PLATFORM:
+ return Info.Write<void *>(Device->Platform);
+ case OL_DEVICE_INFO_TYPE:
+ return Info.Write<ol_device_type_t>(OL_DEVICE_TYPE_HOST);
+ case OL_DEVICE_INFO_NAME:
+ return Info.WriteString("Virtual Host Device");
+ case OL_DEVICE_INFO_VENDOR:
+ return Info.WriteString("Liboffload");
+ case OL_DEVICE_INFO_DRIVER_VERSION:
+ return Info.WriteString(LLVM_VERSION_STRING);
+ default:
+ return createOffloadError(ErrorCode::INVALID_ENUMERATION,
+ "getDeviceInfo enum '%i' is invalid", PropName);
+ }
+
+ return Error::success();
+}
+
Error olGetDeviceInfo_impl(ol_device_handle_t Device, ol_device_info_t PropName,
size_t PropSize, void *PropValue) {
+ if (Device == OffloadContext::get().HostDevice())
+ return olGetDeviceInfoImplDetailHost(Device, PropName, PropSize, PropValue,
+ nullptr);
----------------
jhuber6 wrote:
For the future, I think we need a stronger abstraction here so we don't have `if host device` littered everywhere..
https://github.com/llvm/llvm-project/pull/146345
More information about the llvm-commits
mailing list