clang  6.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";
21  }
22  llvm_unreachable("invalid enum");
23 }
24 
25 const char *CudaArchToString(CudaArch A) {
26  switch (A) {
27  case CudaArch::UNKNOWN:
28  return "unknown";
29  case CudaArch::SM_20:
30  return "sm_20";
31  case CudaArch::SM_21:
32  return "sm_21";
33  case CudaArch::SM_30:
34  return "sm_30";
35  case CudaArch::SM_32:
36  return "sm_32";
37  case CudaArch::SM_35:
38  return "sm_35";
39  case CudaArch::SM_37:
40  return "sm_37";
41  case CudaArch::SM_50:
42  return "sm_50";
43  case CudaArch::SM_52:
44  return "sm_52";
45  case CudaArch::SM_53:
46  return "sm_53";
47  case CudaArch::SM_60:
48  return "sm_60";
49  case CudaArch::SM_61:
50  return "sm_61";
51  case CudaArch::SM_62:
52  return "sm_62";
53  case CudaArch::SM_70:
54  return "sm_70";
55  }
56  llvm_unreachable("invalid enum");
57 }
58 
59 CudaArch StringToCudaArch(llvm::StringRef S) {
60  return llvm::StringSwitch<CudaArch>(S)
61  .Case("sm_20", CudaArch::SM_20)
62  .Case("sm_21", CudaArch::SM_21)
63  .Case("sm_30", CudaArch::SM_30)
64  .Case("sm_32", CudaArch::SM_32)
65  .Case("sm_35", CudaArch::SM_35)
66  .Case("sm_37", CudaArch::SM_37)
67  .Case("sm_50", CudaArch::SM_50)
68  .Case("sm_52", CudaArch::SM_52)
69  .Case("sm_53", CudaArch::SM_53)
70  .Case("sm_60", CudaArch::SM_60)
71  .Case("sm_61", CudaArch::SM_61)
72  .Case("sm_62", CudaArch::SM_62)
73  .Case("sm_70", CudaArch::SM_70)
74  .Default(CudaArch::UNKNOWN);
75 }
76 
78  switch (A) {
80  return "unknown";
82  return "compute_20";
84  return "compute_30";
86  return "compute_32";
88  return "compute_35";
90  return "compute_37";
92  return "compute_50";
94  return "compute_52";
96  return "compute_53";
98  return "compute_60";
100  return "compute_61";
102  return "compute_62";
104  return "compute_70";
105  }
106  llvm_unreachable("invalid enum");
107 }
108 
110  return llvm::StringSwitch<CudaVirtualArch>(S)
111  .Case("compute_20", CudaVirtualArch::COMPUTE_20)
112  .Case("compute_30", CudaVirtualArch::COMPUTE_30)
113  .Case("compute_32", CudaVirtualArch::COMPUTE_32)
114  .Case("compute_35", CudaVirtualArch::COMPUTE_35)
115  .Case("compute_37", CudaVirtualArch::COMPUTE_37)
116  .Case("compute_50", CudaVirtualArch::COMPUTE_50)
117  .Case("compute_52", CudaVirtualArch::COMPUTE_52)
118  .Case("compute_53", CudaVirtualArch::COMPUTE_53)
119  .Case("compute_60", CudaVirtualArch::COMPUTE_60)
120  .Case("compute_61", CudaVirtualArch::COMPUTE_61)
121  .Case("compute_62", CudaVirtualArch::COMPUTE_62)
122  .Case("compute_70", CudaVirtualArch::COMPUTE_70)
123  .Default(CudaVirtualArch::UNKNOWN);
124 }
125 
127  switch (A) {
128  case CudaArch::UNKNOWN:
130  case CudaArch::SM_20:
131  case CudaArch::SM_21:
133  case CudaArch::SM_30:
135  case CudaArch::SM_32:
137  case CudaArch::SM_35:
139  case CudaArch::SM_37:
141  case CudaArch::SM_50:
143  case CudaArch::SM_52:
145  case CudaArch::SM_53:
147  case CudaArch::SM_60:
149  case CudaArch::SM_61:
151  case CudaArch::SM_62:
153  case CudaArch::SM_70:
155  }
156  llvm_unreachable("invalid enum");
157 }
158 
160  switch (A) {
161  case CudaArch::UNKNOWN:
162  return CudaVersion::UNKNOWN;
163  case CudaArch::SM_20:
164  case CudaArch::SM_21:
165  case CudaArch::SM_30:
166  case CudaArch::SM_32:
167  case CudaArch::SM_35:
168  case CudaArch::SM_37:
169  case CudaArch::SM_50:
170  case CudaArch::SM_52:
171  case CudaArch::SM_53:
172  return CudaVersion::CUDA_70;
173  case CudaArch::SM_60:
174  case CudaArch::SM_61:
175  case CudaArch::SM_62:
176  return CudaVersion::CUDA_80;
177  case CudaArch::SM_70:
178  return CudaVersion::CUDA_90;
179  }
180  llvm_unreachable("invalid enum");
181 }
182 
183 } // namespace clang
CudaVirtualArch StringToCudaVirtualArch(llvm::StringRef S)
Definition: Cuda.cpp:109
CudaArch
Definition: Cuda.h:31
const char * CudaArchToString(CudaArch A)
Definition: Cuda.cpp:25
CudaArch StringToCudaArch(llvm::StringRef S)
Definition: Cuda.cpp:59
const char * CudaVersionToString(CudaVersion V)
Definition: Cuda.cpp:9
const char * CudaVirtualArchToString(CudaVirtualArch A)
Definition: Cuda.cpp:77
CudaVersion
Definition: Cuda.h:19
CudaVirtualArch
Definition: Cuda.h:52
CudaVersion MinVersionForCudaArch(CudaArch A)
Get the earliest CudaVersion that supports the given CudaArch.
Definition: Cuda.cpp:159
Dataflow Directional Tag Classes.
CudaVirtualArch VirtualArchForCudaArch(CudaArch A)
Get the compute_xx corresponding to an sm_yy.
Definition: Cuda.cpp:126