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 SM_20,
57 SM_21,
58 SM_30,
59 SM_32,
60 SM_35,
61 SM_37,
62 SM_50,
63 SM_52,
64 SM_53,
65 SM_60,
66 SM_61,
67 SM_62,
68 SM_70,
69 SM_72,
70 SM_75,
71 SM_80,
72 SM_86,
73 SM_87,
74 SM_89,
75 SM_90,
76 SM_90a,
77 GFX600,
78 GFX601,
79 GFX602,
80 GFX700,
81 GFX701,
82 GFX702,
83 GFX703,
84 GFX704,
85 GFX705,
86 GFX801,
87 GFX802,
88 GFX803,
89 GFX805,
90 GFX810,
91 GFX900,
92 GFX902,
93 GFX904,
94 GFX906,
95 GFX908,
96 GFX909,
97 GFX90a,
98 GFX90c,
99 GFX940,
100 GFX941,
101 GFX942,
102 GFX1010,
103 GFX1011,
104 GFX1012,
105 GFX1013,
106 GFX1030,
107 GFX1031,
108 GFX1032,
109 GFX1033,
110 GFX1034,
111 GFX1035,
112 GFX1036,
113 GFX1100,
114 GFX1101,
115 GFX1102,
116 GFX1103,
117 GFX1150,
118 GFX1151,
119 GFX1200,
120 GFX1201,
121 Generic, // A processor model named 'generic' if the target backend defines a
122 // public one.
123 LAST,
124
127};
128
129static inline bool IsNVIDIAGpuArch(CudaArch A) {
130 return A >= CudaArch::SM_20 && A < CudaArch::GFX600;
131}
132
133static inline bool IsAMDGpuArch(CudaArch A) {
134 // Generic processor model is for testing only.
135 return A >= CudaArch::GFX600 && A < CudaArch::Generic;
136}
137
138const char *CudaArchToString(CudaArch A);
140
141// The input should have the form "sm_20".
142CudaArch StringToCudaArch(llvm::StringRef S);
143
144/// Get the earliest CudaVersion that supports the given CudaArch.
146
147/// Get the latest CudaVersion that supports the given CudaArch.
149
150// Various SDK-dependent features that affect CUDA compilation
151enum class CudaFeature {
152 // CUDA-9.2+ uses a new API for launching kernels.
154 // CUDA-10.1+ needs explicit end of GPU binary registration.
156};
157
158CudaVersion ToCudaVersion(llvm::VersionTuple);
159bool CudaFeatureEnabled(llvm::VersionTuple, CudaFeature);
161
162} // namespace clang
163
164#endif
#define V(N, I)
Definition: ASTContext.h:3259
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
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:133
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:129
const char * CudaVersionToString(CudaVersion V)
Definition: Cuda.cpp:49
CudaVersion
Definition: Cuda.h:20
CudaFeature
Definition: Cuda.h:151
@ Generic
not a target-specific vector type
const char * CudaArchToString(CudaArch A)
Definition: Cuda.cpp:150
YAML serialization mapping.
Definition: Dominators.h:30