[clang] [llvm] [TargetParser] Add a list of Intel GPUs, and use it in offload-arch (PR #222072)
Srividya Sundaram via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 10 15:51:47 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.
----------------
srividya-sundaram wrote:
Detection should name the device, and the driver decides what is targetable, because
only the driver can name the bad value the user typed for --offload-arch and list the supported ones.
I think with the current code if the user has a device xe_35.11.0, and a clang whose .def predates it:
We will get:
```
$ clang++ -fsycl --offload-arch=native app.cpp
Unknown Intel GPU 'Intel(R) Graphics', which reports the architecture xe_35.11.0
clang++: error: cannot determine offload architecture: No GPU detected in the
system; consider passing it via '--offload-arch' ---> wrong, the user did have a GPU installed.
```
Instead, if print `getNumericArchName()` and continue, instead of erroring, that seems helpful:
```
$ clang++ -fsycl --offload-arch=native app.cpp
clang++: error: unsupported Intel GPU architecture 'xe_35.11.0'
note: valid target IDs are: xe-pvc, xe-bmg-g21, xe-lnl-m, ...
```
So, offload-arch can just do detection and driver the validation.
Other backends also do detection, leaving validation and diagnostics to the driver.
Detection prints, never validates
https://github.com/llvm/llvm-project/blob/main/clang/tools/offload-arch/NVPTXArch.cpp#L115
https://github.com/llvm/llvm-project/blob/main/clang/tools/offload-arch/AMDGPUArchByKFD.cpp#L81-L82
https://github.com/llvm/llvm-project/blob/main/clang/tools/offload-arch/AMDGPUArchByHIP.cpp#L378
https://github.com/llvm/llvm-project/blob/main/clang/tools/offload-arch/AMDGPUArchByHIP.cpp#L440
Driver validates detection output through the user-input path
https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/Driver.cpp#L4011-L4025
https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/Driver.cpp#L3936-L3946
https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticDriverKinds.td#L60
-cc1 validates again and lists valid values
https://github.com/llvm/llvm-project/blob/main/clang/lib/Basic/Targets.cpp#L855-L862
https://github.com/llvm/llvm-project/pull/222072
More information about the cfe-commits
mailing list