[clang] [CUDA] Rename SM_32 to SM_32_ to work around AIX headers (PR #88779)
Joseph Huber via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 15 12:31:10 PDT 2024
https://github.com/jhuber6 updated https://github.com/llvm/llvm-project/pull/88779
>From dbf6a86930207a4baa787c4387ab83d30524b2aa Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Mon, 15 Apr 2024 14:12:15 -0500
Subject: [PATCH] [CUDA] Rename SM_32 to _SM_32 to work around AIX headers
Summary:
AIX headers define this, so we need to work around it. In the future
this will be removed but for now we should just rename it to avoid these
issues.
---
clang/include/clang/Basic/Cuda.h | 8 +++-----
clang/lib/Basic/Cuda.cpp | 6 +++---
clang/lib/Basic/Targets/NVPTX.cpp | 2 +-
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp | 2 +-
4 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/clang/include/clang/Basic/Cuda.h b/clang/include/clang/Basic/Cuda.h
index 38f30543a0f662..ba0e4465a0f5a0 100644
--- a/clang/include/clang/Basic/Cuda.h
+++ b/clang/include/clang/Basic/Cuda.h
@@ -50,17 +50,15 @@ const char *CudaVersionToString(CudaVersion V);
// Input is "Major.Minor"
CudaVersion CudaStringToVersion(const llvm::Twine &S);
-// We have a name conflict with sys/mac.h on AIX
-#ifdef SM_32
-#undef SM_32
-#endif
enum class CudaArch {
UNUSED,
UNKNOWN,
+ // TODO: Deprecate and remove GPU architectures older than sm_52.
SM_20,
SM_21,
SM_30,
- SM_32,
+ // This has a name conflict with sys/mac.h on AIX, rename it as a workaround.
+ SM_32_,
SM_35,
SM_37,
SM_50,
diff --git a/clang/lib/Basic/Cuda.cpp b/clang/lib/Basic/Cuda.cpp
index 1b1da6a1356f2c..113483db5729b0 100644
--- a/clang/lib/Basic/Cuda.cpp
+++ b/clang/lib/Basic/Cuda.cpp
@@ -86,7 +86,7 @@ static const CudaArchToStringMap arch_names[] = {
// clang-format off
{CudaArch::UNUSED, "", ""},
SM2(20, "compute_20"), SM2(21, "compute_20"), // Fermi
- SM(30), SM(32), SM(35), SM(37), // Kepler
+ SM(30), {CudaArch::SM_32_, "sm_32", "compute_32"}, SM(35), SM(37), // Kepler
SM(50), SM(52), SM(53), // Maxwell
SM(60), SM(61), SM(62), // Pascal
SM(70), SM(72), // Volta
@@ -186,7 +186,7 @@ CudaVersion MinVersionForCudaArch(CudaArch A) {
case CudaArch::SM_20:
case CudaArch::SM_21:
case CudaArch::SM_30:
- case CudaArch::SM_32:
+ case CudaArch::SM_32_:
case CudaArch::SM_35:
case CudaArch::SM_37:
case CudaArch::SM_50:
@@ -231,7 +231,7 @@ CudaVersion MaxVersionForCudaArch(CudaArch A) {
case CudaArch::SM_21:
return CudaVersion::CUDA_80;
case CudaArch::SM_30:
- case CudaArch::SM_32:
+ case CudaArch::SM_32_:
return CudaVersion::CUDA_102;
case CudaArch::SM_35:
case CudaArch::SM_37:
diff --git a/clang/lib/Basic/Targets/NVPTX.cpp b/clang/lib/Basic/Targets/NVPTX.cpp
index b47c399fef6042..8ad9e6e5f58916 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -239,7 +239,7 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions &Opts,
return "210";
case CudaArch::SM_30:
return "300";
- case CudaArch::SM_32:
+ case CudaArch::SM_32_:
return "320";
case CudaArch::SM_35:
return "350";
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 59ba03c6b86253..eb716520e5ff56 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -3466,7 +3466,7 @@ void CGOpenMPRuntimeGPU::processRequiresDirective(
case CudaArch::SM_20:
case CudaArch::SM_21:
case CudaArch::SM_30:
- case CudaArch::SM_32:
+ case CudaArch::SM_32_:
case CudaArch::SM_35:
case CudaArch::SM_37:
case CudaArch::SM_50:
More information about the cfe-commits
mailing list