1 //===--- Cuda.h - Utilities for compiling CUDA code ------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_BASIC_CUDA_H
10 #define LLVM_CLANG_BASIC_CUDA_H
20 enum class CudaVersion {
42 FULLY_SUPPORTED = CUDA_118,
44 CUDA_121, // Partially supported. Proceed with a warning.
45 NEW = 10000, // Too new. Issue a warning, but allow using it.
47 const char *CudaVersionToString(CudaVersion V);
48 // Input is "Major.Minor"
49 CudaVersion CudaStringToVersion(const llvm::Twine &S);
116 Generic, // A processor model named 'generic' if the target backend defines a
120 CudaDefault = CudaArch::SM_35,
121 HIPDefault = CudaArch::GFX803,
124 static inline bool IsNVIDIAGpuArch(CudaArch A) {
125 return A >= CudaArch::SM_20 && A < CudaArch::GFX600;
128 static inline bool IsAMDGpuArch(CudaArch A) {
129 // Generic processor model is for testing only.
130 return A >= CudaArch::GFX600 && A < CudaArch::Generic;
133 const char *CudaArchToString(CudaArch A);
134 const char *CudaArchToVirtualArchString(CudaArch A);
136 // The input should have the form "sm_20".
137 CudaArch StringToCudaArch(llvm::StringRef S);
139 /// Get the earliest CudaVersion that supports the given CudaArch.
140 CudaVersion MinVersionForCudaArch(CudaArch A);
142 /// Get the latest CudaVersion that supports the given CudaArch.
143 CudaVersion MaxVersionForCudaArch(CudaArch A);
145 // Various SDK-dependent features that affect CUDA compilation
146 enum class CudaFeature {
147 // CUDA-9.2+ uses a new API for launching kernels.
148 CUDA_USES_NEW_LAUNCH,
149 // CUDA-10.1+ needs explicit end of GPU binary registration.
150 CUDA_USES_FATBIN_REGISTER_END,
153 CudaVersion ToCudaVersion(llvm::VersionTuple);
154 bool CudaFeatureEnabled(llvm::VersionTuple, CudaFeature);
155 bool CudaFeatureEnabled(CudaVersion, CudaFeature);