[llvm] [Offload] Define additional device info properties (PR #152533)

Callum Fare via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 8 09:25:11 PDT 2025


================
@@ -302,10 +302,57 @@ Error olGetDeviceInfoImplDetail(ol_device_handle_t Device,
   };
 
   // These are not implemented by the plugin interface
-  if (PropName == OL_DEVICE_INFO_PLATFORM)
+  switch (PropName) {
+  case OL_DEVICE_INFO_PLATFORM:
     return Info.write<void *>(Device->Platform);
-  if (PropName == OL_DEVICE_INFO_TYPE)
+
+  case OL_DEVICE_INFO_TYPE:
     return Info.write<ol_device_type_t>(OL_DEVICE_TYPE_GPU);
+
+  case OL_DEVICE_INFO_SINGLE_FP_CONFIG:
+  case OL_DEVICE_INFO_DOUBLE_FP_CONFIG: {
+    ol_device_fp_capability_flags_t flags{0};
+    flags |= OL_DEVICE_FP_CAPABILITY_FLAG_CORRECTLY_ROUNDED_DIVIDE_SQRT |
+             OL_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_NEAREST |
+             OL_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_ZERO |
+             OL_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_INF |
+             OL_DEVICE_FP_CAPABILITY_FLAG_INF_NAN |
+             OL_DEVICE_FP_CAPABILITY_FLAG_DENORM |
+             OL_DEVICE_FP_CAPABILITY_FLAG_FMA;
+    return Info.write(flags);
+  }
+
+  case OL_DEVICE_INFO_HALF_FP_CONFIG:
+    return Info.write<ol_device_fp_capability_flags_t>(0);
+
+  case OL_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_CHAR:
+  case OL_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_SHORT:
+  case OL_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_INT:
+  case OL_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_LONG:
+  case OL_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_FLOAT:
+  case OL_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_DOUBLE:
+  case OL_DEVICE_INFO_NATIVE_VECTOR_WIDTH_CHAR:
+  case OL_DEVICE_INFO_NATIVE_VECTOR_WIDTH_SHORT:
+  case OL_DEVICE_INFO_NATIVE_VECTOR_WIDTH_INT:
+  case OL_DEVICE_INFO_NATIVE_VECTOR_WIDTH_LONG:
+  case OL_DEVICE_INFO_NATIVE_VECTOR_WIDTH_FLOAT:
+  case OL_DEVICE_INFO_NATIVE_VECTOR_WIDTH_DOUBLE:
+    return Info.write<uint32_t>(1);
+
+  case OL_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_HALF:
+  case OL_DEVICE_INFO_NATIVE_VECTOR_WIDTH_HALF:
+    return Info.write<uint32_t>(0);
----------------
callumfare wrote:

This is a bit of an aside and not necessarily something that needs to be resolved in this PR, but just wanted to get my thoughts out.

I dislike that we've inherited all these queries (from OpenCL via SYCL). They only make sense on non-GPU targets and I suspect they're never really used by users, but the SYCL spec means we're stuck with them. I wonder if we could get rid of `PREFERRED` and just keep `NATIVE` (which would implement both queries in UR) - are there any targets in the wild where these actually differ?

https://github.com/llvm/llvm-project/pull/152533


More information about the llvm-commits mailing list