Skip to content

Commit 33386b2

Browse files
committed
[CUDA] Simplify GPU variant handling. NFC.
Instead of hardcoding individual GPU mappings in multiple functions, keep them all in one table and use it to look up the mappings. We also don't care about 'virtual' architecture much, so the API is trimmed down down to a simpler GPU->Virtual arch name lookup. Differential Revision: https://reviews.llvm.org/D77665
1 parent d51b38f commit 33386b2

File tree

3 files changed

+90
-308
lines changed

3 files changed

+90
-308
lines changed

clang/include/clang/Basic/Cuda.h

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -72,36 +72,20 @@ enum class CudaArch {
7272
GFX1012,
7373
LAST,
7474
};
75-
const char *CudaArchToString(CudaArch A);
7675

77-
// The input should have the form "sm_20".
78-
CudaArch StringToCudaArch(llvm::StringRef S);
76+
static inline bool IsNVIDIAGpuArch(CudaArch A) {
77+
return A >= CudaArch::SM_20 && A < CudaArch::GFX600;
78+
}
7979

80-
enum class CudaVirtualArch {
81-
UNKNOWN,
82-
COMPUTE_20,
83-
COMPUTE_30,
84-
COMPUTE_32,
85-
COMPUTE_35,
86-
COMPUTE_37,
87-
COMPUTE_50,
88-
COMPUTE_52,
89-
COMPUTE_53,
90-
COMPUTE_60,
91-
COMPUTE_61,
92-
COMPUTE_62,
93-
COMPUTE_70,
94-
COMPUTE_72,
95-
COMPUTE_75,
96-
COMPUTE_AMDGCN,
97-
};
98-
const char *CudaVirtualArchToString(CudaVirtualArch A);
80+
static inline bool IsAMDGpuArch(CudaArch A) {
81+
return A >= CudaArch::GFX600 && A < CudaArch::LAST;
82+
}
9983

100-
// The input should have the form "compute_20".
101-
CudaVirtualArch StringToCudaVirtualArch(llvm::StringRef S);
84+
const char *CudaArchToString(CudaArch A);
85+
const char *CudaArchToVirtualArchString(CudaArch A);
10286

103-
/// Get the compute_xx corresponding to an sm_yy.
104-
CudaVirtualArch VirtualArchForCudaArch(CudaArch A);
87+
// The input should have the form "sm_20".
88+
CudaArch StringToCudaArch(llvm::StringRef S);
10589

10690
/// Get the earliest CudaVersion that supports the given CudaArch.
10791
CudaVersion MinVersionForCudaArch(CudaArch A);

0 commit comments

Comments
 (0)