Skip to content

Commit

Permalink
[CUDA] bump supported CUDA version to 12.1/11.8
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D151361
  • Loading branch information
Artem-B committed May 25, 2023
1 parent 0ad5d40 commit ffb635c
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 85 deletions.
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ CUDA/HIP Language Changes

CUDA Support
^^^^^^^^^^^^
- Clang now supports CUDA SDK up to 12.1

AIX Support
^^^^^^^^^^^
Expand Down
8 changes: 7 additions & 1 deletion clang/include/clang/Basic/BuiltinsNVPTX.def
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@
#pragma push_macro("PTX76")
#pragma push_macro("PTX77")
#pragma push_macro("PTX78")
#define PTX78 "ptx78"
#pragma push_macro("PTX80")
#pragma push_macro("PTX81")
#define PTX81 "ptx81"
#define PTX80 "ptx80|" PTX81
#define PTX78 "ptx78|" PTX80
#define PTX77 "ptx77|" PTX78
#define PTX76 "ptx76|" PTX77
#define PTX75 "ptx75|" PTX76
Expand Down Expand Up @@ -1012,3 +1016,5 @@ TARGET_BUILTIN(__nvvm_neg_bf16x2, "ZUiZUi", "", AND(SM_80,PTX70))
#pragma pop_macro("PTX76")
#pragma pop_macro("PTX77")
#pragma pop_macro("PTX78")
#pragma pop_macro("PTX80")
#pragma pop_macro("PTX81")
6 changes: 4 additions & 2 deletions clang/include/clang/Basic/Cuda.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ enum class CudaVersion {
CUDA_116,
CUDA_117,
CUDA_118,
FULLY_SUPPORTED = CUDA_115,
CUDA_120,
CUDA_121,
FULLY_SUPPORTED = CUDA_118,
PARTIALLY_SUPPORTED =
CUDA_118, // Partially supported. Proceed with a warning.
CUDA_121, // Partially supported. Proceed with a warning.
NEW = 10000, // Too new. Issue a warning, but allow using it.
};
const char *CudaVersionToString(CudaVersion V);
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Basic/Cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ static const CudaVersionMapEntry CudaNameVersionMap[] = {
CUDA_ENTRY(11, 6),
CUDA_ENTRY(11, 7),
CUDA_ENTRY(11, 8),
CUDA_ENTRY(12, 0),
CUDA_ENTRY(12, 1),
{"", CudaVersion::NEW, llvm::VersionTuple(std::numeric_limits<int>::max())},
{"unknown", CudaVersion::UNKNOWN, {}} // End of list tombstone.
};
Expand Down
6 changes: 6 additions & 0 deletions clang/lib/Driver/ToolChains/Cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ CudaVersion getCudaVersion(uint32_t raw_version) {
return CudaVersion::CUDA_117;
if (raw_version < 11090)
return CudaVersion::CUDA_118;
if (raw_version < 12010)
return CudaVersion::CUDA_120;
if (raw_version < 12020)
return CudaVersion::CUDA_121;
return CudaVersion::NEW;
}

Expand Down Expand Up @@ -668,6 +672,8 @@ void NVPTX::getNVPTXTargetFeatures(const Driver &D, const llvm::Triple &Triple,
case CudaVersion::CUDA_##CUDA_VER: \
PtxFeature = "+ptx" #PTX_VER; \
break;
CASE_CUDA_VERSION(121, 81);
CASE_CUDA_VERSION(120, 80);
CASE_CUDA_VERSION(118, 78);
CASE_CUDA_VERSION(117, 77);
CASE_CUDA_VERSION(116, 76);
Expand Down
97 changes: 15 additions & 82 deletions llvm/lib/Target/NVPTX/NVPTX.td
Original file line number Diff line number Diff line change
Expand Up @@ -24,89 +24,22 @@ include "NVPTXInstrInfo.td"
// TableGen in NVPTXGenSubtarget.inc.
//===----------------------------------------------------------------------===//

// SM Versions
def SM20 : SubtargetFeature<"sm_20", "SmVersion", "20",
"Target SM 2.0">;
def SM21 : SubtargetFeature<"sm_21", "SmVersion", "21",
"Target SM 2.1">;
def SM30 : SubtargetFeature<"sm_30", "SmVersion", "30",
"Target SM 3.0">;
def SM32 : SubtargetFeature<"sm_32", "SmVersion", "32",
"Target SM 3.2">;
def SM35 : SubtargetFeature<"sm_35", "SmVersion", "35",
"Target SM 3.5">;
def SM37 : SubtargetFeature<"sm_37", "SmVersion", "37",
"Target SM 3.7">;
def SM50 : SubtargetFeature<"sm_50", "SmVersion", "50",
"Target SM 5.0">;
def SM52 : SubtargetFeature<"sm_52", "SmVersion", "52",
"Target SM 5.2">;
def SM53 : SubtargetFeature<"sm_53", "SmVersion", "53",
"Target SM 5.3">;
def SM60 : SubtargetFeature<"sm_60", "SmVersion", "60",
"Target SM 6.0">;
def SM61 : SubtargetFeature<"sm_61", "SmVersion", "61",
"Target SM 6.1">;
def SM62 : SubtargetFeature<"sm_62", "SmVersion", "62",
"Target SM 6.2">;
def SM70 : SubtargetFeature<"sm_70", "SmVersion", "70",
"Target SM 7.0">;
def SM72 : SubtargetFeature<"sm_72", "SmVersion", "72",
"Target SM 7.2">;
def SM75 : SubtargetFeature<"sm_75", "SmVersion", "75",
"Target SM 7.5">;
def SM80 : SubtargetFeature<"sm_80", "SmVersion", "80",
"Target SM 8.0">;
def SM86 : SubtargetFeature<"sm_86", "SmVersion", "86",
"Target SM 8.6">;
def SM87 : SubtargetFeature<"sm_87", "SmVersion", "87",
"Target SM 8.7">;
def SM89 : SubtargetFeature<"sm_89", "SmVersion", "89",
"Target SM 8.9">;
def SM90 : SubtargetFeature<"sm_90", "SmVersion", "90",
"Target SM 9.0">;
class FeatureSM<int version>:
SubtargetFeature<"sm_"# version, "SmVersion",
"" # version,
"Target SM " # version>;
class FeaturePTX<int version>:
SubtargetFeature<"ptx"# version, "PTXVersion",
"" # version,
"Use PTX version " # version>;

// PTX Versions
def PTX32 : SubtargetFeature<"ptx32", "PTXVersion", "32",
"Use PTX version 3.2">;
def PTX40 : SubtargetFeature<"ptx40", "PTXVersion", "40",
"Use PTX version 4.0">;
def PTX41 : SubtargetFeature<"ptx41", "PTXVersion", "41",
"Use PTX version 4.1">;
def PTX42 : SubtargetFeature<"ptx42", "PTXVersion", "42",
"Use PTX version 4.2">;
def PTX43 : SubtargetFeature<"ptx43", "PTXVersion", "43",
"Use PTX version 4.3">;
def PTX50 : SubtargetFeature<"ptx50", "PTXVersion", "50",
"Use PTX version 5.0">;
def PTX60 : SubtargetFeature<"ptx60", "PTXVersion", "60",
"Use PTX version 6.0">;
def PTX61 : SubtargetFeature<"ptx61", "PTXVersion", "61",
"Use PTX version 6.1">;
def PTX63 : SubtargetFeature<"ptx63", "PTXVersion", "63",
"Use PTX version 6.3">;
def PTX64 : SubtargetFeature<"ptx64", "PTXVersion", "64",
"Use PTX version 6.4">;
def PTX65 : SubtargetFeature<"ptx65", "PTXVersion", "65",
"Use PTX version 6.5">;
def PTX70 : SubtargetFeature<"ptx70", "PTXVersion", "70",
"Use PTX version 7.0">;
def PTX71 : SubtargetFeature<"ptx71", "PTXVersion", "71",
"Use PTX version 7.1">;
def PTX72 : SubtargetFeature<"ptx72", "PTXVersion", "72",
"Use PTX version 7.2">;
def PTX73 : SubtargetFeature<"ptx73", "PTXVersion", "73",
"Use PTX version 7.3">;
def PTX74 : SubtargetFeature<"ptx74", "PTXVersion", "74",
"Use PTX version 7.4">;
def PTX75 : SubtargetFeature<"ptx75", "PTXVersion", "75",
"Use PTX version 7.5">;
def PTX76 : SubtargetFeature<"ptx76", "PTXVersion", "76",
"Use PTX version 7.6">;
def PTX77 : SubtargetFeature<"ptx77", "PTXVersion", "77",
"Use PTX version 7.7">;
def PTX78 : SubtargetFeature<"ptx78", "PTXVersion", "78",
"Use PTX version 7.8">;
foreach version = [20, 21, 30, 32, 35, 37, 50, 52, 53,
60, 61, 62, 70, 72, 75, 80, 86, 87, 89, 90] in
def SM#version: FeatureSM<version>;

foreach version = [32, 40, 41, 42, 43, 50, 60, 61, 63, 64, 65,
70, 71, 72, 73, 74, 75, 76, 77, 78, 80, 81] in
def PTX#version: FeaturePTX<version>;

//===----------------------------------------------------------------------===//
// NVPTX supported processors.
Expand Down

0 comments on commit ffb635c

Please sign in to comment.