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

Joseph Huber via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 12 08:24:31 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);
----------------
jhuber6 wrote:

LLVM has integer conversions that can fail correctly. Do we need to worry about invalid values?

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


More information about the llvm-commits mailing list