Skip to content

Commit ffb635c

Browse files
committed
[CUDA] bump supported CUDA version to 12.1/11.8
Differential Revision: https://reviews.llvm.org/D151361
1 parent 0ad5d40 commit ffb635c

File tree

6 files changed

+35
-85
lines changed

6 files changed

+35
-85
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ CUDA/HIP Language Changes
587587

588588
CUDA Support
589589
^^^^^^^^^^^^
590+
- Clang now supports CUDA SDK up to 12.1
590591

591592
AIX Support
592593
^^^^^^^^^^^

clang/include/clang/Basic/BuiltinsNVPTX.def

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@
5454
#pragma push_macro("PTX76")
5555
#pragma push_macro("PTX77")
5656
#pragma push_macro("PTX78")
57-
#define PTX78 "ptx78"
57+
#pragma push_macro("PTX80")
58+
#pragma push_macro("PTX81")
59+
#define PTX81 "ptx81"
60+
#define PTX80 "ptx80|" PTX81
61+
#define PTX78 "ptx78|" PTX80
5862
#define PTX77 "ptx77|" PTX78
5963
#define PTX76 "ptx76|" PTX77
6064
#define PTX75 "ptx75|" PTX76
@@ -1012,3 +1016,5 @@ TARGET_BUILTIN(__nvvm_neg_bf16x2, "ZUiZUi", "", AND(SM_80,PTX70))
10121016
#pragma pop_macro("PTX76")
10131017
#pragma pop_macro("PTX77")
10141018
#pragma pop_macro("PTX78")
1019+
#pragma pop_macro("PTX80")
1020+
#pragma pop_macro("PTX81")

clang/include/clang/Basic/Cuda.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ enum class CudaVersion {
3737
CUDA_116,
3838
CUDA_117,
3939
CUDA_118,
40-
FULLY_SUPPORTED = CUDA_115,
40+
CUDA_120,
41+
CUDA_121,
42+
FULLY_SUPPORTED = CUDA_118,
4143
PARTIALLY_SUPPORTED =
42-
CUDA_118, // Partially supported. Proceed with a warning.
44+
CUDA_121, // Partially supported. Proceed with a warning.
4345
NEW = 10000, // Too new. Issue a warning, but allow using it.
4446
};
4547
const char *CudaVersionToString(CudaVersion V);

clang/lib/Basic/Cuda.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ static const CudaVersionMapEntry CudaNameVersionMap[] = {
3737
CUDA_ENTRY(11, 6),
3838
CUDA_ENTRY(11, 7),
3939
CUDA_ENTRY(11, 8),
40+
CUDA_ENTRY(12, 0),
41+
CUDA_ENTRY(12, 1),
4042
{"", CudaVersion::NEW, llvm::VersionTuple(std::numeric_limits<int>::max())},
4143
{"unknown", CudaVersion::UNKNOWN, {}} // End of list tombstone.
4244
};

clang/lib/Driver/ToolChains/Cuda.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ CudaVersion getCudaVersion(uint32_t raw_version) {
7474
return CudaVersion::CUDA_117;
7575
if (raw_version < 11090)
7676
return CudaVersion::CUDA_118;
77+
if (raw_version < 12010)
78+
return CudaVersion::CUDA_120;
79+
if (raw_version < 12020)
80+
return CudaVersion::CUDA_121;
7781
return CudaVersion::NEW;
7882
}
7983

