[llvm] [ELF] Add CPU name detection for CUDA architectures (PR #75964)
Justin Lebar via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 19 15:09:57 PST 2023
================
@@ -517,6 +519,73 @@ StringRef ELFObjectFileBase::getAMDGPUCPUName() const {
}
}
+StringRef ELFObjectFileBase::getNVPTXCPUName() const {
+ assert(getEMachine() == ELF::EM_CUDA);
+ unsigned SM = getPlatformFlags() & ELF::EF_CUDA_SM;
+
+ switch (SM) {
+ // Fermi architecture.
+ case ELF::EF_CUDA_SM20:
+ return "sm_20";
+ case ELF::EF_CUDA_SM21:
+ return "sm_21";
+
+ // Kepler architecture.
+ case ELF::EF_CUDA_SM30:
+ return "sm_30";
+ case ELF::EF_CUDA_SM32:
+ return "sm_32";
+ case ELF::EF_CUDA_SM35:
+ return "sm_35";
+ case ELF::EF_CUDA_SM37:
+ return "sm_37";
+
+ // Maxwell architecture.
+ case ELF::EF_CUDA_SM50:
+ return "sm_50";
+ case ELF::EF_CUDA_SM52:
+ return "sm_52";
+ case ELF::EF_CUDA_SM53:
+ return "sm_53";
+
+ // Pascal architecture.
+ case ELF::EF_CUDA_SM60:
+ return "sm_60";
+ case ELF::EF_CUDA_SM61:
+ return "sm_61";
+ case ELF::EF_CUDA_SM62:
+ return "sm_62";
+
+ // Volta architecture.
+ case ELF::EF_CUDA_SM70:
+ return "sm_70";
+ case ELF::EF_CUDA_SM72:
+ return "sm_72";
+
+ // Turing architecture.
+ case ELF::EF_CUDA_SM75:
+ return "sm_75";
+
+ // Ampere architecture.
+ case ELF::EF_CUDA_SM80:
+ return "sm_80";
+ case ELF::EF_CUDA_SM86:
+ return "sm_86";
+ case ELF::EF_CUDA_SM87:
+ return "sm_87";
+
+ // Ada architecture.
+ case ELF::EF_CUDA_SM89:
+ return "sm_89";
+
+ // Hopper architecture.
+ case ELF::EF_CUDA_SM90:
+ return getPlatformFlags() & ELF::EF_CUDA_ACCELERATORS ? "sm_90a" : "sm_90";
+ default:
+ llvm_unreachable("Unknown EF_CUDA_SM value");
----------------
jlebar wrote:
report_fatal_error? In some builds llvm_unreachable is UB if executed.
https://github.com/llvm/llvm-project/pull/75964
More information about the llvm-commits
mailing list