-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Clang][SYCL] Add initial set of Intel OffloadArch values #138158
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: Justin Cai (jzc) ChangesFollowing #137070, this PR adds an initial set of Intel Full diff: https://github.com/llvm/llvm-project/pull/138158.diff 6 Files Affected:
diff --git a/clang/include/clang/Basic/OffloadArch.h b/clang/include/clang/Basic/OffloadArch.h
index c5ccd17e7a8be..c681f99f2e146 100644
--- a/clang/include/clang/Basic/OffloadArch.h
+++ b/clang/include/clang/Basic/OffloadArch.h
@@ -101,6 +101,13 @@ enum class OffloadArch {
AMDGCNSPIRV,
Generic, // A processor model named 'generic' if the target backend defines a
// public one.
+ // 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
+ GRANITERAPIDS,
+ // Intel GPUs
+ BMG_G21,
LAST,
CudaDefault = OffloadArch::SM_52,
@@ -116,6 +123,18 @@ static inline bool IsAMDOffloadArch(OffloadArch A) {
return A >= OffloadArch::GFX600 && A < OffloadArch::Generic;
}
+static inline bool IsIntelCPUOffloadArch(OffloadArch Arch) {
+ return Arch >= OffloadArch::GRANITERAPIDS && Arch < OffloadArch::BMG_G21;
+}
+
+static inline bool IsIntelGPUOffloadArch(OffloadArch Arch) {
+ return Arch >= OffloadArch::BMG_G21 && Arch < OffloadArch::LAST;
+}
+
+static inline bool IsIntelOffloadArch(OffloadArch Arch) {
+ return IsIntelCPUOffloadArch(Arch) || IsIntelGPUOffloadArch(Arch);
+}
+
const char *OffloadArchToString(OffloadArch A);
const char *OffloadArchToVirtualArchString(OffloadArch A);
diff --git a/clang/lib/Basic/OffloadArch.cpp b/clang/lib/Basic/OffloadArch.cpp
index 5e29742478b99..a019f0ac18c84 100644
--- a/clang/lib/Basic/OffloadArch.cpp
+++ b/clang/lib/Basic/OffloadArch.cpp
@@ -87,6 +87,10 @@ static const OffloadArchToStringMap ArchNames[] = {
GFX(1200), // gfx1200
GFX(1201), // gfx1201
{OffloadArch::AMDGCNSPIRV, "amdgcnspirv", "compute_amdgcn"},
+ // Intel CPUs
+ {OffloadArch::GRANITERAPIDS, "graniterapids", ""},
+ // Intel GPUS
+ {OffloadArch::BMG_G21, "bmg_g21", ""},
{OffloadArch::Generic, "generic", ""},
// clang-format on
};
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 59a5f7b914ce5..aa97422d54ede 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -2334,6 +2334,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 b0e0a97168757..8c8baa57b64e7 100644
--- a/clang/unittests/Basic/CMakeLists.txt
+++ b/clang/unittests/Basic/CMakeLists.txt
@@ -7,6 +7,7 @@ add_distinct_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..c19ad0043d774
--- /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(IsIntelCPUOffloadArch(OffloadArch::GRANITERAPIDS));
+ EXPECT_FALSE(IsIntelGPUOffloadArch(OffloadArch::GRANITERAPIDS));
+ EXPECT_TRUE(IsIntelOffloadArch(OffloadArch::BMG_G21));
+ EXPECT_FALSE(IsIntelCPUOffloadArch(OffloadArch::BMG_G21));
+ EXPECT_TRUE(IsIntelGPUOffloadArch(OffloadArch::BMG_G21));
+
+ EXPECT_FALSE(IsNVIDIAOffloadArch(OffloadArch::Generic));
+ EXPECT_FALSE(IsAMDOffloadArch(OffloadArch::Generic));
+ EXPECT_FALSE(IsIntelOffloadArch(OffloadArch::Generic));
+}
|
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 with a nit.
// 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. |
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 feel like this is unnecessary
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/11/builds/14237 Here is the relevant piece of the build log for the reference
|
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.
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.
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 #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.