@@ -668,6 +672,8 @@ void NVPTX::getNVPTXTargetFeatures(const Driver &D, const llvm::Triple &Triple,
668672
case CudaVersion::CUDA_##CUDA_VER: \
669673
PtxFeature = "+ptx" #PTX_VER; \
670674
break;
675+
CASE_CUDA_VERSION(121, 81);
676+
CASE_CUDA_VERSION(120, 80);
671677
CASE_CUDA_VERSION(118, 78);
672678
CASE_CUDA_VERSION(117, 77);
673679
CASE_CUDA_VERSION(116, 76);

llvm/lib/Target/NVPTX/NVPTX.td

Lines changed: 15 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -24,89 +24,22 @@ include "NVPTXInstrInfo.td"
2424
// TableGen in NVPTXGenSubtarget.inc.
2525
//===----------------------------------------------------------------------===//
2626

27-
// SM Versions
28-
def SM20 : SubtargetFeature<"sm_20", "SmVersion", "20",
29-
"Target SM 2.0">;
30-
def SM21 : SubtargetFeature<"sm_21", "SmVersion", "21",
31-
"Target SM 2.1">;
32-
def SM30 : SubtargetFeature<"sm_30", "SmVersion", "30",
33-
"Target SM 3.0">;
34-
def SM32 : SubtargetFeature<"sm_32", "SmVersion", "32",
35-
"Target SM 3.2">;
36-
def SM35 : SubtargetFeature<"sm_35", "SmVersion", "35",
37-
"Target SM 3.5">;
38-
def SM37 : SubtargetFeature<"sm_37", "SmVersion", "37",
39-
"Target SM 3.7">;
40-
def SM50 : SubtargetFeature<"sm_50", "SmVersion", "50",
41-
"Target SM 5.0">;
42-
def SM52 : SubtargetFeature<"sm_52", "SmVersion", "52",
43-
"Target SM 5.2">;
44-
def SM53 : SubtargetFeature<"sm_53", "SmVersion", "53",
45-
"Target SM 5.3">;
46-
def SM60 : SubtargetFeature<"sm_60", "SmVersion", "60",
47-
"Target SM 6.0">;
48-
def SM61 : SubtargetFeature<"sm_61", "SmVersion", "61",
49-
"Target SM 6.1">;
50-
def SM62 : SubtargetFeature<"sm_62", "SmVersion", "62",
51-
"Target SM 6.2">;
52-
def SM70 : SubtargetFeature<"sm_70", "SmVersion", "70",
53-
"Target SM 7.0">;
54-
def SM72 : SubtargetFeature<"sm_72", "SmVersion", "72",
55-
"Target SM 7.2">;
56-
def SM75 : SubtargetFeature<"sm_75", "SmVersion", "75",
57-
"Target SM 7.5">;
58-
def SM80 : SubtargetFeature<"sm_80", "SmVersion", "80",
59-
"Target SM 8.0">;
60-
def SM86 : SubtargetFeature<"sm_86", "SmVersion", "86",
61-
"Target SM 8.6">;
62-
def SM87 : SubtargetFeature<"sm_87", "SmVersion", "87",
63-
"Target SM 8.7">;
64-
def SM89 : SubtargetFeature<"sm_89", "SmVersion", "89",
65-
"Target SM 8.9">;
66-
def SM90 : SubtargetFeature<"sm_90", "SmVersion", "90",
67-
"Target SM 9.0">;
27+
class FeatureSM<int version>:
28+
SubtargetFeature<"sm_"# version, "SmVersion",
29+
"" # version,
30+
"Target SM " # version>;
31+
class FeaturePTX<int version>:
32+
SubtargetFeature<"ptx"# version, "PTXVersion",
33+
"" # version,
34+
"Use PTX version " # version>;
6835

69-
// PTX Versions
70-
def PTX32 : SubtargetFeature<"ptx32", "PTXVersion", "32",
71-
"Use PTX version 3.2">;
72-
def PTX40 : SubtargetFeature<"ptx40", "PTXVersion", "40",
73-
"Use PTX version 4.0">;
74-
def PTX41 : SubtargetFeature<"ptx41", "PTXVersion", "41",
75-
"Use PTX version 4.1">;
76-
def PTX42 : SubtargetFeature<"ptx42", "PTXVersion", "42",
77-
"Use PTX version 4.2">;
78-
def PTX43 : SubtargetFeature<"ptx43", "PTXVersion", "43",
79-
"Use PTX version 4.3">;
80-
def PTX50 : SubtargetFeature<"ptx50", "PTXVersion", "50",
81-
"Use PTX version 5.0">;
82-
def PTX60 : SubtargetFeature<"ptx60", "PTXVersion", "60",
83-
"Use PTX version 6.0">;
84-
def PTX61 : SubtargetFeature<"ptx61", "PTXVersion", "61",
85-
"Use PTX version 6.1">;
86-
def PTX63 : SubtargetFeature<"ptx63", "PTXVersion", "63",
87-
"Use PTX version 6.3">;
88-
def PTX64 : SubtargetFeature<"ptx64", "PTXVersion", "64",
89-
"Use PTX version 6.4">;
90-
def PTX65 : SubtargetFeature<"ptx65", "PTXVersion", "65",
91-
"Use PTX version 6.5">;
92-
def PTX70 : SubtargetFeature<"ptx70", "PTXVersion", "70",
93-
"Use PTX version 7.0">;
94-
def PTX71 : SubtargetFeature<"ptx71", "PTXVersion", "71",
95-
"Use PTX version 7.1">;
96-
def PTX72 : SubtargetFeature<"ptx72", "PTXVersion", "72",
97-
"Use PTX version 7.2">;
98-
def PTX73 : SubtargetFeature<"ptx73", "PTXVersion", "73",
99-
"Use PTX version 7.3">;
100-
def PTX74 : SubtargetFeature<"ptx74", "PTXVersion", "74",
101-
"Use PTX version 7.4">;
102-
def PTX75 : SubtargetFeature<"ptx75", "PTXVersion", "75",
103-
"Use PTX version 7.5">;
104-
def PTX76 : SubtargetFeature<"ptx76", "PTXVersion", "76",
105-
"Use PTX version 7.6">;
106-
def PTX77 : SubtargetFeature<"ptx77", "PTXVersion", "77",
107-
"Use PTX version 7.7">;
108-
def PTX78 : SubtargetFeature<"ptx78", "PTXVersion", "78",
109-
"Use PTX version 7.8">;
36+
foreach version = [20, 21, 30, 32, 35, 37, 50, 52, 53,
37+
60, 61, 62, 70, 72, 75, 80, 86, 87, 89, 90] in
38+
def SM#version: FeatureSM<version>;
39+
40+
foreach version = [32, 40, 41, 42, 43, 50, 60, 61, 63, 64, 65,
41+
70, 71, 72, 73, 74, 75, 76, 77, 78, 80, 81] in
42+
def PTX#version: FeaturePTX<version>;
11043

11144
//===----------------------------------------------------------------------===//
11245
// NVPTX supported processors.

0 commit comments

Comments
 (0)