-
Notifications
You must be signed in to change notification settings - Fork 14.2k
[CUDA] Rename SM_32 to SM_32_ to work around AIX headers #88779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-codegen Author: Joseph Huber (jhuber6) ChangesSummary: Full diff: https://github.com/llvm/llvm-project/pull/88779.diff 4 Files Affected:
diff --git a/clang/include/clang/Basic/Cuda.h b/clang/include/clang/Basic/Cuda.h
index 38f30543a0f662..9666a16a173cdb 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..9ab057c6a3741f 100644
--- a/clang/lib/Basic/Cuda.cpp
+++ b/clang/lib/Basic/Cuda.cpp
@@ -77,6 +77,8 @@ struct CudaArchToStringMap {
};
} // namespace
+#define SM3(sm, ca) \
+ { CudaArch::_SM_##sm, "sm_" #sm, ca }
#define SM2(sm, ca) \
{ CudaArch::SM_##sm, "sm_" #sm, ca }
#define SM(sm) SM2(sm, "compute_" #sm)
@@ -86,7 +88,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), SM3(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 +188,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 +233,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..1b08d1f900d6a6 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..791173b6d31dec 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:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than that nit, LGTM (leaving final approval to @Artem-B )
clang/lib/Basic/Cuda.cpp
Outdated
@@ -86,7 +88,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), SM3(32, "compute_32"), SM(35), SM(37), // Kepler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit. We don't really need SM3 here. For one-off we could Just use {CudaArch::SM_32_, "sm_32" , "compute_32"}}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't do it originally becausei tm ake the formatting a little awkward, but I'll change it.
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.
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.