clang  8.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";
26  return "10.0";
27  }
28  llvm_unreachable("invalid enum");
29 }
30 
31 const char *CudaArchToString(CudaArch A) {
32  switch (A) {
33  case CudaArch::LAST:
34  break;
35  case CudaArch::UNKNOWN:
36  return "unknown";
37  case CudaArch::SM_20:
38  return "sm_20";
39  case CudaArch::SM_21:
40  return "sm_21";
41  case CudaArch::SM_30:
42  return "sm_30";
43  case CudaArch::SM_32:
44  return "sm_32";
45  case CudaArch::SM_35:
46  return "sm_35";
47  case CudaArch::SM_37:
48  return "sm_37";
49  case CudaArch::SM_50:
50  return "sm_50";
51  case CudaArch::SM_52:
52  return "sm_52";
53  case CudaArch::SM_53:
54  return "sm_53";
55  case CudaArch::SM_60:
56  return "sm_60";
57  case CudaArch::SM_61:
58  return "sm_61";
59  case CudaArch::SM_62:
60  return "sm_62";
61  case CudaArch::SM_70:
62  return "sm_70";
63  case CudaArch::SM_72:
64  return "sm_72";
65  case CudaArch::SM_75:
66  return "sm_75";
67  case CudaArch::GFX600: // tahiti
68  return "gfx600";
69  case CudaArch::GFX601: // pitcairn, verde, oland,hainan
70  return "gfx601";
71  case CudaArch::GFX700: // kaveri
72  return "gfx700";
73  case CudaArch::GFX701: // hawaii
74  return "gfx701";
75  case CudaArch::GFX702: // 290,290x,R390,R390x
76  return "gfx702";
77  case CudaArch::GFX703: // kabini mullins
78  return "gfx703";
79  case CudaArch::GFX704: // bonaire
80  return "gfx704";
81  case CudaArch::GFX801: // carrizo
82  return "gfx801";
83  case CudaArch::GFX802: // tonga,iceland
84  return "gfx802";
85  case CudaArch::GFX803: // fiji,polaris10
86  return "gfx803";
87  case CudaArch::GFX810: // stoney
88  return "gfx810";
89  case CudaArch::GFX900: // vega, instinct
90  return "gfx900";
91  case CudaArch::GFX902: // TBA
92  return "gfx902";
93  case CudaArch::GFX904: // TBA
94  return "gfx904";
95  case CudaArch::GFX906: // TBA
96  return "gfx906";
97  case CudaArch::GFX909: // TBA
98  return "gfx909";
99  }
100  llvm_unreachable("invalid enum");
101 }
102 
103 CudaArch StringToCudaArch(llvm::StringRef S) {
104  return llvm::StringSwitch<CudaArch>(S)
105  .Case("sm_20", CudaArch::SM_20)
106  .Case("sm_21", CudaArch::SM_21)
107  .Case("sm_30", CudaArch::SM_30)
108  .Case("sm_32", CudaArch::SM_32)
109  .Case("sm_35", CudaArch::SM_35)
110  .Case("sm_37", CudaArch::SM_37)
111  .Case("sm_50", CudaArch::SM_50)
112  .Case("sm_52", CudaArch::SM_52)
113  .Case("sm_53", CudaArch::SM_53)
114  .Case("sm_60", CudaArch::SM_60)
115  .Case("sm_61", CudaArch::SM_61)
116  .Case("sm_62", CudaArch::SM_62)
117  .Case("sm_70", CudaArch::SM_70)
118  .Case("sm_72", CudaArch::SM_72)
119  .Case("sm_75", CudaArch::SM_75)
120  .Case("gfx600", CudaArch::GFX600)
121  .Case("gfx601", CudaArch::GFX601)
122  .Case("gfx700", CudaArch::GFX700)
123  .Case("gfx701", CudaArch::GFX701)
124  .Case("gfx702", CudaArch::GFX702)
125  .Case("gfx703", CudaArch::GFX703)
126  .Case("gfx704", CudaArch::GFX704)
127  .Case("gfx801", CudaArch::GFX801)
128  .Case("gfx802", CudaArch::GFX802)
129  .Case("gfx803", CudaArch::GFX803)
130  .Case("gfx810", CudaArch::GFX810)
131  .Case("gfx900", CudaArch::GFX900)
132  .Case("gfx902", CudaArch::GFX902)
133  .Case("gfx904", CudaArch::GFX904)
134  .Case("gfx906", CudaArch::GFX906)
135  .Case("gfx909", CudaArch::GFX909)
136  .Default(CudaArch::UNKNOWN);
137 }
138 
140  switch (A) {
142  return "unknown";
144  return "compute_20";
146  return "compute_30";
148  return "compute_32";
150  return "compute_35";
152  return "compute_37";
154  return "compute_50";
156  return "compute_52";
158  return "compute_53";
160  return "compute_60";
162  return "compute_61";
164  return "compute_62";
166  return "compute_70";
168  return "compute_72";
170  return "compute_75";
172  return "compute_amdgcn";
173  }
174  llvm_unreachable("invalid enum");
175 }
176 
178  return llvm::StringSwitch<CudaVirtualArch>(S)
179  .Case("compute_20", CudaVirtualArch::COMPUTE_20)
180  .Case("compute_30", CudaVirtualArch::COMPUTE_30)
181  .Case("compute_32", CudaVirtualArch::COMPUTE_32)
182  .Case("compute_35", CudaVirtualArch::COMPUTE_35)
183  .Case("compute_37", CudaVirtualArch::COMPUTE_37)
184  .Case("compute_50", CudaVirtualArch::COMPUTE_50)
185  .Case("compute_52", CudaVirtualArch::COMPUTE_52)
186  .Case("compute_53", CudaVirtualArch::COMPUTE_53)
187  .Case("compute_60", CudaVirtualArch::COMPUTE_60)
188  .Case("compute_61", CudaVirtualArch::COMPUTE_61)
189  .Case("compute_62", CudaVirtualArch::COMPUTE_62)
190  .Case("compute_70", CudaVirtualArch::COMPUTE_70)
191  .Case("compute_72", CudaVirtualArch::COMPUTE_72)
192  .Case("compute_75", CudaVirtualArch::COMPUTE_75)
193  .Case("compute_amdgcn", CudaVirtualArch::COMPUTE_AMDGCN)
194  .Default(CudaVirtualArch::UNKNOWN);
195 }
196 
198  switch (A) {
199  case CudaArch::LAST:
200  break;
201  case CudaArch::UNKNOWN:
203  case CudaArch::SM_20:
204  case CudaArch::SM_21:
206  case CudaArch::SM_30:
208  case CudaArch::SM_32:
210  case CudaArch::SM_35:
212  case CudaArch::SM_37:
214  case CudaArch::SM_50:
216  case CudaArch::SM_52:
218  case CudaArch::SM_53:
220  case CudaArch::SM_60:
222  case CudaArch::SM_61:
224  case CudaArch::SM_62:
226  case CudaArch::SM_70:
228  case CudaArch::SM_72:
230  case CudaArch::SM_75:
232  case CudaArch::GFX600:
233  case CudaArch::GFX601:
234  case CudaArch::GFX700:
235  case CudaArch::GFX701:
236  case CudaArch::GFX702:
237  case CudaArch::GFX703:
238  case CudaArch::GFX704:
239  case CudaArch::GFX801:
240  case CudaArch::GFX802:
241  case CudaArch::GFX803:
242  case CudaArch::GFX810:
243  case CudaArch::GFX900:
244  case CudaArch::GFX902:
245  case CudaArch::GFX904:
246  case CudaArch::GFX906:
247  case CudaArch::GFX909:
249  }
250  llvm_unreachable("invalid enum");
251 }
252 
254  switch (A) {
255  case CudaArch::LAST:
256  break;
257  case CudaArch::UNKNOWN:
258  return CudaVersion::UNKNOWN;
259  case CudaArch::SM_20:
260  case CudaArch::SM_21:
261  case CudaArch::SM_30:
262  case CudaArch::SM_32:
263  case CudaArch::SM_35:
264  case CudaArch::SM_37:
265  case CudaArch::SM_50:
266  case CudaArch::SM_52:
267  case CudaArch::SM_53:
268  return CudaVersion::CUDA_70;
269  case CudaArch::SM_60:
270  case CudaArch::SM_61:
271  case CudaArch::SM_62:
272  return CudaVersion::CUDA_80;
273  case CudaArch::SM_70:
274  return CudaVersion::CUDA_90;
275  case CudaArch::SM_72:
276  return CudaVersion::CUDA_91;
277  case CudaArch::SM_75:
278  return CudaVersion::CUDA_100;
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  case CudaArch::GFX904:
293  case CudaArch::GFX906:
294  case CudaArch::GFX909:
295  return CudaVersion::CUDA_70;
296  }
297  llvm_unreachable("invalid enum");
298 }
299 
301  switch (A) {
302  case CudaArch::UNKNOWN:
303  return CudaVersion::UNKNOWN;
304  case CudaArch::SM_20:
305  case CudaArch::SM_21:
306  case CudaArch::GFX600:
307  case CudaArch::GFX601:
308  case CudaArch::GFX700:
309  case CudaArch::GFX701:
310  case CudaArch::GFX702:
311  case CudaArch::GFX703:
312  case CudaArch::GFX704:
313  case CudaArch::GFX801:
314  case CudaArch::GFX802:
315  case CudaArch::GFX803:
316  case CudaArch::GFX810:
317  case CudaArch::GFX900:
318  case CudaArch::GFX902:
319  return CudaVersion::CUDA_80;
320  default:
321  return CudaVersion::LATEST;
322  }
323 }
324 
325 } // namespace clang
CudaVirtualArch StringToCudaVirtualArch(llvm::StringRef S)
Definition: Cuda.cpp:177
CudaArch
Definition: Cuda.h:35
const char * CudaArchToString(CudaArch A)
Definition: Cuda.cpp:31
CudaArch StringToCudaArch(llvm::StringRef S)
Definition: Cuda.cpp:103
const char * CudaVersionToString(CudaVersion V)
Definition: Cuda.cpp:9
const char * CudaVirtualArchToString(CudaVirtualArch A)
Definition: Cuda.cpp:139
CudaVersion MaxVersionForCudaArch(CudaArch A)
Get the latest CudaVersion that supports the given CudaArch.
Definition: Cuda.cpp:300
CudaVersion
Definition: Cuda.h:19
CudaVirtualArch
Definition: Cuda.h:75
CudaVersion MinVersionForCudaArch(CudaArch A)
Get the earliest CudaVersion that supports the given CudaArch.
Definition: Cuda.cpp:253
Dataflow Directional Tag Classes.
CudaVirtualArch VirtualArchForCudaArch(CudaArch A)
Get the compute_xx corresponding to an sm_yy.
Definition: Cuda.cpp:197