diff options
Diffstat (limited to 'sys-devel/llvm-roc')
-rw-r--r-- | sys-devel/llvm-roc/Manifest | 2 | ||||
-rw-r--r-- | sys-devel/llvm-roc/files/llvm-roc-4.3.0-hip-location.patch | 2 | ||||
-rw-r--r-- | sys-devel/llvm-roc/files/llvm-roc-4.5.0-hip-location.patch | 189 |
3 files changed, 191 insertions, 2 deletions
diff --git a/sys-devel/llvm-roc/Manifest b/sys-devel/llvm-roc/Manifest index 8a30733..f49adad 100644 --- a/sys-devel/llvm-roc/Manifest +++ b/sys-devel/llvm-roc/Manifest @@ -7,7 +7,7 @@ AUX llvm-roc-4.1.0-fix-missing-include.patch 665 BLAKE2B f1bf71ef746cb7bf2671e88 AUX llvm-roc-4.2.0-add_Object.patch 439 BLAKE2B c59ab50959d94ea04d63b734d580f1e91e6fc12bab5ff94b2322a28388ffb2e9e2bd26905dc3095bc75c57248b6e9a0e8913a1d02054b06c7e5e3e72a05add93 SHA512 ed2ffebd3c79f2dbcdb77cbacffc9a546b35e11a7c523d524ad74b6b69eab7fca91e0d22af09bac42284865da1a332292dbe8a3df968e4364baf55996ea05823 AUX llvm-roc-4.2.0-current_pos.patch 1217 BLAKE2B 693e79cb895918f5e1a56be8d6624c049e8aa5640c55c34fc3fe27f053b7642670310ece321548df58f23e73d145f00d5c95b1e462eee008070cf6a2fde1c66c SHA512 fa8f773ba230e01f83526e4ae644fb2e7aceae99720cb5219c1b22baaabc5008f9b0151aee4c44ba9a4415ef421a8bfeb268302ee70e8c56428bf56c08b15903 AUX llvm-roc-4.2.0-cyclades.patch 3703 BLAKE2B 3250b2da548ffe759155fb673f0f81cfba1a918a8337aac72c8190edde18c0d14610b9734ac47c9e47570c35c6c28a525045f48acb446f70e7b6aa0706daab72 SHA512 694c38775a6353eba3c5bdcc39e2884a913f72b7a35dd5285ceed0ddf89456c9ca89fa2f5d801b6f4aa44f1301e3ceeb65f1641cd92d5128a91ebce5f42a261e -AUX llvm-roc-4.3.0-hip-location.patch 7128 BLAKE2B 6756bcad1c0bdef0729d3e7f2c6ea3468777623fb1493209956f436e9f234a1728e052c31ff064f8125c72d2a8cf68f425f76fb21cecf02680e999a6d5e7e41b SHA512 09f42ce7a37e072aa813036b78efd38cdaee54a1155fb347bf22f3f9f87441a6af83014fbc798f4d6d11966f40cf9c9fe6d3a8662b58be7859ab5b167eee37c2 +AUX llvm-roc-4.5.0-hip-location.patch 7128 BLAKE2B 3db0df96119c31d9264557844be8c1e598b5dff454e4f3c13bb32597c33d50b6d34a4ae5a069d6f5c84d8dc9325b0f0f0d67841a9651d484c2682f46607ae02c SHA512 8853211f253f60eee8b5c0bd40ee749231c912f49ca4fa84be9fa6db47e90381eabef116d09b766b19338379f546064202e26e16d2f3131516e69461047d65e4 DIST llvm-rocm-ocl-4.5.0.tar.gz 137372719 BLAKE2B 02cd8dee3df503efa7b5287d9584acb12e1c92bbeb2724584a066bb842132e9ac396c68ffef321078e6abce689ab2776bf89f98e23715aa4f4d63343ed7bfddf SHA512 45d5cb63502d18c96abcdaa00912bc87ded5c2e79b56bd3fbf8169d631f4d65c8755416e37d93ccd2188bd93187562278e75376f1b7f8c3b34b055f4c1e63138 EBUILD llvm-roc-4.5.0.ebuild 2591 BLAKE2B 3753eec614e6768e259741266df8d15662a4f9626a0848383ff47eefd306a397ee8c0cce5563c19ad0a51566d9d66a5fae0b10c302597f5be413e2b969920c1b SHA512 e0d7af57fb3d32a8788c53fa2c13b969caa4a3485c63858403e65771318bfb872af20546e85d90a9f0160b0f0d201ef3a71012ddc6b19159b0c053eb1d7c4d2f EBUILD llvm-roc-9999.ebuild 2599 BLAKE2B 4ab3a062ebfbd662c45baa8732389fd0c5a9dde1a9d6a66c41011754d9e3676dc7bcbbe86698fa7f3733c3f9141d4f59d2ab8caf8d2380c93dc2c0f81d41cea9 SHA512 e01bf053011c189a985e19eea8ed9702aa82df387fa1f0e2ef32ae0b3b87bd5f84e695231b431e19ee73b322d7d17cab89e8b2dc83e12023f6af52513ffb1fcf diff --git a/sys-devel/llvm-roc/files/llvm-roc-4.3.0-hip-location.patch b/sys-devel/llvm-roc/files/llvm-roc-4.3.0-hip-location.patch index 1fe93a3..4092255 100644 --- a/sys-devel/llvm-roc/files/llvm-roc-4.3.0-hip-location.patch +++ b/sys-devel/llvm-roc/files/llvm-roc-4.3.0-hip-location.patch @@ -6,7 +6,7 @@ Author: Benda Xu <heroxbd@gentoo.org> Author: Yiyang Wu <xgreenlandforwyy@gmail.com> --- orig/clang/lib/Driver/ToolChains/AMDGPU.cpp -+++ llvm-project-rocm-4.3.0/clang/lib/Driver/ToolChains/AMDGPU.cpp ++++ llvm-project-rocm-4.5.0/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -165,133 +165,8 @@ bool RocmInstallationDetector::parseHIPV /// cached and populated only once. const SmallVectorImpl<RocmInstallationDetector::Candidate> & diff --git a/sys-devel/llvm-roc/files/llvm-roc-4.5.0-hip-location.patch b/sys-devel/llvm-roc/files/llvm-roc-4.5.0-hip-location.patch new file mode 100644 index 0000000..4092255 --- /dev/null +++ b/sys-devel/llvm-roc/files/llvm-roc-4.5.0-hip-location.patch @@ -0,0 +1,189 @@ +replace hardcoded hip finder with Gentoo paths. + +It is not necessary to check HIP runtime each time. + +Author: Benda Xu <heroxbd@gentoo.org> +Author: Yiyang Wu <xgreenlandforwyy@gmail.com> + +--- orig/clang/lib/Driver/ToolChains/AMDGPU.cpp ++++ llvm-project-rocm-4.5.0/clang/lib/Driver/ToolChains/AMDGPU.cpp +@@ -165,133 +165,8 @@ bool RocmInstallationDetector::parseHIPV + /// cached and populated only once. + const SmallVectorImpl<RocmInstallationDetector::Candidate> & + RocmInstallationDetector::getInstallationPathCandidates() { +- +- // Return the cached candidate list if it has already been populated. +- if (!ROCmSearchDirs.empty()) +- return ROCmSearchDirs; +- +- auto DoPrintROCmSearchDirs = [&]() { +- if (PrintROCmSearchDirs) +- for (auto Cand : ROCmSearchDirs) { +- llvm::errs() << "ROCm installation search path"; +- if (Cand.isSPACK()) +- llvm::errs() << " (Spack " << Cand.SPACKReleaseStr << ")"; +- llvm::errs() << ": " << Cand.Path << '\n'; +- } +- }; +- +- // For candidate specified by --rocm-path we do not do strict check, i.e., +- // checking existence of HIP version file and device library files. +- if (!RocmPathArg.empty()) { +- ROCmSearchDirs.emplace_back(RocmPathArg.str()); +- DoPrintROCmSearchDirs(); +- return ROCmSearchDirs; +- } else if (const char *RocmPathEnv = ::getenv("ROCM_PATH")) { +- if (!StringRef(RocmPathEnv).empty()) { +- ROCmSearchDirs.emplace_back(RocmPathEnv); +- DoPrintROCmSearchDirs(); +- return ROCmSearchDirs; +- } +- } +- +- // Try to find relative to the compiler binary. +- const char *InstallDir = D.getInstalledDir(); +- +- // Check both a normal Unix prefix position of the clang binary, as well as +- // the Windows-esque layout the ROCm packages use with the host architecture +- // subdirectory of bin. +- auto DeduceROCmPath = [](StringRef ClangPath) { +- // Strip off directory (usually bin) +- StringRef ParentDir = llvm::sys::path::parent_path(ClangPath); +- StringRef ParentName = llvm::sys::path::filename(ParentDir); +- +- // Some builds use bin/{host arch}, so go up again. +- if (ParentName == "bin") { +- ParentDir = llvm::sys::path::parent_path(ParentDir); +- ParentName = llvm::sys::path::filename(ParentDir); +- } +- +- // Detect ROCm packages built with SPACK. +- // clang is installed at +- // <rocm_root>/llvm-amdgpu-<rocm_release_string>-<hash>/bin directory. +- // We only consider the parent directory of llvm-amdgpu package as ROCm +- // installation candidate for SPACK. +- if (ParentName.startswith("llvm-amdgpu-")) { +- auto SPACKPostfix = +- ParentName.drop_front(strlen("llvm-amdgpu-")).split('-'); +- auto SPACKReleaseStr = SPACKPostfix.first; +- if (!SPACKReleaseStr.empty()) { +- ParentDir = llvm::sys::path::parent_path(ParentDir); +- return Candidate(ParentDir.str(), /*StrictChecking=*/true, +- SPACKReleaseStr); +- } +- } +- +- // Some versions of the rocm llvm package install to /opt/rocm/llvm/bin +- // Some versions of the aomp package install to /opt/rocm/aomp/bin +- if (ParentName == "llvm" || ParentName.startswith("aomp")) +- ParentDir = llvm::sys::path::parent_path(ParentDir); +- +- return Candidate(ParentDir.str(), /*StrictChecking=*/true); +- }; +- +- // Deduce ROCm path by the path used to invoke clang. Do not resolve symbolic +- // link of clang itself. +- ROCmSearchDirs.emplace_back(DeduceROCmPath(InstallDir)); +- +- // Deduce ROCm path by the real path of the invoked clang, resolving symbolic +- // link of clang itself. +- llvm::SmallString<256> RealClangPath; +- llvm::sys::fs::real_path(D.getClangProgramPath(), RealClangPath); +- auto ParentPath = llvm::sys::path::parent_path(RealClangPath); +- if (ParentPath != InstallDir) +- ROCmSearchDirs.emplace_back(DeduceROCmPath(ParentPath)); +- +- // Device library may be installed in clang resource directory. +- ROCmSearchDirs.emplace_back(D.ResourceDir, +- /*StrictChecking=*/true); +- +- ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/rocm", +- /*StrictChecking=*/true); +- +- // Find the latest /opt/rocm-{release} directory. +- std::error_code EC; +- std::string LatestROCm; +- llvm::VersionTuple LatestVer; +- // Get ROCm version from ROCm directory name. +- auto GetROCmVersion = [](StringRef DirName) { +- llvm::VersionTuple V; +- std::string VerStr = DirName.drop_front(strlen("rocm-")).str(); +- // The ROCm directory name follows the format of +- // rocm-{major}.{minor}.{subMinor}[-{build}] +- std::replace(VerStr.begin(), VerStr.end(), '-', '.'); +- V.tryParse(VerStr); +- return V; +- }; +- for (llvm::vfs::directory_iterator +- File = D.getVFS().dir_begin(D.SysRoot + "/opt", EC), +- FileEnd; +- File != FileEnd && !EC; File.increment(EC)) { +- llvm::StringRef FileName = llvm::sys::path::filename(File->path()); +- if (!FileName.startswith("rocm-")) +- continue; +- if (LatestROCm.empty()) { +- LatestROCm = FileName.str(); +- LatestVer = GetROCmVersion(LatestROCm); +- continue; +- } +- auto Ver = GetROCmVersion(FileName); +- if (LatestVer < Ver) { +- LatestROCm = FileName.str(); +- LatestVer = Ver; +- } +- } +- if (!LatestROCm.empty()) +- ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, +- /*StrictChecking=*/true); +- +- DoPrintROCmSearchDirs(); +- return ROCmSearchDirs; ++ ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", /*StrictChecking=*/true); ++ return ROCmSearchDirs; + } + + RocmInstallationDetector::RocmInstallationDetector( +@@ -423,42 +298,7 @@ void RocmInstallationDetector::detectDev + } + + void RocmInstallationDetector::detectHIPRuntime() { +- SmallVector<Candidate, 4> HIPSearchDirs; +- if (!HIPPathArg.empty()) +- HIPSearchDirs.emplace_back(HIPPathArg.str(), /*StrictChecking=*/true); +- else +- HIPSearchDirs.append(getInstallationPathCandidates()); +- auto &FS = D.getVFS(); +- +- for (const auto &Candidate : HIPSearchDirs) { +- InstallPath = Candidate.Path; +- if (InstallPath.empty() || !FS.exists(InstallPath)) +- continue; +- // HIP runtime built by SPACK is installed to +- // <rocm_root>/hip-<rocm_release_string>-<hash> directory. +- auto SPACKPath = findSPACKPackage(Candidate, "hip"); +- InstallPath = SPACKPath.empty() ? InstallPath : SPACKPath; +- +- BinPath = InstallPath; +- llvm::sys::path::append(BinPath, "bin"); +- IncludePath = InstallPath; +- llvm::sys::path::append(IncludePath, "include"); +- LibPath = InstallPath; +- llvm::sys::path::append(LibPath, "lib"); +- +- llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> VersionFile = +- FS.getBufferForFile(BinPath + "/.hipVersion"); +- if (!VersionFile && Candidate.StrictChecking) +- continue; +- +- if (HIPVersionArg.empty() && VersionFile) +- if (parseHIPVersionFile((*VersionFile)->getBuffer())) +- continue; +- +- HasHIPRuntime = true; +- return; +- } +- HasHIPRuntime = false; ++ HasHIPRuntime = true; + } + + void RocmInstallationDetector::print(raw_ostream &OS) const { |