================
@@ -58,28 +61,39 @@ int printGPUsByKFD(StringRef NodePath) {
       return 1;
 
     long GFXVersion = 0;
+    uint64_t Capability = 0;
     for (line_iterator Lines(**BufferOrErr, false); !Lines.is_at_end();
          ++Lines) {
-      StringRef Line(*Lines);
-      if (Line.consume_front("gfx_target_version")) {
-        if (Line.drop_while([](char C) { return std::isspace(C); })
-                .consumeInteger(10, GFXVersion))
+      // Split by ' ' to differentiate capability and capability2
+      auto [Key, Value] = StringRef(*Lines).split(' ');
+      if (Key == "gfx_target_version") {
+        if (Value.trim().consumeInteger(10, GFXVersion))
+          return 1;
+      } else if (Key == "capability") {
+        if (Value.trim().consumeInteger(10, Capability))
           return 1;
-        break;
       }
     }
 
     // If this is zero the node is a CPU.
     if (GFXVersion == 0)
       continue;
-    Devices.emplace_back(Node, GFXVersion);
+    // ASIC revision is bits 25:22 in capability
+    long ASICRevision = (Capability >> 22) & 0xf;
+    Devices.emplace_back(Node, GFXVersion, ASICRevision);
   }
 
   // Sort the devices by their node to make sure it prints in order.
-  llvm::sort(Devices, [](auto &L, auto &R) { return L.first < R.first; });
-  for (const auto &[Node, GFXVersion] : Devices)
+  llvm::sort(Devices,
+             [](auto &L, auto &R) { return std::get<0>(L) < std::get<0>(R); });
+  for (const auto &[Node, GFXVersion, ASICRevision] : Devices) {
     outs() << "gfx" << getMajor(GFXVersion) << getMinor(GFXVersion)
-           << format_hex_no_prefix(getStep(GFXVersion), 1) << '\n';
+           << format_hex_no_prefix(getStep(GFXVersion), 1);
+    // For A0, print gfx1250-strict to match rocminfo
+    if (GFXVersion == GFX1250_VERSION && ASICRevision == 0)
----------------
jhuber6 wrote:

We should have a helper that just returns an empty string or `-strict` 
depending on the capability.

https://github.com/llvm/llvm-project/pull/224480
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to