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