[llvm] [Offload] Add `MAX_WORK_GROUP_SIZE` device info query (PR #143718)

Ross Brunton via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 16 03:31:48 PDT 2025


================
@@ -247,11 +244,49 @@ Error olGetDeviceInfoImplDetail(ol_device_handle_t Device,
                                DevInfo.getQueue().end(), InfoKeyMatches);
 
       if (Item != std::end(DevInfo.getQueue())) {
-        return Item->Value;
+        return Item;
       }
     }
 
-    return std::string("");
+    return std::nullopt;
+  };
+  auto GetInfoString = [&](llvm::SmallVector<StringRef> Names) {
+    InfoQueueTy DevInfo;
+
+    if (auto Item = FindInfo(DevInfo, Names)) {
+      return (*Item)->Value.c_str();
+    } else {
+      return "";
+    }
+  };
+  auto GetInfoXyz = [&](llvm::SmallVector<StringRef> Names) {
+    InfoQueueTy DevInfo;
+
+    if (auto Item = FindInfo(DevInfo, Names)) {
+      auto Iter = *Item;
+      ol_dimensions_t Out{0, 0, 0};
+      auto Level = Iter->Level + 1;
+
+      // Check the "children" of the current info for x/y/z components.
+      // We ignore any components that don't match.
+      while ((++Iter)->Level == Level) {
+        switch (Iter->Key[0]) {
+        case 'x':
+          Out.x = std::stoi(Iter->Value);
----------------
RossBrunton wrote:

I'm not sure. This value is reported by the plugins which should always return valid integers. Should liboffload be in charge of validating values that plugins return, or is it enough to say that plugins returning invalid values is UB?

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


More information about the llvm-commits mailing list