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