Cuda.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===--- Cuda.h - Utilities for compiling CUDA code ------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_CLANG_BASIC_CUDA_H
  14. #define LLVM_CLANG_BASIC_CUDA_H
  15. namespace llvm {
  16. class StringRef;
  17. class Twine;
  18. class VersionTuple;
  19. } // namespace llvm
  20. namespace clang {
  21. enum class CudaVersion {
  22. UNKNOWN,
  23. CUDA_70,
  24. CUDA_75,
  25. CUDA_80,
  26. CUDA_90,
  27. CUDA_91,
  28. CUDA_92,
  29. CUDA_100,
  30. CUDA_101,
  31. CUDA_102,
  32. CUDA_110,
  33. CUDA_111,
  34. CUDA_112,
  35. CUDA_113,
  36. CUDA_114,
  37. CUDA_115,
  38. FULLY_SUPPORTED = CUDA_115,
  39. PARTIALLY_SUPPORTED =
  40. CUDA_115, // Partially supported. Proceed with a warning.
  41. NEW = 10000, // Too new. Issue a warning, but allow using it.
  42. };
  43. const char *CudaVersionToString(CudaVersion V);
  44. // Input is "Major.Minor"
  45. CudaVersion CudaStringToVersion(const llvm::Twine &S);
  46. enum class CudaArch {
  47. UNUSED,
  48. UNKNOWN,
  49. SM_20,
  50. SM_21,
  51. SM_30,
  52. SM_32,
  53. SM_35,
  54. SM_37,
  55. SM_50,
  56. SM_52,
  57. SM_53,
  58. SM_60,
  59. SM_61,
  60. SM_62,
  61. SM_70,
  62. SM_72,
  63. SM_75,
  64. SM_80,
  65. SM_86,
  66. GFX600,
  67. GFX601,
  68. GFX602,
  69. GFX700,
  70. GFX701,
  71. GFX702,
  72. GFX703,
  73. GFX704,
  74. GFX705,
  75. GFX801,
  76. GFX802,
  77. GFX803,
  78. GFX805,
  79. GFX810,
  80. GFX900,
  81. GFX902,
  82. GFX904,
  83. GFX906,
  84. GFX908,
  85. GFX909,
  86. GFX90a,
  87. GFX90c,
  88. GFX1010,
  89. GFX1011,
  90. GFX1012,
  91. GFX1013,
  92. GFX1030,
  93. GFX1031,
  94. GFX1032,
  95. GFX1033,
  96. GFX1034,
  97. GFX1035,
  98. Generic, // A processor model named 'generic' if the target backend defines a
  99. // public one.
  100. LAST,
  101. };
  102. static inline bool IsNVIDIAGpuArch(CudaArch A) {
  103. return A >= CudaArch::SM_20 && A < CudaArch::GFX600;
  104. }
  105. static inline bool IsAMDGpuArch(CudaArch A) {
  106. // Generic processor model is for testing only.
  107. return A >= CudaArch::GFX600 && A < CudaArch::Generic;
  108. }
  109. const char *CudaArchToString(CudaArch A);
  110. const char *CudaArchToVirtualArchString(CudaArch A);
  111. // The input should have the form "sm_20".
  112. CudaArch StringToCudaArch(llvm::StringRef S);
  113. /// Get the earliest CudaVersion that supports the given CudaArch.
  114. CudaVersion MinVersionForCudaArch(CudaArch A);
  115. /// Get the latest CudaVersion that supports the given CudaArch.
  116. CudaVersion MaxVersionForCudaArch(CudaArch A);
  117. // Various SDK-dependent features that affect CUDA compilation
  118. enum class CudaFeature {
  119. // CUDA-9.2+ uses a new API for launching kernels.
  120. CUDA_USES_NEW_LAUNCH,
  121. // CUDA-10.1+ needs explicit end of GPU binary registration.
  122. CUDA_USES_FATBIN_REGISTER_END,
  123. };
  124. CudaVersion ToCudaVersion(llvm::VersionTuple);
  125. bool CudaFeatureEnabled(llvm::VersionTuple, CudaFeature);
  126. bool CudaFeatureEnabled(CudaVersion, CudaFeature);
  127. } // namespace clang
  128. #endif
  129. #ifdef __GNUC__
  130. #pragma GCC diagnostic pop
  131. #endif