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";
24  return "9.2";
25  }
26  llvm_unreachable("invalid enum");
27 }
28 
29 const char *CudaArchToString(CudaArch A) {
30  switch (A) {
31  case CudaArch::LAST:
32  break;
33  case CudaArch::UNKNOWN:
34  return "unknown";
35  case CudaArch::SM_20:
36  return "sm_20";
37  case CudaArch::SM_21:
38  return "sm_21";
39  case CudaArch::SM_30:
40  return "sm_30";
41  case CudaArch::SM_32:
42  return "sm_32";
43  case CudaArch::SM_35:
44  return "sm_35";
45  case CudaArch::SM_37:
46  return "sm_37";
47  case CudaArch::SM_50:
48  return "sm_50";
49  case CudaArch::SM_52:
50  return "sm_52";
51  case CudaArch::SM_53:
52  return "sm_53";
53  case CudaArch::SM_60:
54  return "sm_60";
55  case CudaArch::SM_61:
56  return "sm_61";
57  case CudaArch::SM_62:
58  return "sm_62";
59  case CudaArch::SM_70:
60  return "sm_70";
61  case CudaArch::SM_72:
62  return "sm_72";
63  case CudaArch::GFX600: // tahiti
64  return "gfx600";
65  case CudaArch::GFX601: // pitcairn, verde, oland,hainan
66  return "gfx601";
67  case CudaArch::GFX700: // kaveri
68  return "gfx700";
69  case CudaArch::GFX701: // hawaii
70  return "gfx701";
71  case CudaArch::GFX702: // 290,290x,R390,R390x
72  return "gfx702";
73  case CudaArch::GFX703: // kabini mullins
74  return "gfx703";
75  case CudaArch::GFX704: // bonaire
76  return "gfx704";
77  case CudaArch::GFX801: // carrizo
78  return "gfx801";
79  case CudaArch::GFX802: // tonga,iceland
80  return "gfx802";
81  case CudaArch::GFX803: // fiji,polaris10
82  return "gfx803";
83  case CudaArch::GFX810: // stoney
84  return "gfx810";
85  case CudaArch::GFX900: // vega, instinct
86  return "gfx900";
87  case CudaArch::GFX902: // TBA
88  return "gfx902";
89  }
90  llvm_unreachable("invalid enum");
91 }
92 
93 CudaArch StringToCudaArch(llvm::StringRef S) {
94  return llvm::StringSwitch<CudaArch>(S)
95  .Case("sm_20", CudaArch::SM_20)
96  .Case("sm_21", CudaArch::SM_21)
97  .Case("sm_30", CudaArch::SM_30)
98  .Case("sm_32", CudaArch::SM_32)
99  .Case("sm_35", CudaArch::SM_35)
100  .Case("sm_37", CudaArch::SM_37)
101  .Case("sm_50", CudaArch::SM_50)
102  .Case("sm_52", CudaArch::SM_52)
103  .Case("sm_53", CudaArch::SM_53)
104  .Case("sm_60", CudaArch::SM_60)
105  .Case("sm_61", CudaArch::SM_61)
106  .Case("sm_62", CudaArch::SM_62)
107  .Case("sm_70", CudaArch::SM_70)
108  .Case("sm_72", CudaArch::SM_72)
109  .Case("gfx600", CudaArch::GFX600)
110  .Case("gfx601", CudaArch::GFX601)
111  .Case("gfx700", CudaArch::GFX700)
112  .Case("gfx701", CudaArch::GFX701)
113  .Case("gfx702", CudaArch::GFX702)
114  .Case("gfx703", CudaArch::GFX703)
115  .Case("gfx704", CudaArch::GFX704)
116  .Case("gfx801", CudaArch::GFX801)
117  .Case("gfx802", CudaArch::GFX802)
118  .Case("gfx803", CudaArch::GFX803)
119  .Case("gfx810", CudaArch::GFX810)
120  .Case("gfx900", CudaArch::GFX900)
121  .Case("gfx902", CudaArch::GFX902)
122  .Default(CudaArch::UNKNOWN);
123 }
124 
126  switch (A) {
128  return "unknown";
130  return "compute_20";
132  return "compute_30";
134  return "compute_32";
136  return "compute_35";
138  return "compute_37";
140  return "compute_50";
142  return "compute_52";
144  return "compute_53";
146  return "compute_60";
148  return "compute_61";
150  return "compute_62";
152  return "compute_70";
154  return "compute_72";
156  return "compute_amdgcn";
157  }
158  llvm_unreachable("invalid enum");
159 }
160 
162  return llvm::StringSwitch<CudaVirtualArch>(S)
163  .Case("compute_20", CudaVirtualArch::COMPUTE_20)
164  .Case("compute_30", CudaVirtualArch::COMPUTE_30)
165  .Case("compute_32", CudaVirtualArch::COMPUTE_32)
166  .Case("compute_35", CudaVirtualArch::COMPUTE_35)
167  .Case("compute_37", CudaVirtualArch::COMPUTE_37)
168  .Case("compute_50", CudaVirtualArch::COMPUTE_50)
169  .Case("compute_52", CudaVirtualArch::COMPUTE_52)
170  .Case("compute_53", CudaVirtualArch::COMPUTE_53)
171  .Case("compute_60", CudaVirtualArch::COMPUTE_60)
172  .Case("compute_61", CudaVirtualArch::COMPUTE_61)
173  .Case("compute_62", CudaVirtualArch::COMPUTE_62)
174  .Case("compute_70", CudaVirtualArch::COMPUTE_70)
175  .Case("compute_72", CudaVirtualArch::COMPUTE_72)
176  .Case("compute_amdgcn", CudaVirtualArch::COMPUTE_AMDGCN)
177  .Default(CudaVirtualArch::UNKNOWN);
178 }
179 
181  switch (A) {
182  case CudaArch::LAST:
183  break;
184  case CudaArch::UNKNOWN:
186  case CudaArch::SM_20:
187  case CudaArch::SM_21:
189  case CudaArch::SM_30:
191  case CudaArch::SM_32:
193  case CudaArch::SM_35:
195  case CudaArch::SM_37:
197  case CudaArch::SM_50:
199  case CudaArch::SM_52:
201  case CudaArch::SM_53:
203  case CudaArch::SM_60:
205  case CudaArch::SM_61:
207  case CudaArch::SM_62:
209  case CudaArch::SM_70:
211  case CudaArch::SM_72:
213  case CudaArch::GFX600:
214  case CudaArch::GFX601:
215  case CudaArch::GFX700:
216  case CudaArch::GFX701:
217  case CudaArch::GFX702:
218  case CudaArch::GFX703:
219  case CudaArch::GFX704:
220  case CudaArch::GFX801:
221  case CudaArch::GFX802:
222  case CudaArch::GFX803:
223  case CudaArch::GFX810:
224  case CudaArch::GFX900:
225  case CudaArch::GFX902:
227  }
228  llvm_unreachable("invalid enum");
229 }
230 
232  switch (A) {
233  case CudaArch::LAST:
234  break;
235  case CudaArch::UNKNOWN:
236  return CudaVersion::UNKNOWN;
237  case CudaArch::SM_20:
238  case CudaArch::SM_21:
239  case CudaArch::SM_30:
240  case CudaArch::SM_32:
241  case CudaArch::SM_35:
242  case CudaArch::SM_37:
243  case CudaArch::SM_50:
244  case CudaArch::SM_52:
245  case CudaArch::SM_53:
246  return CudaVersion::CUDA_70;
247  case CudaArch::SM_60:
248  case CudaArch::SM_61:
249  case CudaArch::SM_62:
250  return CudaVersion::CUDA_80;
251  case CudaArch::SM_70:
252  return CudaVersion::CUDA_90;
253  case CudaArch::SM_72:
254  return CudaVersion::CUDA_91;
255  case CudaArch::GFX600:
256  case CudaArch::GFX601:
257  case CudaArch::GFX700:
258  case CudaArch::GFX701:
259  case CudaArch::GFX702:
260  case CudaArch::GFX703:
261  case CudaArch::GFX704:
262  case CudaArch::GFX801:
263  case CudaArch::GFX802:
264  case CudaArch::GFX803:
265  case CudaArch::GFX810:
266  case CudaArch::GFX900:
267  case CudaArch::GFX902:
268  return CudaVersion::CUDA_70;
269  }
270  llvm_unreachable("invalid enum");
271 }
272 
274  switch (A) {
275  case CudaArch::UNKNOWN:
276  return CudaVersion::UNKNOWN;
277  case CudaArch::SM_20:
278  case CudaArch::SM_21:
279  case CudaArch::GFX600:
280  case CudaArch::GFX601:
281  case CudaArch::GFX700:
282  case CudaArch::GFX701:
283  case CudaArch::GFX702:
284  case CudaArch::GFX703:
285  case CudaArch::GFX704:
286  case CudaArch::GFX801:
287  case CudaArch::GFX802:
288  case CudaArch::GFX803:
289  case CudaArch::GFX810:
290  case CudaArch::GFX900:
291  case CudaArch::GFX902:
292  return CudaVersion::CUDA_80;
293  default:
294  return CudaVersion::LATEST;
295  }
296 }
297 
298 } // namespace clang
CudaVirtualArch StringToCudaVirtualArch(llvm::StringRef S)
Definition: Cuda.cpp:161
CudaArch
Definition: Cuda.h:34
const char * CudaArchToString(CudaArch A)
Definition: Cuda.cpp:29
CudaArch StringToCudaArch(llvm::StringRef S)
Definition: Cuda.cpp:93
const char * CudaVersionToString(CudaVersion V)
Definition: Cuda.cpp:9
const char * CudaVirtualArchToString(CudaVirtualArch A)
Definition: Cuda.cpp:125
CudaVersion MaxVersionForCudaArch(CudaArch A)
Get the latest CudaVersion that supports the given CudaArch.
Definition: Cuda.cpp:273
CudaVersion
Definition: Cuda.h:19
CudaVirtualArch
Definition: Cuda.h:70
CudaVersion MinVersionForCudaArch(CudaArch A)
Get the earliest CudaVersion that supports the given CudaArch.
Definition: Cuda.cpp:231
Dataflow Directional Tag Classes.
CudaVirtualArch VirtualArchForCudaArch(CudaArch A)
Get the compute_xx corresponding to an sm_yy.
Definition: Cuda.cpp:180