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