[llvm] [Offload] Optimistically accept SM architectures (PR #142399)

Artem Belevich via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 2 11:27:52 PDT 2025


================
@@ -75,8 +75,7 @@ checkMachineImpl(const object::ELFObjectFile<ELFT> &ELFObj, uint16_t EMachine) {
   } else if (Header.e_machine == EM_CUDA) {
     if (~Header.e_flags & EF_CUDA_64BIT_ADDRESS)
       return createError("Invalid CUDA addressing mode");
-    if ((Header.e_flags & EF_CUDA_SM) < EF_CUDA_SM35 ||
-        (Header.e_flags & EF_CUDA_SM) > EF_CUDA_SM90)
+    if ((Header.e_flags & EF_CUDA_SM) < EF_CUDA_SM35)
----------------
Artem-B wrote:

What exactly does `checkMachineImpl` check for? That the ELF file is valid in principle? Or that it was created with specific set of parameters?

If it's the former, then the check should be removed altogether -- I can create a perfectly valid GPU ELF for sm_30 or even sm_20 using an older CUDA SDK. The fact that the newer CUDA versions can no longer do that does not make that ELF invalid.

If we do want to check that the ELF is for specific subset of the architectures, then it's up to you what you want to do here. Considering that we can't do much with the NVIDIA's ELF files themselves, I suspect we do not really care which SM it's for, except for, perhaps, making sure that it matches the GPU the compilation is targeting, but that would be checked somewhere else, I assume.

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


More information about the llvm-commits mailing list