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 {
33 LATEST_SUPPORTED = CUDA_101,
35 const char *CudaVersionToString(CudaVersion V);
36 // Input is "Major.Minor"
37 CudaVersion CudaStringToVersion(const llvm::Twine &S);
81 static inline bool IsNVIDIAGpuArch(CudaArch A) {
82 return A >= CudaArch::SM_20 && A < CudaArch::GFX600;
85 static inline bool IsAMDGpuArch(CudaArch A) {
86 return A >= CudaArch::GFX600 && A < CudaArch::LAST;
89 const char *CudaArchToString(CudaArch A);
90 const char *CudaArchToVirtualArchString(CudaArch A);
92 // The input should have the form "sm_20".
93 CudaArch StringToCudaArch(llvm::StringRef S);
95 /// Get the earliest CudaVersion that supports the given CudaArch.
96 CudaVersion MinVersionForCudaArch(CudaArch A);
98 /// Get the latest CudaVersion that supports the given CudaArch.
99 CudaVersion MaxVersionForCudaArch(CudaArch A);
101 // Various SDK-dependent features that affect CUDA compilation
102 enum class CudaFeature {
103 // CUDA-9.2+ uses a new API for launching kernels.
104 CUDA_USES_NEW_LAUNCH,
105 // CUDA-10.1+ needs explicit end of GPU binary registration.
106 CUDA_USES_FATBIN_REGISTER_END,
109 CudaVersion ToCudaVersion(llvm::VersionTuple);
110 bool CudaFeatureEnabled(llvm::VersionTuple, CudaFeature);
111 bool CudaFeatureEnabled(CudaVersion, CudaFeature);