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