-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! fixup! rocm-compilersupport: Update to v6.2.4
Signed-off-by: Gavin Zhao <[email protected]>
- Loading branch information
1 parent
3bd334b
commit 9077bb5
Showing
6 changed files
with
193 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
packages/r/rocm-compilersupport/files/0001-Comgr-Extend-ISA-compatibility-for-CCOB.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
From 2d8c459a4d4c0567a7a275b4b54560d88e5c6919 Mon Sep 17 00:00:00 2001 | ||
From: Gavin Zhao <[email protected]> | ||
Date: Sat, 21 Dec 2024 09:43:46 -0500 | ||
Subject: [PATCH] [Comgr] Extend ISA compatibility for CCOB | ||
|
||
Signed-off-by: Gavin Zhao <[email protected]> | ||
--- | ||
amd/comgr/src/comgr-compiler.cpp | 57 +++++++++++++++++++++++++++++++- | ||
amd/comgr/src/comgr-metadata.h | 2 ++ | ||
2 files changed, 58 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/amd/comgr/src/comgr-compiler.cpp b/amd/comgr/src/comgr-compiler.cpp | ||
index 9f39b939dd12..cdd14650d83a 100644 | ||
--- a/amd/comgr/src/comgr-compiler.cpp | ||
+++ b/amd/comgr/src/comgr-compiler.cpp | ||
@@ -39,6 +39,7 @@ | ||
#include "comgr-compiler.h" | ||
#include "comgr-device-libs.h" | ||
#include "comgr-env.h" | ||
+#include "comgr-metadata.h" | ||
#include "lld/Common/CommonLinkerContext.h" | ||
#include "lld/Common/Driver.h" | ||
#include "clang/Basic/Version.h" | ||
@@ -1298,9 +1299,63 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() { | ||
size_t index = output_prefix.find_last_of("."); | ||
output_prefix = output_prefix.substr(0, index); | ||
|
||
+ std::set<std::string> co_entry_ids; | ||
+ if (auto Error = OffloadBundler::GetBundleIDsInFile(input_file_path, BundlerConfig, co_entry_ids)) { | ||
+ if (env::shouldEmitVerboseLogs()) { | ||
+ LogS << "Failed to get bundle IDs in " | ||
+ << input_file_path | ||
+ << ", not trying to coerce compatible archs\n"; | ||
+ LogS.flush(); | ||
+ } | ||
+ } | ||
+ std::set<std::pair<std::string, std::string>> entry_ids_with_idents; | ||
+ for (const auto& co_entry_id : co_entry_ids) { | ||
+ std::string target_ident; | ||
+ size_t pos = std::string::npos; | ||
+ for (const auto& prefix : {"hipv4-", "hip-"}) { | ||
+ if ((pos = co_entry_id.find(prefix)) == 0) { | ||
+ target_ident = co_entry_id.substr(std::char_traits<char>::length(prefix)); | ||
+ break; | ||
+ } | ||
+ } | ||
+ | ||
+ if (target_ident.empty()) { | ||
+ continue; | ||
+ } | ||
+ | ||
+ entry_ids_with_idents.emplace(co_entry_id, target_ident); | ||
+ } | ||
+ | ||
// Bundler target and output names | ||
for (auto entry: ActionInfo->BundleEntryIDs) { | ||
- BundlerConfig.TargetNames.push_back(entry); | ||
+ std::string compat_entry = entry; | ||
+ | ||
+ std::string entry_ident; | ||
+ size_t pos = std::string::npos; | ||
+ for (const auto& prefix : {"hipv4-", "hip-"}) { | ||
+ if ((pos = entry.find(prefix)) == 0) { | ||
+ entry_ident = entry.substr(std::char_traits<char>::length(prefix)); | ||
+ break; | ||
+ } | ||
+ } | ||
+ | ||
+ if (!entry_ident.empty()) { | ||
+ std::string best_entry; | ||
+ for (const auto& [co_entry, co_ident] : entry_ids_with_idents) { | ||
+ if (entry_ident == co_ident) { | ||
+ best_entry = co_entry; | ||
+ break; | ||
+ } else if (metadata::isCompatibleIsaName(entry_ident, co_ident)) { | ||
+ best_entry = co_entry; | ||
+ } | ||
+ } | ||
+ | ||
+ if (!best_entry.empty()) { | ||
+ compat_entry = best_entry; | ||
+ } | ||
+ } | ||
+ | ||
+ BundlerConfig.TargetNames.push_back(compat_entry); | ||
|
||
// Add an output file for each target | ||
std::string output_file_name = output_prefix + '-' + entry + "." + | ||
diff --git a/amd/comgr/src/comgr-metadata.h b/amd/comgr/src/comgr-metadata.h | ||
index 8c2ba7ee4f9f..08aebdb76e89 100644 | ||
--- a/amd/comgr/src/comgr-metadata.h | ||
+++ b/amd/comgr/src/comgr-metadata.h | ||
@@ -55,6 +55,8 @@ amd_comgr_status_t getIsaMetadata(llvm::StringRef IsaName, | ||
|
||
bool isValidIsaName(llvm::StringRef IsaName); | ||
|
||
+bool isCompatibleIsaName(llvm::StringRef IsaName, llvm::StringRef CodeObjectIsaName); | ||
+ | ||
amd_comgr_status_t getElfIsaName(DataObject *DataP, std::string &IsaName); | ||
|
||
amd_comgr_status_t lookUpCodeObject(DataObject *DataP, | ||
-- | ||
2.47.0 | ||
|
83 changes: 83 additions & 0 deletions
83
packages/r/rocm-compilersupport/files/0001-Comgr-Extend-ISA-compatibility.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
From a439e4f37ce71de48d4a979594276e3be0e6278f Mon Sep 17 00:00:00 2001 | ||
From: Gavin Zhao <[email protected]> | ||
Date: Fri, 20 Dec 2024 16:04:41 -0500 | ||
Subject: [PATCH] [Comgr] Extend ISA compatibility | ||
|
||
Signed-off-by: Gavin Zhao <[email protected]> | ||
--- | ||
amd/comgr/src/comgr-metadata.cpp | 52 +++++++++++++++++++++++++++++++- | ||
1 file changed, 51 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/amd/comgr/src/comgr-metadata.cpp b/amd/comgr/src/comgr-metadata.cpp | ||
index 5571808be0e7..dcd4e66927a8 100644 | ||
--- a/amd/comgr/src/comgr-metadata.cpp | ||
+++ b/amd/comgr/src/comgr-metadata.cpp | ||
@@ -923,6 +923,55 @@ static constexpr const char *CLANG_OFFLOAD_BUNDLER_MAGIC = | ||
static constexpr size_t OffloadBundleMagicLen = | ||
strLiteralLength(CLANG_OFFLOAD_BUNDLER_MAGIC); | ||
|
||
+struct GfxPattern { | ||
+ StringRef root; | ||
+ StringRef suffixes; | ||
+}; | ||
+ | ||
+static bool matches(const GfxPattern& p, const StringRef s) { | ||
+ if (p.root.size() + 1 != s.size()) { | ||
+ return false; | ||
+ } | ||
+ if (0 != std::memcmp(p.root.data(), s.data(), p.root.size())) { | ||
+ return false; | ||
+ } | ||
+ return p.suffixes.find(s[p.root.size()]) != std::string::npos; | ||
+} | ||
+ | ||
+static bool isGfx900EquivalentProcessor(const StringRef processor) { | ||
+ return matches(GfxPattern{"gfx90", "029c"}, processor); | ||
+} | ||
+ | ||
+static bool isGfx900SupersetProcessor(const StringRef processor) { | ||
+ return matches(GfxPattern{"gfx90", "0269c"}, processor); | ||
+} | ||
+ | ||
+static bool isGfx1030EquivalentProcessor(const StringRef processor) { | ||
+ return matches(GfxPattern{"gfx103", "0123456"}, processor); | ||
+} | ||
+ | ||
+static bool isGfx1010EquivalentProcessor(const StringRef processor) { | ||
+ return matches(GfxPattern{"gfx101", "0"}, processor); | ||
+} | ||
+ | ||
+static bool isGfx1010SupersetProcessor(const StringRef processor) { | ||
+ return matches(GfxPattern{"gfx101", "0123"}, processor); | ||
+} | ||
+ | ||
+static bool isIsaCompatible(const StringRef isaIdent, const StringRef codeObjectIdent) { | ||
+ if (isaIdent == codeObjectIdent) { | ||
+ return true; | ||
+ } else if (isGfx900SupersetProcessor(isaIdent) && isGfx900EquivalentProcessor(codeObjectIdent)) { | ||
+ return true; | ||
+ } else if (isGfx1010SupersetProcessor(isaIdent) && isGfx1010EquivalentProcessor(codeObjectIdent)) { | ||
+ return true; | ||
+ } else if (isGfx1030EquivalentProcessor(isaIdent) && isGfx1030EquivalentProcessor(codeObjectIdent)) { | ||
+ return true; | ||
+ } else { | ||
+ return false; | ||
+ } | ||
+} | ||
+ | ||
bool isCompatibleIsaName(StringRef IsaName, StringRef CodeObjectIsaName) { | ||
if (IsaName == CodeObjectIsaName) { | ||
return true; | ||
@@ -938,7 +987,8 @@ bool isCompatibleIsaName(StringRef IsaName, StringRef CodeObjectIsaName) { | ||
return false; | ||
} | ||
|
||
- if (CodeObjectIdent.Processor != IsaIdent.Processor) { | ||
+ if (CodeObjectIdent.Processor != IsaIdent.Processor | ||
+ && !isIsaCompatible(IsaIdent.Processor, CodeObjectIdent.Processor)) { | ||
return false; | ||
} | ||
|
||
-- | ||
2.47.0 | ||
|
78 changes: 0 additions & 78 deletions
78
...r/rocm-compilersupport/files/0001-Extend-ROCm-CompilerSupport-HIP-ISA-compatibility.patch
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters