clang  14.0.0git
Cuda.h
Go to the documentation of this file.
1 //===--- Cuda.h - Utilities for compiling CUDA code ------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_CLANG_BASIC_CUDA_H
10 #define LLVM_CLANG_BASIC_CUDA_H
11 
12 namespace llvm {
13 class StringRef;
14 class Twine;
15 class VersionTuple;
16 } // namespace llvm
17 
18 namespace clang {
19 
20 enum class CudaVersion {
21  UNKNOWN,
22  CUDA_70,
23  CUDA_75,
24  CUDA_80,
25  CUDA_90,
26  CUDA_91,
27  CUDA_92,
28  CUDA_100,
29  CUDA_101,
30  CUDA_102,
31  CUDA_110,
32  CUDA_111,
33  CUDA_112,
34  CUDA_113,
35  CUDA_114,
38  CUDA_114, // Partially supported. Proceed with a warning.
39  NEW = 10000, // Too new. Issue a warning, but allow using it.
40 };
41 const char *CudaVersionToString(CudaVersion V);
42 // Input is "Major.Minor"
43 CudaVersion CudaStringToVersion(const llvm::Twine &S);
44 
45 enum class CudaArch {
46  UNUSED,
47  UNKNOWN,
48  SM_20,
49  SM_21,
50  SM_30,
51  SM_32,
52  SM_35,
53  SM_37,
54  SM_50,
55  SM_52,
56  SM_53,
57  SM_60,
58  SM_61,
59  SM_62,
60  SM_70,
61  SM_72,
62  SM_75,
63  SM_80,
64  SM_86,
65  GFX600,
66  GFX601,
67  GFX602,
68  GFX700,
69  GFX701,
70  GFX702,
71  GFX703,
72  GFX704,
73  GFX705,
74  GFX801,
75  GFX802,
76  GFX803,
77  GFX805,
78  GFX810,
79  GFX900,
80  GFX902,
81  GFX904,
82  GFX906,
83  GFX908,
84  GFX909,
85  GFX90a,
86  GFX90c,
87  GFX1010,
88  GFX1011,
89  GFX1012,
90  GFX1013,
91  GFX1030,
92  GFX1031,
93  GFX1032,
94  GFX1033,
95  GFX1034,
96  GFX1035,
97  LAST,
98 };
99 
100 static inline bool IsNVIDIAGpuArch(CudaArch A) {
101  return A >= CudaArch::SM_20 && A < CudaArch::GFX600;
102 }
103 
104 static inline bool IsAMDGpuArch(CudaArch A) {
105  return A >= CudaArch::GFX600 && A < CudaArch::LAST;
106 }
107 
108 const char *CudaArchToString(CudaArch A);
110 
111 // The input should have the form "sm_20".
112 CudaArch StringToCudaArch(llvm::StringRef S);
113 
114 /// Get the earliest CudaVersion that supports the given CudaArch.
116 
117 /// Get the latest CudaVersion that supports the given CudaArch.
119 
120 // Various SDK-dependent features that affect CUDA compilation
121 enum class CudaFeature {
122  // CUDA-9.2+ uses a new API for launching kernels.
124  // CUDA-10.1+ needs explicit end of GPU binary registration.
126 };
127 
128 CudaVersion ToCudaVersion(llvm::VersionTuple);
129 bool CudaFeatureEnabled(llvm::VersionTuple, CudaFeature);
131 
132 } // namespace clang
133 
134 #endif
clang::CudaArch::SM_35
@ SM_35
clang::CudaArch::GFX805
@ GFX805
clang::CudaVersion::CUDA_91
@ CUDA_91
clang::CudaArch::SM_70
@ SM_70
clang::CudaArch::GFX704
@ GFX704
clang::CudaVersion::CUDA_114
@ CUDA_114
llvm
Definition: Dominators.h:30
clang::CudaVersion::CUDA_100
@ CUDA_100
clang::CudaArch::GFX1035
@ GFX1035
clang::CudaArchToVirtualArchString
const char * CudaArchToVirtualArchString(CudaArch A)
Definition: Cuda.cpp:138
clang::CudaVersion::NEW
@ NEW
clang::CudaFeature
CudaFeature
Definition: Cuda.h:121
clang::CudaArch::GFX601
@ GFX601
clang::CudaVersion::CUDA_70
@ CUDA_70
clang::CudaArch::GFX908
@ GFX908
clang::IsAMDGpuArch
static bool IsAMDGpuArch(CudaArch A)
Definition: Cuda.h:104
clang::CudaArch::GFX906
@ GFX906
clang::CudaArch::GFX802
@ GFX802
clang::CudaArch::SM_53
@ SM_53
clang::CudaArch::GFX1034
@ GFX1034
clang::CudaVersion::CUDA_101
@ CUDA_101
clang::MinVersionForCudaArch
CudaVersion MinVersionForCudaArch(CudaArch A)
Get the earliest CudaVersion that supports the given CudaArch.
Definition: Cuda.cpp:156
clang::StringToCudaArch
CudaArch StringToCudaArch(llvm::StringRef S)
Definition: Cuda.cpp:147
clang::CudaArch::GFX1010
@ GFX1010
clang::CudaArch::SM_60
@ SM_60
clang::CudaArch::GFX1011
@ GFX1011
clang::CudaArch::SM_20
@ SM_20
V
#define V(N, I)
Definition: ASTContext.h:3121
clang::CudaVersion::CUDA_90
@ CUDA_90
clang::CudaArch::SM_86
@ SM_86
clang::CudaArch::GFX702
@ GFX702
clang::CudaFeature::CUDA_USES_FATBIN_REGISTER_END
@ CUDA_USES_FATBIN_REGISTER_END
clang::CudaArch::SM_72
@ SM_72
clang::CudaVersion::CUDA_102
@ CUDA_102
clang::CudaArch::GFX90c
@ GFX90c
clang::CudaVersion::CUDA_110
@ CUDA_110
clang::CudaArch::GFX1012
@ GFX1012
clang::CudaVersion
CudaVersion
Definition: Cuda.h:20
clang::CudaArch::GFX1033
@ GFX1033
clang::CudaArch::GFX1031
@ GFX1031
clang::CudaArch::GFX90a
@ GFX90a
clang::CudaArch::SM_21
@ SM_21
clang::CudaFeatureEnabled
bool CudaFeatureEnabled(llvm::VersionTuple, CudaFeature)
Definition: Cuda.cpp:249
clang::CudaArch::GFX1032
@ GFX1032
clang::CudaFeature::CUDA_USES_NEW_LAUNCH
@ CUDA_USES_NEW_LAUNCH
clang::CudaArch::GFX904
@ GFX904
clang::CudaVersion::CUDA_75
@ CUDA_75
clang::CudaArch::SM_52
@ SM_52
clang::CudaVersion::FULLY_SUPPORTED
@ FULLY_SUPPORTED
clang::CudaArch::SM_61
@ SM_61
clang::CudaArch::GFX803
@ GFX803
clang::CudaVersion::CUDA_111
@ CUDA_111
clang::CudaArch::LAST
@ LAST
clang::CudaArch::SM_80
@ SM_80
clang::CudaStringToVersion
CudaVersion CudaStringToVersion(const llvm::Twine &S)
Definition: Cuda.cpp:49
clang::CudaArch::GFX909
@ GFX909
clang::CudaArch::SM_30
@ SM_30
clang::CudaVersion::PARTIALLY_SUPPORTED
@ PARTIALLY_SUPPORTED
clang::CudaArch::GFX600
@ GFX600
clang::CudaArchToString
const char * CudaArchToString(CudaArch A)
Definition: Cuda.cpp:129
clang::ToCudaVersion
CudaVersion ToCudaVersion(llvm::VersionTuple)
Definition: Cuda.cpp:212
clang::CudaArch::UNKNOWN
@ UNKNOWN
clang::CudaVersion::CUDA_92
@ CUDA_92
clang::CudaArch::SM_32
@ SM_32
clang::CudaArch::GFX900
@ GFX900
clang::CudaArch::GFX801
@ GFX801
clang::CudaVersionToString
const char * CudaVersionToString(CudaVersion V)
Definition: Cuda.cpp:11
clang::CudaArch::GFX703
@ GFX703
clang::CudaArch::GFX705
@ GFX705
clang::MaxVersionForCudaArch
CudaVersion MaxVersionForCudaArch(CudaArch A)
Get the latest CudaVersion that supports the given CudaArch.
Definition: Cuda.cpp:194
clang
Definition: CalledOnceCheck.h:17
clang::CudaArch::GFX902
@ GFX902
clang::CudaVersion::CUDA_80
@ CUDA_80
clang::CudaArch::SM_37
@ SM_37
clang::CudaArch::GFX602
@ GFX602
clang::CudaArch::SM_50
@ SM_50
clang::CudaArch::GFX1013
@ GFX1013
clang::CudaArch
CudaArch
Definition: Cuda.h:45
clang::CudaArch::GFX810
@ GFX810
clang::CudaArch::UNUSED
@ UNUSED
clang::CudaArch::SM_62
@ SM_62
clang::CudaVersion::CUDA_113
@ CUDA_113
clang::CudaVersion::UNKNOWN
@ UNKNOWN
clang::IsNVIDIAGpuArch
static bool IsNVIDIAGpuArch(CudaArch A)
Definition: Cuda.h:100
clang::CudaArch::SM_75
@ SM_75
clang::CudaArch::GFX701
@ GFX701
clang::CudaArch::GFX1030
@ GFX1030
clang::CudaArch::GFX700
@ GFX700
clang::CudaVersion::CUDA_112
@ CUDA_112