clang  7.0.0svn
Cuda.cpp
Go to the documentation of this file.
1 #include "clang/Basic/Cuda.h"
2 
3 #include "llvm/ADT/StringRef.h"
4 #include "llvm/ADT/StringSwitch.h"
5 #include "llvm/Support/ErrorHandling.h"
6 
7 namespace clang {
8 
10  switch (V) {
12  return "unknown";
14  return "7.0";
16  return "7.5";
18  return "8.0";
20  return "9.0";
22  return "9.1";
23  }
24  llvm_unreachable("invalid enum");
25 }
26 
27 const char *CudaArchToString(CudaArch A) {
28  switch (A) {
29  case CudaArch::LAST:
30  break;
31  case CudaArch::UNKNOWN:
32  return "unknown";
33  case CudaArch::SM_20:
34  return "sm_20";
35  case CudaArch::SM_21:
36  return "sm_21";
37  case CudaArch::SM_30:
38  return "sm_30";
39  case CudaArch::SM_32:
40  return "sm_32";
41  case CudaArch::SM_35:
42  return "sm_35";
43  case CudaArch::SM_37:
44  return "sm_37";
45  case CudaArch::SM_50:
46  return "sm_50";
47  case CudaArch::SM_52:
48  return "sm_52";
49  case CudaArch::SM_53:
50  return "sm_53";
51  case CudaArch::SM_60:
52  return "sm_60";
53  case CudaArch::SM_61:
54  return "sm_61";
55  case CudaArch::SM_62:
56  return "sm_62";
57  case CudaArch::SM_70:
58  return "sm_70";
59  case CudaArch::SM_72:
60  return "sm_72";
61  }
62  llvm_unreachable("invalid enum");
63 }
64 
65 CudaArch StringToCudaArch(llvm::StringRef S) {
66  return llvm::StringSwitch<CudaArch>(S)
67  .Case("sm_20", CudaArch::SM_20)
68  .Case("sm_21", CudaArch::SM_21)
69  .Case("sm_30", CudaArch::SM_30)
70  .Case("sm_32", CudaArch::SM_32)
71  .Case("sm_35", CudaArch::SM_35)
72  .Case("sm_37", CudaArch::SM_37)
73  .Case("sm_50", CudaArch::SM_50)
74  .Case("sm_52", CudaArch::SM_52)
75  .Case("sm_53", CudaArch::SM_53)
76  .Case("sm_60", CudaArch::SM_60)
77  .Case("sm_61", CudaArch::SM_61)
78  .Case("sm_62", CudaArch::SM_62)
79  .Case("sm_70", CudaArch::SM_70)
80  .Case("sm_72", CudaArch::SM_72)
81  .Default(CudaArch::UNKNOWN);
82 }
83 
85  switch (A) {
87  return "unknown";
89  return "compute_20";
91  return "compute_30";
93  return "compute_32";
95  return "compute_35";
97  return "compute_37";
99  return "compute_50";
101  return "compute_52";
103  return "compute_53";
105  return "compute_60";
107  return "compute_61";
109  return "compute_62";
111  return "compute_70";
113  return "compute_72";
114  }
115  llvm_unreachable("invalid enum");
116 }
117 
119  return llvm::StringSwitch<CudaVirtualArch>(S)
120  .Case("compute_20", CudaVirtualArch::COMPUTE_20)
121  .Case("compute_30", CudaVirtualArch::COMPUTE_30)
122  .Case("compute_32", CudaVirtualArch::COMPUTE_32)
123  .Case("compute_35", CudaVirtualArch::COMPUTE_35)
124  .Case("compute_37", CudaVirtualArch::COMPUTE_37)
125  .Case("compute_50", CudaVirtualArch::COMPUTE_50)
126  .Case("compute_52", CudaVirtualArch::COMPUTE_52)
127  .Case("compute_53", CudaVirtualArch::COMPUTE_53)
128  .Case("compute_60", CudaVirtualArch::COMPUTE_60)
129  .Case("compute_61", CudaVirtualArch::COMPUTE_61)
130  .Case("compute_62", CudaVirtualArch::COMPUTE_62)
131  .Case("compute_70", CudaVirtualArch::COMPUTE_70)
132  .Case("compute_72", CudaVirtualArch::COMPUTE_72)
133  .Default(CudaVirtualArch::UNKNOWN);
134 }
135 
137  switch (A) {
138  case CudaArch::LAST:
139  break;
140  case CudaArch::UNKNOWN:
142  case CudaArch::SM_20:
143  case CudaArch::SM_21:
145  case CudaArch::SM_30:
147  case CudaArch::SM_32:
149  case CudaArch::SM_35:
151  case CudaArch::SM_37:
153  case CudaArch::SM_50:
155  case CudaArch::SM_52:
157  case CudaArch::SM_53:
159  case CudaArch::SM_60:
161  case CudaArch::SM_61:
163  case CudaArch::SM_62:
165  case CudaArch::SM_70:
167  case CudaArch::SM_72:
169  }
170  llvm_unreachable("invalid enum");
171 }
172 
174  switch (A) {
175  case CudaArch::LAST:
176  break;
177  case CudaArch::UNKNOWN:
178  return CudaVersion::UNKNOWN;
179  case CudaArch::SM_20:
180  case CudaArch::SM_21:
181  case CudaArch::SM_30:
182  case CudaArch::SM_32:
183  case CudaArch::SM_35:
184  case CudaArch::SM_37:
185  case CudaArch::SM_50:
186  case CudaArch::SM_52:
187  case CudaArch::SM_53:
188  return CudaVersion::CUDA_70;
189  case CudaArch::SM_60:
190  case CudaArch::SM_61:
191  case CudaArch::SM_62:
192  return CudaVersion::CUDA_80;
193  case CudaArch::SM_70:
194  return CudaVersion::CUDA_90;
195  case CudaArch::SM_72:
196  return CudaVersion::CUDA_91;
197  }
198  llvm_unreachable("invalid enum");
199 }
200 
202  switch (A) {
203  case CudaArch::UNKNOWN:
204  return CudaVersion::UNKNOWN;
205  case CudaArch::SM_20:
206  case CudaArch::SM_21:
207  return CudaVersion::CUDA_80;
208  default:
209  return CudaVersion::LATEST;
210  }
211 }
212 
213 } // namespace clang
CudaVirtualArch StringToCudaVirtualArch(llvm::StringRef S)
Definition: Cuda.cpp:118
CudaArch
Definition: Cuda.h:33
const char * CudaArchToString(CudaArch A)
Definition: Cuda.cpp:27
CudaArch StringToCudaArch(llvm::StringRef S)
Definition: Cuda.cpp:65
const char * CudaVersionToString(CudaVersion V)
Definition: Cuda.cpp:9
const char * CudaVirtualArchToString(CudaVirtualArch A)
Definition: Cuda.cpp:84
CudaVersion MaxVersionForCudaArch(CudaArch A)
Get the latest CudaVersion that supports the given CudaArch.
Definition: Cuda.cpp:201
CudaVersion
Definition: Cuda.h:19
CudaVirtualArch
Definition: Cuda.h:56
CudaVersion MinVersionForCudaArch(CudaArch A)
Get the earliest CudaVersion that supports the given CudaArch.
Definition: Cuda.cpp:173
Dataflow Directional Tag Classes.
CudaVirtualArch VirtualArchForCudaArch(CudaArch A)
Get the compute_xx corresponding to an sm_yy.
Definition: Cuda.cpp:136