clang 20.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
12namespace llvm {
13class StringRef;
14class Twine;
15class VersionTuple;
16} // namespace llvm
17
18namespace clang {
19
20enum class CudaVersion {
21 UNKNOWN,
22 CUDA_70,
23 CUDA_75,
24 CUDA_80,
25 CUDA_90,
26 CUDA_91,
27 CUDA_92,
49 CUDA_126, // Partially supported. Proceed with a warning.
50 NEW = 10000, // Too new. Issue a warning, but allow using it.
51};
53// Input is "Major.Minor"
54CudaVersion CudaStringToVersion(const llvm::Twine &S);
55
56enum class OffloadArch {
57 UNUSED,
58 UNKNOWN,
59 // TODO: Deprecate and remove GPU architectures older than sm_52.
60 SM_20,
61 SM_21,
62 SM_30,
63 // This has a name conflict with sys/mac.h on AIX, rename it as a workaround.
64 SM_32_,
65 SM_35,
66 SM_37,
67 SM_50,
68 SM_52,
69 SM_53,
70 SM_60,
71 SM_61,
72 SM_62,
73 SM_70,
74 SM_72,
75 SM_75,
76 SM_80,
77 SM_86,
78 SM_87,
79 SM_89,
80 SM_90,
81 SM_90a,
82 SM_100,
83 GFX600,
84 GFX601,
85 GFX602,
86 GFX700,
87 GFX701,
88 GFX702,
89 GFX703,
90 GFX704,
91 GFX705,
92 GFX801,
93 GFX802,
94 GFX803,
95 GFX805,
96 GFX810,
98 GFX900,
99 GFX902,
100 GFX904,
101 GFX906,
102 GFX908,
103 GFX909,
104 GFX90a,
105 GFX90c,
107 GFX940,
108 GFX941,
109 GFX942,
110 GFX950,
112 GFX1010,
113 GFX1011,
114 GFX1012,
115 GFX1013,
117 GFX1030,
118 GFX1031,
119 GFX1032,
120 GFX1033,
121 GFX1034,
122 GFX1035,
123 GFX1036,
125 GFX1100,
126 GFX1101,
127 GFX1102,
128 GFX1103,
129 GFX1150,
130 GFX1151,
131 GFX1152,
132 GFX1153,
134 GFX1200,
135 GFX1201,
137 Generic, // A processor model named 'generic' if the target backend defines a
138 // public one.
139 LAST,
140
143};
144
146 Device,
147 Global,
148 Host,
151};
152
153static inline bool IsNVIDIAOffloadArch(OffloadArch A) {
154 return A >= OffloadArch::SM_20 && A < OffloadArch::GFX600;
155}
156
157static inline bool IsAMDOffloadArch(OffloadArch A) {
158 // Generic processor model is for testing only.
159 return A >= OffloadArch::GFX600 && A < OffloadArch::Generic;
160}
161
162const char *OffloadArchToString(OffloadArch A);
164
165// The input should have the form "sm_20".
166OffloadArch StringToOffloadArch(llvm::StringRef S);
167
168/// Get the earliest CudaVersion that supports the given OffloadArch.
170
171/// Get the latest CudaVersion that supports the given OffloadArch.
173
174// Various SDK-dependent features that affect CUDA compilation
175enum class CudaFeature {
176 // CUDA-9.2+ uses a new API for launching kernels.
178 // CUDA-10.1+ needs explicit end of GPU binary registration.
180};
181
182CudaVersion ToCudaVersion(llvm::VersionTuple);
183bool CudaFeatureEnabled(llvm::VersionTuple, CudaFeature);
185
186} // namespace clang
187
188#endif
#define V(N, I)
Definition: ASTContext.h:3443
The JSON file list parser is used to communicate input to InstallAPI.
CudaVersion MaxVersionForOffloadArch(OffloadArch A)
Get the latest CudaVersion that supports the given OffloadArch.
Definition: Cuda.cpp:237
CUDAFunctionTarget
Definition: Cuda.h:145
static bool IsAMDOffloadArch(OffloadArch A)
Definition: Cuda.h:157
OffloadArch
Definition: Cuda.h:56
CudaVersion ToCudaVersion(llvm::VersionTuple)
Definition: Cuda.cpp:68
CudaVersion CudaStringToVersion(const llvm::Twine &S)
Definition: Cuda.cpp:60
bool CudaFeatureEnabled(llvm::VersionTuple, CudaFeature)
Definition: Cuda.cpp:259
static bool IsNVIDIAOffloadArch(OffloadArch A)
Definition: Cuda.h:153
const char * CudaVersionToString(CudaVersion V)
Definition: Cuda.cpp:52
const char * OffloadArchToVirtualArchString(OffloadArch A)
Definition: Cuda.cpp:171
OffloadArch StringToOffloadArch(llvm::StringRef S)
Definition: Cuda.cpp:180
CudaVersion
Definition: Cuda.h:20
CudaFeature
Definition: Cuda.h:175
const char * OffloadArchToString(OffloadArch A)
Definition: Cuda.cpp:162
CudaVersion MinVersionForOffloadArch(OffloadArch A)
Get the earliest CudaVersion that supports the given OffloadArch.
Definition: Cuda.cpp:189
@ Generic
not a target-specific vector type
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30