[clang] [llvm] [TargetParser] Add a list of Intel GPUs, and use it in offload-arch (PR #222072)
Nikita Kornev via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 11 02:34:09 PDT 2026
================
@@ -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';
----------------
KornevNikita wrote:
Replied in the original thread.
https://github.com/llvm/llvm-project/pull/222072
More information about the cfe-commits
mailing list