================
@@ -173,11 +189,42 @@ int printGPUsByLevelZero() {
     CALL_ZE_AND_CHECK(zeDeviceGet, Driver, &DeviceCount, Devices.data());
 
     for (auto Device : Devices) {
+      ze_device_ip_version_ext_t IPVersion = {};
+      IPVersion.stype = ZE_STRUCTURE_TYPE_DEVICE_IP_VERSION_EXT;
+      IPVersion.pNext = nullptr;
+
       ze_device_properties_t DeviceProperties = {};
       DeviceProperties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;
-      DeviceProperties.pNext = nullptr;
+      DeviceProperties.pNext = &IPVersion;
       CALL_ZE_AND_CHECK(zeDeviceGetProperties, Device, &DeviceProperties);
-      llvm::outs() << DeviceProperties.name << '\n';
+
+      // A driver that does not support the extension leaves the chained
+      // structure untouched, in which case there is no architecture to name.
+      if (IPVersion.ipVersion == 0) {
+        if (Verbose)
+          llvm::errs() << "Unable to query the IP version of device '"
+                       << DeviceProperties.name << "'\n";
+        continue;
+      }
+
+      if (Verbose)
+        llvm::errs() << "Found device '" << DeviceProperties.name << "'\n";
+
+      // Naming an unknown device after its GMDID would print something that
+      // --offload-arch cannot accept, because this build knows no IGCA level 
to
+      // compile for.  Report it instead, spelling out the GMDID so that the
+      // device can be identified.
+      StringRef Arch = getIntelGPUArchName(IPVersion.ipVersion);
+      if (Arch.empty()) {
+        llvm::errs() << "Unknown Intel GPU '" << DeviceProperties.name
+                     << "', which reports the architecture "
+                     << IntelGPU::getNumericArchName(
+                            IntelGPU::decodeGMDID(IPVersion.ipVersion))
+                     << "\n";
+        return 1;
+      }
+
+      llvm::outs() << Arch << '\n';
----------------
srividya-sundaram wrote:

Maybe this?

```suggestion
  StringRef Arch = getIntelGPUArchName(IPVersion.ipVersion);
  if (Arch.empty()) {
-   llvm::errs() << "Unknown Intel GPU '" << ... << "\n";
-   return 1;
+   llvm::outs() << IntelGPU::getNumericArchName(
+                       IntelGPU::decodeGMDID(IPVersion.ipVersion)) << '\n';
+   continue;
  }
- llvm::outs() << Arch << '\n';
+ else
+   llvm::outs() << Arch << '\n';

```

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

Reply via email to