-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Clang][NFC] Move OffloadArch enum to a generic location #137070
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
…et of Intel OffloadArch values
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-clang Author: Justin Cai (jzc) ChangesCurrently, the OffloadArch enum is defined Cuda.h. This PR moves the definition to a more generic location in OffloadArch.h/cpp and also adds an initial set of Intel OffloadArch values that will be used in SYCL compilation. Full diff: https://github.com/llvm/llvm-project/pull/137070.diff 9 Files Affected:
diff --git a/clang/include/clang/Basic/Cuda.h b/clang/include/clang/Basic/Cuda.h
index c4eb7b7cac1d6..d6a22a7af559b 100644
--- a/clang/include/clang/Basic/Cuda.h
+++ b/clang/include/clang/Basic/Cuda.h
@@ -9,6 +9,8 @@
#ifndef LLVM_CLANG_BASIC_CUDA_H
#define LLVM_CLANG_BASIC_CUDA_H
+#include "clang/Basic/OffloadArch.h"
+
namespace llvm {
class StringRef;
class Twine;
@@ -54,98 +56,6 @@ const char *CudaVersionToString(CudaVersion V);
// Input is "Major.Minor"
CudaVersion CudaStringToVersion(const llvm::Twine &S);
-enum class OffloadArch {
- UNUSED,
- UNKNOWN,
- // TODO: Deprecate and remove GPU architectures older than sm_52.
- SM_20,
- SM_21,
- SM_30,
- // This has a name conflict with sys/mac.h on AIX, rename it as a workaround.
- SM_32_,
- SM_35,
- SM_37,
- SM_50,
- SM_52,
- SM_53,
- SM_60,
- SM_61,
- SM_62,
- SM_70,
- SM_72,
- SM_75,
- SM_80,
- SM_86,
- SM_87,
- SM_89,
- SM_90,
- SM_90a,
- SM_100,
- SM_100a,
- SM_101,
- SM_101a,
- SM_120,
- SM_120a,
- GFX600,
- GFX601,
- GFX602,
- GFX700,
- GFX701,
- GFX702,
- GFX703,
- GFX704,
- GFX705,
- GFX801,
- GFX802,
- GFX803,
- GFX805,
- GFX810,
- GFX9_GENERIC,
- GFX900,
- GFX902,
- GFX904,
- GFX906,
- GFX908,
- GFX909,
- GFX90a,
- GFX90c,
- GFX9_4_GENERIC,
- GFX942,
- GFX950,
- GFX10_1_GENERIC,
- GFX1010,
- GFX1011,
- GFX1012,
- GFX1013,
- GFX10_3_GENERIC,
- GFX1030,
- GFX1031,
- GFX1032,
- GFX1033,
- GFX1034,
- GFX1035,
- GFX1036,
- GFX11_GENERIC,
- GFX1100,
- GFX1101,
- GFX1102,
- GFX1103,
- GFX1150,
- GFX1151,
- GFX1152,
- GFX1153,
- GFX12_GENERIC,
- GFX1200,
- GFX1201,
- AMDGCNSPIRV,
- Generic, // A processor model named 'generic' if the target backend defines a
- // public one.
- LAST,
-
- CudaDefault = OffloadArch::SM_52,
- HIPDefault = OffloadArch::GFX906,
-};
-
enum class CUDAFunctionTarget {
Device,
Global,
@@ -154,21 +64,6 @@ enum class CUDAFunctionTarget {
InvalidTarget
};
-static inline bool IsNVIDIAOffloadArch(OffloadArch A) {
- return A >= OffloadArch::SM_20 && A < OffloadArch::GFX600;
-}
-
-static inline bool IsAMDOffloadArch(OffloadArch A) {
- // Generic processor model is for testing only.
- return A >= OffloadArch::GFX600 && A < OffloadArch::Generic;
-}
-
-const char *OffloadArchToString(OffloadArch A);
-const char *OffloadArchToVirtualArchString(OffloadArch A);
-
-// The input should have the form "sm_20".
-OffloadArch StringToOffloadArch(llvm::StringRef S);
-
/// Get the earliest CudaVersion that supports the given OffloadArch.
CudaVersion MinVersionForOffloadArch(OffloadArch A);
diff --git a/clang/include/clang/Basic/OffloadArch.h b/clang/include/clang/Basic/OffloadArch.h
new file mode 100644
index 0000000000000..6fee1e2bc8c06
--- /dev/null
+++ b/clang/include/clang/Basic/OffloadArch.h
@@ -0,0 +1,143 @@
+//===--- OffloadArch.h - Definition of offloading architectures --- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_BASIC_OFFLOADARCH_H
+#define LLVM_CLANG_BASIC_OFFLOADARCH_H
+
+namespace llvm {
+class StringRef;
+} // namespace llvm
+
+namespace clang {
+
+enum class OffloadArch {
+ UNUSED,
+ UNKNOWN,
+ // TODO: Deprecate and remove GPU architectures older than sm_52.
+ SM_20,
+ SM_21,
+ SM_30,
+ // This has a name conflict with sys/mac.h on AIX, rename it as a workaround.
+ SM_32_,
+ SM_35,
+ SM_37,
+ SM_50,
+ SM_52,
+ SM_53,
+ SM_60,
+ SM_61,
+ SM_62,
+ SM_70,
+ SM_72,
+ SM_75,
+ SM_80,
+ SM_86,
+ SM_87,
+ SM_89,
+ SM_90,
+ SM_90a,
+ SM_100,
+ SM_100a,
+ SM_101,
+ SM_101a,
+ SM_120,
+ SM_120a,
+ GFX600,
+ GFX601,
+ GFX602,
+ GFX700,
+ GFX701,
+ GFX702,
+ GFX703,
+ GFX704,
+ GFX705,
+ GFX801,
+ GFX802,
+ GFX803,
+ GFX805,
+ GFX810,
+ GFX9_GENERIC,
+ GFX900,
+ GFX902,
+ GFX904,
+ GFX906,
+ GFX908,
+ GFX909,
+ GFX90a,
+ GFX90c,
+ GFX9_4_GENERIC,
+ GFX942,
+ GFX950,
+ GFX10_1_GENERIC,
+ GFX1010,
+ GFX1011,
+ GFX1012,
+ GFX1013,
+ GFX10_3_GENERIC,
+ GFX1030,
+ GFX1031,
+ GFX1032,
+ GFX1033,
+ GFX1034,
+ GFX1035,
+ GFX1036,
+ GFX11_GENERIC,
+ GFX1100,
+ GFX1101,
+ GFX1102,
+ GFX1103,
+ GFX1150,
+ GFX1151,
+ GFX1152,
+ GFX1153,
+ GFX12_GENERIC,
+ GFX1200,
+ GFX1201,
+ AMDGCNSPIRV,
+ Generic, // A processor model named 'generic' if the target backend defines a
+ // public one.
+ // Intel CPUs
+ GRANITERAPIDS,
+ // Intel GPUs
+ BMG_G21,
+ LAST,
+
+ CudaDefault = OffloadArch::SM_52,
+ HIPDefault = OffloadArch::GFX906,
+};
+
+static inline bool IsNVIDIAOffloadArch(OffloadArch A) {
+ return A >= OffloadArch::SM_20 && A < OffloadArch::GFX600;
+}
+
+static inline bool IsAMDOffloadArch(OffloadArch A) {
+ // Generic processor model is for testing only.
+ return A >= OffloadArch::GFX600 && A < OffloadArch::Generic;
+}
+
+static inline bool IsIntelCPUArch(OffloadArch Arch) {
+ return Arch >= OffloadArch::GRANITERAPIDS && Arch < OffloadArch::BMG_G21;
+}
+
+static inline bool IsIntelGPUArch(OffloadArch Arch) {
+ return Arch >= OffloadArch::BMG_G21 && Arch < OffloadArch::LAST;
+}
+
+static inline bool IsIntelOffloadArch(OffloadArch Arch) {
+ return IsIntelCPUArch(Arch) || IsIntelGPUArch(Arch);
+}
+
+const char *OffloadArchToString(OffloadArch A);
+const char *OffloadArchToVirtualArchString(OffloadArch A);
+
+// The input should have the form "sm_20".
+OffloadArch StringToOffloadArch(llvm::StringRef S);
+
+} // namespace clang
+
+#endif // LLVM_CLANG_BASIC_OFFLOADARCH_H
diff --git a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
index 331dfbb3f4b67..419fd9bc136cf 100644
--- a/clang/lib/Basic/CMakeLists.txt
+++ b/clang/lib/Basic/CMakeLists.txt
@@ -76,6 +76,7 @@ add_clang_library(clangBasic
MakeSupport.cpp
Module.cpp
ObjCRuntime.cpp
+ OffloadArch.cpp
OpenCLOptions.cpp
OpenMPKinds.cpp
OperatorPrecedence.cpp
diff --git a/clang/lib/Basic/Cuda.cpp b/clang/lib/Basic/Cuda.cpp
index 68d042eca2492..8ea242911a2ba 100644
--- a/clang/lib/Basic/Cuda.cpp
+++ b/clang/lib/Basic/Cuda.cpp
@@ -73,123 +73,6 @@ CudaVersion ToCudaVersion(llvm::VersionTuple Version) {
return CudaVersion::UNKNOWN;
}
-namespace {
-struct OffloadArchToStringMap {
- OffloadArch arch;
- const char *arch_name;
- const char *virtual_arch_name;
-};
-} // namespace
-
-#define SM2(sm, ca) {OffloadArch::SM_##sm, "sm_" #sm, ca}
-#define SM(sm) SM2(sm, "compute_" #sm)
-#define GFX(gpu) {OffloadArch::GFX##gpu, "gfx" #gpu, "compute_amdgcn"}
-static const OffloadArchToStringMap arch_names[] = {
- // clang-format off
- {OffloadArch::UNUSED, "", ""},
- SM2(20, "compute_20"), SM2(21, "compute_20"), // Fermi
- SM(30), {OffloadArch::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
- SM(75), // Turing
- SM(80), SM(86), // Ampere
- SM(87), // Jetson/Drive AGX Orin
- SM(89), // Ada Lovelace
- SM(90), // Hopper
- SM(90a), // Hopper
- SM(100), // Blackwell
- SM(100a), // Blackwell
- SM(101), // Blackwell
- SM(101a), // Blackwell
- SM(120), // Blackwell
- SM(120a), // Blackwell
- GFX(600), // gfx600
- GFX(601), // gfx601
- GFX(602), // gfx602
- GFX(700), // gfx700
- GFX(701), // gfx701
- GFX(702), // gfx702
- GFX(703), // gfx703
- GFX(704), // gfx704
- GFX(705), // gfx705
- GFX(801), // gfx801
- GFX(802), // gfx802
- GFX(803), // gfx803
- GFX(805), // gfx805
- GFX(810), // gfx810
- {OffloadArch::GFX9_GENERIC, "gfx9-generic", "compute_amdgcn"},
- GFX(900), // gfx900
- GFX(902), // gfx902
- GFX(904), // gfx903
- GFX(906), // gfx906
- GFX(908), // gfx908
- GFX(909), // gfx909
- GFX(90a), // gfx90a
- GFX(90c), // gfx90c
- {OffloadArch::GFX9_4_GENERIC, "gfx9-4-generic", "compute_amdgcn"},
- GFX(942), // gfx942
- GFX(950), // gfx950
- {OffloadArch::GFX10_1_GENERIC, "gfx10-1-generic", "compute_amdgcn"},
- GFX(1010), // gfx1010
- GFX(1011), // gfx1011
- GFX(1012), // gfx1012
- GFX(1013), // gfx1013
- {OffloadArch::GFX10_3_GENERIC, "gfx10-3-generic", "compute_amdgcn"},
- GFX(1030), // gfx1030
- GFX(1031), // gfx1031
- GFX(1032), // gfx1032
- GFX(1033), // gfx1033
- GFX(1034), // gfx1034
- GFX(1035), // gfx1035
- GFX(1036), // gfx1036
- {OffloadArch::GFX11_GENERIC, "gfx11-generic", "compute_amdgcn"},
- GFX(1100), // gfx1100
- GFX(1101), // gfx1101
- GFX(1102), // gfx1102
- GFX(1103), // gfx1103
- GFX(1150), // gfx1150
- GFX(1151), // gfx1151
- GFX(1152), // gfx1152
- GFX(1153), // gfx1153
- {OffloadArch::GFX12_GENERIC, "gfx12-generic", "compute_amdgcn"},
- GFX(1200), // gfx1200
- GFX(1201), // gfx1201
- {OffloadArch::AMDGCNSPIRV, "amdgcnspirv", "compute_amdgcn"},
- {OffloadArch::Generic, "generic", ""},
- // clang-format on
-};
-#undef SM
-#undef SM2
-#undef GFX
-
-const char *OffloadArchToString(OffloadArch A) {
- auto result = std::find_if(
- std::begin(arch_names), std::end(arch_names),
- [A](const OffloadArchToStringMap &map) { return A == map.arch; });
- if (result == std::end(arch_names))
- return "unknown";
- return result->arch_name;
-}
-
-const char *OffloadArchToVirtualArchString(OffloadArch A) {
- auto result = std::find_if(
- std::begin(arch_names), std::end(arch_names),
- [A](const OffloadArchToStringMap &map) { return A == map.arch; });
- if (result == std::end(arch_names))
- return "unknown";
- return result->virtual_arch_name;
-}
-
-OffloadArch StringToOffloadArch(llvm::StringRef S) {
- auto result = std::find_if(
- std::begin(arch_names), std::end(arch_names),
- [S](const OffloadArchToStringMap &map) { return S == map.arch_name; });
- if (result == std::end(arch_names))
- return OffloadArch::UNKNOWN;
- return result->arch;
-}
-
CudaVersion MinVersionForOffloadArch(OffloadArch A) {
if (A == OffloadArch::UNKNOWN)
return CudaVersion::UNKNOWN;
diff --git a/clang/lib/Basic/OffloadArch.cpp b/clang/lib/Basic/OffloadArch.cpp
new file mode 100644
index 0000000000000..828c1ebf866fa
--- /dev/null
+++ b/clang/lib/Basic/OffloadArch.cpp
@@ -0,0 +1,133 @@
+#include "clang/Basic/OffloadArch.h"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <algorithm>
+
+namespace clang {
+
+namespace {
+struct OffloadArchToStringMap {
+ OffloadArch arch;
+ const char *arch_name;
+ const char *virtual_arch_name;
+};
+} // namespace
+
+#define SM2(sm, ca) {OffloadArch::SM_##sm, "sm_" #sm, ca}
+#define SM(sm) SM2(sm, "compute_" #sm)
+#define GFX(gpu) {OffloadArch::GFX##gpu, "gfx" #gpu, "compute_amdgcn"}
+static const OffloadArchToStringMap arch_names[] = {
+ // clang-format off
+ {OffloadArch::UNUSED, "", ""},
+ SM2(20, "compute_20"), SM2(21, "compute_20"), // Fermi
+ SM(30), {OffloadArch::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
+ SM(75), // Turing
+ SM(80), SM(86), // Ampere
+ SM(87), // Jetson/Drive AGX Orin
+ SM(89), // Ada Lovelace
+ SM(90), // Hopper
+ SM(90a), // Hopper
+ SM(100), // Blackwell
+ SM(100a), // Blackwell
+ SM(101), // Blackwell
+ SM(101a), // Blackwell
+ SM(120), // Blackwell
+ SM(120a), // Blackwell
+ GFX(600), // gfx600
+ GFX(601), // gfx601
+ GFX(602), // gfx602
+ GFX(700), // gfx700
+ GFX(701), // gfx701
+ GFX(702), // gfx702
+ GFX(703), // gfx703
+ GFX(704), // gfx704
+ GFX(705), // gfx705
+ GFX(801), // gfx801
+ GFX(802), // gfx802
+ GFX(803), // gfx803
+ GFX(805), // gfx805
+ GFX(810), // gfx810
+ {OffloadArch::GFX9_GENERIC, "gfx9-generic", "compute_amdgcn"},
+ GFX(900), // gfx900
+ GFX(902), // gfx902
+ GFX(904), // gfx903
+ GFX(906), // gfx906
+ GFX(908), // gfx908
+ GFX(909), // gfx909
+ GFX(90a), // gfx90a
+ GFX(90c), // gfx90c
+ {OffloadArch::GFX9_4_GENERIC, "gfx9-4-generic", "compute_amdgcn"},
+ GFX(942), // gfx942
+ GFX(950), // gfx950
+ {OffloadArch::GFX10_1_GENERIC, "gfx10-1-generic", "compute_amdgcn"},
+ GFX(1010), // gfx1010
+ GFX(1011), // gfx1011
+ GFX(1012), // gfx1012
+ GFX(1013), // gfx1013
+ {OffloadArch::GFX10_3_GENERIC, "gfx10-3-generic", "compute_amdgcn"},
+ GFX(1030), // gfx1030
+ GFX(1031), // gfx1031
+ GFX(1032), // gfx1032
+ GFX(1033), // gfx1033
+ GFX(1034), // gfx1034
+ GFX(1035), // gfx1035
+ GFX(1036), // gfx1036
+ {OffloadArch::GFX11_GENERIC, "gfx11-generic", "compute_amdgcn"},
+ GFX(1100), // gfx1100
+ GFX(1101), // gfx1101
+ GFX(1102), // gfx1102
+ GFX(1103), // gfx1103
+ GFX(1150), // gfx1150
+ GFX(1151), // gfx1151
+ GFX(1152), // gfx1152
+ GFX(1153), // gfx1153
+ {OffloadArch::GFX12_GENERIC, "gfx12-generic", "compute_amdgcn"},
+ GFX(1200), // gfx1200
+ GFX(1201), // gfx1201
+ {OffloadArch::AMDGCNSPIRV, "amdgcnspirv", "compute_amdgcn"},
+ // Note: this is an initial list of Intel GPU and GPU offloading architectures.
+ // The list will be expanded later as support for more architectures is added.
+ // Intel CPUs
+ {OffloadArch::GRANITERAPIDS, "graniterapids", ""},
+ // Intel GPUS
+ {OffloadArch::BMG_G21, "bmg_g21", ""},
+ {OffloadArch::Generic, "generic", ""},
+ // clang-format on
+};
+#undef SM
+#undef SM2
+#undef GFX
+#undef INTEL
+
+const char *OffloadArchToString(OffloadArch A) {
+ auto result = std::find_if(
+ std::begin(arch_names), std::end(arch_names),
+ [A](const OffloadArchToStringMap &map) { return A == map.arch; });
+ if (result == std::end(arch_names))
+ return "unknown";
+ return result->arch_name;
+}
+
+const char *OffloadArchToVirtualArchString(OffloadArch A) {
+ auto result = std::find_if(
+ std::begin(arch_names), std::end(arch_names),
+ [A](const OffloadArchToStringMap &map) { return A == map.arch; });
+ if (result == std::end(arch_names))
+ return "unknown";
+ return result->virtual_arch_name;
+}
+
+OffloadArch StringToOffloadArch(llvm::StringRef S) {
+ auto result = std::find_if(
+ std::begin(arch_names), std::end(arch_names),
+ [S](const OffloadArchToStringMap &map) { return S == map.arch_name; });
+ if (result == std::end(arch_names))
+ return OffloadArch::UNKNOWN;
+ return result->arch;
+}
+
+} // namespace clang
diff --git a/clang/lib/Basic/Targets/NVPTX.cpp b/clang/lib/Basic/Targets/NVPTX.cpp
index 08c8460045c6a..42b66d3559f6a 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -241,6 +241,8 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions &Opts,
case OffloadArch::GFX1201:
case OffloadArch::AMDGCNSPIRV:
case OffloadArch::Generic:
+ case OffloadArch::GRANITERAPIDS:
+ case OffloadArch::BMG_G21:
case OffloadArch::LAST:
break;
case OffloadArch::UNKNOWN:
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index f697c13f4c522..eed4471c38e4e 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -2335,6 +2335,8 @@ void CGOpenMPRuntimeGPU::processRequiresDirective(const OMPRequiresDecl *D) {
case OffloadArch::GFX1201:
case OffloadArch::AMDGCNSPIRV:
case OffloadArch::Generic:
+ case OffloadArch::GRANITERAPIDS:
+ case OffloadArch::BMG_G21:
case OffloadArch::UNUSED:
case OffloadArch::UNKNOWN:
break;
diff --git a/clang/unittests/Basic/CMakeLists.txt b/clang/unittests/Basic/CMakeLists.txt
index e818bd3e2c372..37b01cc9f66a8 100644
--- a/clang/unittests/Basic/CMakeLists.txt
+++ b/clang/unittests/Basic/CMakeLists.txt
@@ -5,6 +5,7 @@ add_clang_unittest(BasicTests
FileEntryTest.cpp
FileManagerTest.cpp
LineOffsetMappingTest.cpp
+ OffloadArchTest.cpp
SanitizersTest.cpp
SarifTest.cpp
SourceManagerTest.cpp
diff --git a/clang/unittests/Basic/OffloadArchTest.cpp b/clang/unittests/Basic/OffloadArchTest.cpp
new file mode 100644
index 0000000000000..964f5f2ad2603
--- /dev/null
+++ b/clang/unittests/Basic/OffloadArchTest.cpp
@@ -0,0 +1,36 @@
+//===- unittests/Basic/OffloadArchTest.cpp - Test OffloadArch -------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Basic/OffloadArch.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+
+TEST(OffloadArchTest, basic) {
+ EXPECT_TRUE(IsNVIDIAOffloadArch(OffloadArch::SM_20));
+ EXPECT_TRUE(IsNVIDIAOffloadArch(OffloadArch::SM_120a));
+ EXPECT_FALSE(IsNVIDIAOffloadArch(OffloadArch::GFX600));
+
+ EXPECT_FALSE(IsAMDOffloadArch(OffloadArch::SM_120a));
+ EXPECT_TRUE(IsAMDOffloadArch(OffloadArch::GFX600));
+ EXPECT_TRUE(IsAMDOffloadArch(OffloadArch::GFX1201));
+ EXPECT_TRUE(IsAMDOffloadArch(OffloadArch::GFX12_GENERIC));
+ EXPECT_TRUE(IsAMDOffloadArch(OffloadArch::AMDGCNSPIRV));
+ EXPECT_FALSE(IsAMDOffloadArch(OffloadArch::GRANITERAPIDS));
+
+ EXPECT_TRUE(IsIntelOffloadArch(OffloadArch::GRANITERAPIDS));
+ EXPECT_TRUE(IsIntelCPUArch(OffloadArch::GRANITERAPIDS));
+ EXPECT_FALSE(IsIntelGPUArch(OffloadArch::GRANITERAPIDS));
+ EXPECT_TRUE(IsIntelOffloadArch(OffloadArch::BMG_G21));
+ EXPECT_FALSE(IsIntelCPUArch(OffloadArch::BMG_G21));
+ EXPECT_TRUE(IsIntelGPUArch(OffloadArch::BMG_G21));
+
+ EXPECT_FALSE(IsNVIDIAOffloadArch(OffloadArch::Generic));
+ EXPECT_FALSE(IsAMDOffloadArch(OffloadArch::Generic));
+ EXPECT_FALSE(IsIntelOffloadArch(OffloadArch::Generic));
+}
|
@llvm/pr-subscribers-clang-codegen Author: Justin Cai (jzc) ChangesCurrently, the OffloadArch enum is defined Cuda.h. This PR moves the definition to a more generic location in OffloadArch.h/cpp and also adds an initial set of Intel OffloadArch values that will be used in SYCL compilation. Full diff: https://github.com/llvm/llvm-project/pull/137070.diff 9 Files Affected:
diff --git a/clang/include/clang/Basic/Cuda.h b/clang/include/clang/Basic/Cuda.h
index c4eb7b7cac1d6..d6a22a7af559b 100644
--- a/clang/include/clang/Basic/Cuda.h
+++ b/clang/include/clang/Basic/Cuda.h
@@ -9,6 +9,8 @@
#ifndef LLVM_CLANG_BASIC_CUDA_H
#define LLVM_CLANG_BASIC_CUDA_H
+#include "clang/Basic/OffloadArch.h"
+
namespace llvm {
class StringRef;
class Twine;
@@ -54,98 +56,6 @@ const char *CudaVersionToString(CudaVersion V);
// Input is "Major.Minor"
CudaVersion CudaStringToVersion(const llvm::Twine &S);
-enum class OffloadArch {
- UNUSED,
- UNKNOWN,
- // TODO: Deprecate and remove GPU architectures older than sm_52.
- SM_20,
- SM_21,
- SM_30,
- // This has a name conflict with sys/mac.h on AIX, rename it as a workaround.
- SM_32_,
- SM_35,
- SM_37,
- SM_50,
- SM_52,
- SM_53,
- SM_60,
- SM_61,
- SM_62,
- SM_70,
- SM_72,
- SM_75,
- SM_80,
- SM_86,
- SM_87,
- SM_89,
- SM_90,
- SM_90a,
- SM_100,
- SM_100a,
- SM_101,
- SM_101a,
- SM_120,
- SM_120a,
- GFX600,
- GFX601,
- GFX602,
- GFX700,
- GFX701,
- GFX702,
- GFX703,
- GFX704,
- GFX705,
- GFX801,
- GFX802,
- GFX803,
- GFX805,
- GFX810,
- GFX9_GENERIC,
- GFX900,
- GFX902,
- GFX904,
- GFX906,
- GFX908,
- GFX909,
- GFX90a,
- GFX90c,
- GFX9_4_GENERIC,
- GFX942,
- GFX950,
- GFX10_1_GENERIC,
- GFX1010,
- GFX1011,
- GFX1012,
- GFX1013,
- GFX10_3_GENERIC,
- GFX1030,
- GFX1031,
- GFX1032,
- GFX1033,
- GFX1034,
- GFX1035,
- GFX1036,
- GFX11_GENERIC,
- GFX1100,
- GFX1101,
- GFX1102,
- GFX1103,
- GFX1150,
- GFX1151,
- GFX1152,
- GFX1153,
- GFX12_GENERIC,
- GFX1200,
- GFX1201,
- AMDGCNSPIRV,
- Generic, // A processor model named 'generic' if the target backend defines a
- // public one.
- LAST,
-
- CudaDefault = OffloadArch::SM_52,
- HIPDefault = OffloadArch::GFX906,
-};
-
enum class CUDAFunctionTarget {
Device,
Global,
@@ -154,21 +64,6 @@ enum class CUDAFunctionTarget {
InvalidTarget
};
-static inline bool IsNVIDIAOffloadArch(OffloadArch A) {
- return A >= OffloadArch::SM_20 && A < OffloadArch::GFX600;
-}
-
-static inline bool IsAMDOffloadArch(OffloadArch A) {
- // Generic processor model is for testing only.
- return A >= OffloadArch::GFX600 && A < OffloadArch::Generic;
-}
-
-const char *OffloadArchToString(OffloadArch A);
-const char *OffloadArchToVirtualArchString(OffloadArch A);
-
-// The input should have the form "sm_20".
-OffloadArch StringToOffloadArch(llvm::StringRef S);
-
/// Get the earliest CudaVersion that supports the given OffloadArch.
CudaVersion MinVersionForOffloadArch(OffloadArch A);
diff --git a/clang/include/clang/Basic/OffloadArch.h b/clang/include/clang/Basic/OffloadArch.h
new file mode 100644
index 0000000000000..6fee1e2bc8c06
--- /dev/null
+++ b/clang/include/clang/Basic/OffloadArch.h
@@ -0,0 +1,143 @@
+//===--- OffloadArch.h - Definition of offloading architectures --- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_BASIC_OFFLOADARCH_H
+#define LLVM_CLANG_BASIC_OFFLOADARCH_H
+
+namespace llvm {
+class StringRef;
+} // namespace llvm
+
+namespace clang {
+
+enum class OffloadArch {
+ UNUSED,
+ UNKNOWN,
+ // TODO: Deprecate and remove GPU architectures older than sm_52.
+ SM_20,
+ SM_21,
+ SM_30,
+ // This has a name conflict with sys/mac.h on AIX, rename it as a workaround.
+ SM_32_,
+ SM_35,
+ SM_37,
+ SM_50,
+ SM_52,
+ SM_53,
+ SM_60,
+ SM_61,
+ SM_62,
+ SM_70,
+ SM_72,
+ SM_75,
+ SM_80,
+ SM_86,
+ SM_87,
+ SM_89,
+ SM_90,
+ SM_90a,
+ SM_100,
+ SM_100a,
+ SM_101,
+ SM_101a,
+ SM_120,
+ SM_120a,
+ GFX600,
+ GFX601,
+ GFX602,
+ GFX700,
+ GFX701,
+ GFX702,
+ GFX703,
+ GFX704,
+ GFX705,
+ GFX801,
+ GFX802,
+ GFX803,
+ GFX805,
+ GFX810,
+ GFX9_GENERIC,
+ GFX900,
+ GFX902,
+ GFX904,
+ GFX906,
+ GFX908,
+ GFX909,
+ GFX90a,
+ GFX90c,
+ GFX9_4_GENERIC,
+ GFX942,
+ GFX950,
+ GFX10_1_GENERIC,
+ GFX1010,
+ GFX1011,
+ GFX1012,
+ GFX1013,
+ GFX10_3_GENERIC,
+ GFX1030,
+ GFX1031,
+ GFX1032,
+ GFX1033,
+ GFX1034,
+ GFX1035,
+ GFX1036,
+ GFX11_GENERIC,
+ GFX1100,
+ GFX1101,
+ GFX1102,
+ GFX1103,
+ GFX1150,
+ GFX1151,
+ GFX1152,
+ GFX1153,
+ GFX12_GENERIC,
+ GFX1200,
+ GFX1201,
+ AMDGCNSPIRV,
+ Generic, // A processor model named 'generic' if the target backend defines a
+ // public one.
+ // Intel CPUs
+ GRANITERAPIDS,
+ // Intel GPUs
+ BMG_G21,
+ LAST,
+
+ CudaDefault = OffloadArch::SM_52,
+ HIPDefault = OffloadArch::GFX906,
+};
+
+static inline bool IsNVIDIAOffloadArch(OffloadArch A) {
+ return A >= OffloadArch::SM_20 && A < OffloadArch::GFX600;
+}
+
+static inline bool IsAMDOffloadArch(OffloadArch A) {
+ // Generic processor model is for testing only.
+ return A >= OffloadArch::GFX600 && A < OffloadArch::Generic;
+}
+
+static inline bool IsIntelCPUArch(OffloadArch Arch) {
+ return Arch >= OffloadArch::GRANITERAPIDS && Arch < OffloadArch::BMG_G21;
+}
+
+static inline bool IsIntelGPUArch(OffloadArch Arch) {
+ return Arch >= OffloadArch::BMG_G21 && Arch < OffloadArch::LAST;
+}
+
+static inline bool IsIntelOffloadArch(OffloadArch Arch) {
+ return IsIntelCPUArch(Arch) || IsIntelGPUArch(Arch);
+}
+
+const char *OffloadArchToString(OffloadArch A);
+const char *OffloadArchToVirtualArchString(OffloadArch A);
+
+// The input should have the form "sm_20".
+OffloadArch StringToOffloadArch(llvm::StringRef S);
+
+} // namespace clang
+
+#endif // LLVM_CLANG_BASIC_OFFLOADARCH_H
diff --git a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
index 331dfbb3f4b67..419fd9bc136cf 100644
--- a/clang/lib/Basic/CMakeLists.txt
+++ b/clang/lib/Basic/CMakeLists.txt
@@ -76,6 +76,7 @@ add_clang_library(clangBasic
MakeSupport.cpp
Module.cpp
ObjCRuntime.cpp
+ OffloadArch.cpp
OpenCLOptions.cpp
OpenMPKinds.cpp
OperatorPrecedence.cpp
diff --git a/clang/lib/Basic/Cuda.cpp b/clang/lib/Basic/Cuda.cpp
index 68d042eca2492..8ea242911a2ba 100644
--- a/clang/lib/Basic/Cuda.cpp
+++ b/clang/lib/Basic/Cuda.cpp
@@ -73,123 +73,6 @@ CudaVersion ToCudaVersion(llvm::VersionTuple Version) {
return CudaVersion::UNKNOWN;
}
-namespace {
-struct OffloadArchToStringMap {
- OffloadArch arch;
- const char *arch_name;
- const char *virtual_arch_name;
-};
-} // namespace
-
-#define SM2(sm, ca) {OffloadArch::SM_##sm, "sm_" #sm, ca}
-#define SM(sm) SM2(sm, "compute_" #sm)
-#define GFX(gpu) {OffloadArch::GFX##gpu, "gfx" #gpu, "compute_amdgcn"}
-static const OffloadArchToStringMap arch_names[] = {
- // clang-format off
- {OffloadArch::UNUSED, "", ""},
- SM2(20, "compute_20"), SM2(21, "compute_20"), // Fermi
- SM(30), {OffloadArch::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
- SM(75), // Turing
- SM(80), SM(86), // Ampere
- SM(87), // Jetson/Drive AGX Orin
- SM(89), // Ada Lovelace
- SM(90), // Hopper
- SM(90a), // Hopper
- SM(100), // Blackwell
- SM(100a), // Blackwell
- SM(101), // Blackwell
- SM(101a), // Blackwell
- SM(120), // Blackwell
- SM(120a), // Blackwell
- GFX(600), // gfx600
- GFX(601), // gfx601
- GFX(602), // gfx602
- GFX(700), // gfx700
- GFX(701), // gfx701
- GFX(702), // gfx702
- GFX(703), // gfx703
- GFX(704), // gfx704
- GFX(705), // gfx705
- GFX(801), // gfx801
- GFX(802), // gfx802
- GFX(803), // gfx803
- GFX(805), // gfx805
- GFX(810), // gfx810
- {OffloadArch::GFX9_GENERIC, "gfx9-generic", "compute_amdgcn"},
- GFX(900), // gfx900
- GFX(902), // gfx902
- GFX(904), // gfx903
- GFX(906), // gfx906
- GFX(908), // gfx908
- GFX(909), // gfx909
- GFX(90a), // gfx90a
- GFX(90c), // gfx90c
- {OffloadArch::GFX9_4_GENERIC, "gfx9-4-generic", "compute_amdgcn"},
- GFX(942), // gfx942
- GFX(950), // gfx950
- {OffloadArch::GFX10_1_GENERIC, "gfx10-1-generic", "compute_amdgcn"},
- GFX(1010), // gfx1010
- GFX(1011), // gfx1011
- GFX(1012), // gfx1012
- GFX(1013), // gfx1013
- {OffloadArch::GFX10_3_GENERIC, "gfx10-3-generic", "compute_amdgcn"},
- GFX(1030), // gfx1030
- GFX(1031), // gfx1031
- GFX(1032), // gfx1032
- GFX(1033), // gfx1033
- GFX(1034), // gfx1034
- GFX(1035), // gfx1035
- GFX(1036), // gfx1036
- {OffloadArch::GFX11_GENERIC, "gfx11-generic", "compute_amdgcn"},
- GFX(1100), // gfx1100
- GFX(1101), // gfx1101
- GFX(1102), // gfx1102
- GFX(1103), // gfx1103
- GFX(1150), // gfx1150
- GFX(1151), // gfx1151
- GFX(1152), // gfx1152
- GFX(1153), // gfx1153
- {OffloadArch::GFX12_GENERIC, "gfx12-generic", "compute_amdgcn"},
- GFX(1200), // gfx1200
- GFX(1201), // gfx1201
- {OffloadArch::AMDGCNSPIRV, "amdgcnspirv", "compute_amdgcn"},
- {OffloadArch::Generic, "generic", ""},
- // clang-format on
-};
-#undef SM
-#undef SM2
-#undef GFX
-
-const char *OffloadArchToString(OffloadArch A) {
- auto result = std::find_if(
- std::begin(arch_names), std::end(arch_names),
- [A](const OffloadArchToStringMap &map) { return A == map.arch; });
- if (result == std::end(arch_names))
- return "unknown";
- return result->arch_name;
-}
-
-const char *OffloadArchToVirtualArchString(OffloadArch A) {
- auto result = std::find_if(
- std::begin(arch_names), std::end(arch_names),
- [A](const OffloadArchToStringMap &map) { return A == map.arch; });
- if (result == std::end(arch_names))
- return "unknown";
- return result->virtual_arch_name;
-}
-
-OffloadArch StringToOffloadArch(llvm::StringRef S) {
- auto result = std::find_if(
- std::begin(arch_names), std::end(arch_names),
- [S](const OffloadArchToStringMap &map) { return S == map.arch_name; });
- if (result == std::end(arch_names))
- return OffloadArch::UNKNOWN;
- return result->arch;
-}
-
CudaVersion MinVersionForOffloadArch(OffloadArch A) {
if (A == OffloadArch::UNKNOWN)
return CudaVersion::UNKNOWN;
diff --git a/clang/lib/Basic/OffloadArch.cpp b/clang/lib/Basic/OffloadArch.cpp
new file mode 100644
index 0000000000000..828c1ebf866fa
--- /dev/null
+++ b/clang/lib/Basic/OffloadArch.cpp
@@ -0,0 +1,133 @@
+#include "clang/Basic/OffloadArch.h"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <algorithm>
+
+namespace clang {
+
+namespace {
+struct OffloadArchToStringMap {
+ OffloadArch arch;
+ const char *arch_name;
+ const char *virtual_arch_name;
+};
+} // namespace
+
+#define SM2(sm, ca) {OffloadArch::SM_##sm, "sm_" #sm, ca}
+#define SM(sm) SM2(sm, "compute_" #sm)
+#define GFX(gpu) {OffloadArch::GFX##gpu, "gfx" #gpu, "compute_amdgcn"}
+static const OffloadArchToStringMap arch_names[] = {
+ // clang-format off
+ {OffloadArch::UNUSED, "", ""},
+ SM2(20, "compute_20"), SM2(21, "compute_20"), // Fermi
+ SM(30), {OffloadArch::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
+ SM(75), // Turing
+ SM(80), SM(86), // Ampere
+ SM(87), // Jetson/Drive AGX Orin
+ SM(89), // Ada Lovelace
+ SM(90), // Hopper
+ SM(90a), // Hopper
+ SM(100), // Blackwell
+ SM(100a), // Blackwell
+ SM(101), // Blackwell
+ SM(101a), // Blackwell
+ SM(120), // Blackwell
+ SM(120a), // Blackwell
+ GFX(600), // gfx600
+ GFX(601), // gfx601
+ GFX(602), // gfx602
+ GFX(700), // gfx700
+ GFX(701), // gfx701
+ GFX(702), // gfx702
+ GFX(703), // gfx703
+ GFX(704), // gfx704
+ GFX(705), // gfx705
+ GFX(801), // gfx801
+ GFX(802), // gfx802
+ GFX(803), // gfx803
+ GFX(805), // gfx805
+ GFX(810), // gfx810
+ {OffloadArch::GFX9_GENERIC, "gfx9-generic", "compute_amdgcn"},
+ GFX(900), // gfx900
+ GFX(902), // gfx902
+ GFX(904), // gfx903
+ GFX(906), // gfx906
+ GFX(908), // gfx908
+ GFX(909), // gfx909
+ GFX(90a), // gfx90a
+ GFX(90c), // gfx90c
+ {OffloadArch::GFX9_4_GENERIC, "gfx9-4-generic", "compute_amdgcn"},
+ GFX(942), // gfx942
+ GFX(950), // gfx950
+ {OffloadArch::GFX10_1_GENERIC, "gfx10-1-generic", "compute_amdgcn"},
+ GFX(1010), // gfx1010
+ GFX(1011), // gfx1011
+ GFX(1012), // gfx1012
+ GFX(1013), // gfx1013
+ {OffloadArch::GFX10_3_GENERIC, "gfx10-3-generic", "compute_amdgcn"},
+ GFX(1030), // gfx1030
+ GFX(1031), // gfx1031
+ GFX(1032), // gfx1032
+ GFX(1033), // gfx1033
+ GFX(1034), // gfx1034
+ GFX(1035), // gfx1035
+ GFX(1036), // gfx1036
+ {OffloadArch::GFX11_GENERIC, "gfx11-generic", "compute_amdgcn"},
+ GFX(1100), // gfx1100
+ GFX(1101), // gfx1101
+ GFX(1102), // gfx1102
+ GFX(1103), // gfx1103
+ GFX(1150), // gfx1150
+ GFX(1151), // gfx1151
+ GFX(1152), // gfx1152
+ GFX(1153), // gfx1153
+ {OffloadArch::GFX12_GENERIC, "gfx12-generic", "compute_amdgcn"},
+ GFX(1200), // gfx1200
+ GFX(1201), // gfx1201
+ {OffloadArch::AMDGCNSPIRV, "amdgcnspirv", "compute_amdgcn"},
+ // Note: this is an initial list of Intel GPU and GPU offloading architectures.
+ // The list will be expanded later as support for more architectures is added.
+ // Intel CPUs
+ {OffloadArch::GRANITERAPIDS, "graniterapids", ""},
+ // Intel GPUS
+ {OffloadArch::BMG_G21, "bmg_g21", ""},
+ {OffloadArch::Generic, "generic", ""},
+ // clang-format on
+};
+#undef SM
+#undef SM2
+#undef GFX
+#undef INTEL
+
+const char *OffloadArchToString(OffloadArch A) {
+ auto result = std::find_if(
+ std::begin(arch_names), std::end(arch_names),
+ [A](const OffloadArchToStringMap &map) { return A == map.arch; });
+ if (result == std::end(arch_names))
+ return "unknown";
+ return result->arch_name;
+}
+
+const char *OffloadArchToVirtualArchString(OffloadArch A) {
+ auto result = std::find_if(
+ std::begin(arch_names), std::end(arch_names),
+ [A](const OffloadArchToStringMap &map) { return A == map.arch; });
+ if (result == std::end(arch_names))
+ return "unknown";
+ return result->virtual_arch_name;
+}
+
+OffloadArch StringToOffloadArch(llvm::StringRef S) {
+ auto result = std::find_if(
+ std::begin(arch_names), std::end(arch_names),
+ [S](const OffloadArchToStringMap &map) { return S == map.arch_name; });
+ if (result == std::end(arch_names))
+ return OffloadArch::UNKNOWN;
+ return result->arch;
+}
+
+} // namespace clang
diff --git a/clang/lib/Basic/Targets/NVPTX.cpp b/clang/lib/Basic/Targets/NVPTX.cpp
index 08c8460045c6a..42b66d3559f6a 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -241,6 +241,8 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions &Opts,
case OffloadArch::GFX1201:
case OffloadArch::AMDGCNSPIRV:
case OffloadArch::Generic:
+ case OffloadArch::GRANITERAPIDS:
+ case OffloadArch::BMG_G21:
case OffloadArch::LAST:
break;
case OffloadArch::UNKNOWN:
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index f697c13f4c522..eed4471c38e4e 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -2335,6 +2335,8 @@ void CGOpenMPRuntimeGPU::processRequiresDirective(const OMPRequiresDecl *D) {
case OffloadArch::GFX1201:
case OffloadArch::AMDGCNSPIRV:
case OffloadArch::Generic:
+ case OffloadArch::GRANITERAPIDS:
+ case OffloadArch::BMG_G21:
case OffloadArch::UNUSED:
case OffloadArch::UNKNOWN:
break;
diff --git a/clang/unittests/Basic/CMakeLists.txt b/clang/unittests/Basic/CMakeLists.txt
index e818bd3e2c372..37b01cc9f66a8 100644
--- a/clang/unittests/Basic/CMakeLists.txt
+++ b/clang/unittests/Basic/CMakeLists.txt
@@ -5,6 +5,7 @@ add_clang_unittest(BasicTests
FileEntryTest.cpp
FileManagerTest.cpp
LineOffsetMappingTest.cpp
+ OffloadArchTest.cpp
SanitizersTest.cpp
SarifTest.cpp
SourceManagerTest.cpp
diff --git a/clang/unittests/Basic/OffloadArchTest.cpp b/clang/unittests/Basic/OffloadArchTest.cpp
new file mode 100644
index 0000000000000..964f5f2ad2603
--- /dev/null
+++ b/clang/unittests/Basic/OffloadArchTest.cpp
@@ -0,0 +1,36 @@
+//===- unittests/Basic/OffloadArchTest.cpp - Test OffloadArch -------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Basic/OffloadArch.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+
+TEST(OffloadArchTest, basic) {
+ EXPECT_TRUE(IsNVIDIAOffloadArch(OffloadArch::SM_20));
+ EXPECT_TRUE(IsNVIDIAOffloadArch(OffloadArch::SM_120a));
+ EXPECT_FALSE(IsNVIDIAOffloadArch(OffloadArch::GFX600));
+
+ EXPECT_FALSE(IsAMDOffloadArch(OffloadArch::SM_120a));
+ EXPECT_TRUE(IsAMDOffloadArch(OffloadArch::GFX600));
+ EXPECT_TRUE(IsAMDOffloadArch(OffloadArch::GFX1201));
+ EXPECT_TRUE(IsAMDOffloadArch(OffloadArch::GFX12_GENERIC));
+ EXPECT_TRUE(IsAMDOffloadArch(OffloadArch::AMDGCNSPIRV));
+ EXPECT_FALSE(IsAMDOffloadArch(OffloadArch::GRANITERAPIDS));
+
+ EXPECT_TRUE(IsIntelOffloadArch(OffloadArch::GRANITERAPIDS));
+ EXPECT_TRUE(IsIntelCPUArch(OffloadArch::GRANITERAPIDS));
+ EXPECT_FALSE(IsIntelGPUArch(OffloadArch::GRANITERAPIDS));
+ EXPECT_TRUE(IsIntelOffloadArch(OffloadArch::BMG_G21));
+ EXPECT_FALSE(IsIntelCPUArch(OffloadArch::BMG_G21));
+ EXPECT_TRUE(IsIntelGPUArch(OffloadArch::BMG_G21));
+
+ EXPECT_FALSE(IsNVIDIAOffloadArch(OffloadArch::Generic));
+ EXPECT_FALSE(IsAMDOffloadArch(OffloadArch::Generic));
+ EXPECT_FALSE(IsIntelOffloadArch(OffloadArch::Generic));
+}
|
// Intel CPUs | ||
GRANITERAPIDS, | ||
// Intel GPUs | ||
BMG_G21, |
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.
Are these new? If so that should be in a follow-up after an NFC move.
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.
That's reasonable. I'll introduce these later.
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.
Thanks
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.
LG, I'll merge it once CI's green. Thanks.
clang/lib/Basic/OffloadArch.cpp
Outdated
}; | ||
} // namespace | ||
|
||
#define SM2(sm, ca) {OffloadArch::SM_##sm, "sm_" #sm, ca} |
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.
I'd just define the special sm_20
w/o using this macro
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.
Good point, that is simpler - bd5e7a2
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.
LGTM. Thanks
@jzc Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
Currently, the OffloadArch enum is defined Cuda.h. This PR moves the definition to a more generic location in OffloadArch.h/cpp.
Following #137070, this PR adds an initial set of Intel `OffloadArch` values with corresponding predicates that will be used in SYCL offloading. More Intel architectures will be added in a future PR.
Currently, the OffloadArch enum is defined Cuda.h. This PR moves the definition to a more generic location in OffloadArch.h/cpp.
Following llvm#137070, this PR adds an initial set of Intel `OffloadArch` values with corresponding predicates that will be used in SYCL offloading. More Intel architectures will be added in a future PR.
Currently, the OffloadArch enum is defined Cuda.h. This PR moves the definition to a more generic location in OffloadArch.h/cpp.
Following llvm#137070, this PR adds an initial set of Intel `OffloadArch` values with corresponding predicates that will be used in SYCL offloading. More Intel architectures will be added in a future PR.
Currently, the OffloadArch enum is defined Cuda.h. This PR moves the definition to a more generic location in OffloadArch.h/cpp.
Following llvm#137070, this PR adds an initial set of Intel `OffloadArch` values with corresponding predicates that will be used in SYCL offloading. More Intel architectures will be added in a future PR.
Following llvm#137070, this PR adds an initial set of Intel `OffloadArch` values with corresponding predicates that will be used in SYCL offloading. More Intel architectures will be added in a future PR.
Currently, the OffloadArch enum is defined Cuda.h. This PR moves the definition to a more generic location in OffloadArch.h/cpp.
Following llvm#137070, this PR adds an initial set of Intel `OffloadArch` values with corresponding predicates that will be used in SYCL offloading. More Intel architectures will be added in a future PR.
Currently, the OffloadArch enum is defined Cuda.h. This PR moves the definition to a more generic location in OffloadArch.h/cpp.