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 {
32 const char *CudaVersionToString(CudaVersion V);
33 // Input is "Major.Minor"
34 CudaVersion CudaStringToVersion(const llvm::Twine &S);
75 const char *CudaArchToString(CudaArch A);
77 // The input should have the form "sm_20".
78 CudaArch StringToCudaArch(llvm::StringRef S);
80 enum class CudaVirtualArch {
98 const char *CudaVirtualArchToString(CudaVirtualArch A);
100 // The input should have the form "compute_20".
101 CudaVirtualArch StringToCudaVirtualArch(llvm::StringRef S);
103 /// Get the compute_xx corresponding to an sm_yy.
104 CudaVirtualArch VirtualArchForCudaArch(CudaArch A);
106 /// Get the earliest CudaVersion that supports the given CudaArch.
107 CudaVersion MinVersionForCudaArch(CudaArch A);
109 /// Get the latest CudaVersion that supports the given CudaArch.
110 CudaVersion MaxVersionForCudaArch(CudaArch A);
112 // Various SDK-dependent features that affect CUDA compilation
113 enum class CudaFeature {
114 // CUDA-9.2+ uses a new API for launching kernels.
115 CUDA_USES_NEW_LAUNCH,
116 // CUDA-10.1+ needs explicit end of GPU binary registration.
117 CUDA_USES_FATBIN_REGISTER_END,
120 bool CudaFeatureEnabled(llvm::VersionTuple, CudaFeature);
121 bool CudaFeatureEnabled(CudaVersion, CudaFeature);