xref: /freebsd/contrib/llvm-project/clang/include/clang/Basic/Cuda.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
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 
12 #include "clang/Basic/OffloadArch.h"
13 
14 namespace llvm {
15 class StringRef;
16 class Twine;
17 class VersionTuple;
18 } // namespace llvm
19 
20 namespace clang {
21 
22 enum class CudaVersion {
23   UNKNOWN,
24   CUDA_70,
25   CUDA_75,
26   CUDA_80,
27   CUDA_90,
28   CUDA_91,
29   CUDA_92,
30   CUDA_100,
31   CUDA_101,
32   CUDA_102,
33   CUDA_110,
34   CUDA_111,
35   CUDA_112,
36   CUDA_113,
37   CUDA_114,
38   CUDA_115,
39   CUDA_116,
40   CUDA_117,
41   CUDA_118,
42   CUDA_120,
43   CUDA_121,
44   CUDA_122,
45   CUDA_123,
46   CUDA_124,
47   CUDA_125,
48   CUDA_126,
49   CUDA_128,
50   FULLY_SUPPORTED = CUDA_123,
51   PARTIALLY_SUPPORTED =
52       CUDA_128, // Partially supported. Proceed with a warning.
53   NEW = 10000,  // Too new. Issue a warning, but allow using it.
54 };
55 const char *CudaVersionToString(CudaVersion V);
56 // Input is "Major.Minor"
57 CudaVersion CudaStringToVersion(const llvm::Twine &S);
58 
59 enum class CUDAFunctionTarget {
60   Device,
61   Global,
62   Host,
63   HostDevice,
64   InvalidTarget
65 };
66 
67 /// Get the earliest CudaVersion that supports the given OffloadArch.
68 CudaVersion MinVersionForOffloadArch(OffloadArch A);
69 
70 /// Get the latest CudaVersion that supports the given OffloadArch.
71 CudaVersion MaxVersionForOffloadArch(OffloadArch A);
72 
73 //  Various SDK-dependent features that affect CUDA compilation
74 enum class CudaFeature {
75   // CUDA-9.2+ uses a new API for launching kernels.
76   CUDA_USES_NEW_LAUNCH,
77   // CUDA-10.1+ needs explicit end of GPU binary registration.
78   CUDA_USES_FATBIN_REGISTER_END,
79 };
80 
81 CudaVersion ToCudaVersion(llvm::VersionTuple);
82 bool CudaFeatureEnabled(llvm::VersionTuple, CudaFeature);
83 bool CudaFeatureEnabled(CudaVersion, CudaFeature);
84 
85 } // namespace clang
86 
87 #endif
88