!178 ACPO Infrastructure for ML integration into LLVM compiler

From: @eastb233 
Reviewed-by: @liyunfei33 
Signed-off-by: @liyunfei33
This commit is contained in:
openeuler-ci-bot 2024-11-21 02:19:50 +00:00 committed by Gitee
commit 30debf597f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 7972 additions and 1 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,34 @@
From d4cfa4fd4496735ea45afcd2b0cfb3607cadd1c9 Mon Sep 17 00:00:00 2001
From: yinrun <lvyinrun@huawei.com>
Date: Thu, 17 Oct 2024 18:47:40 +0800
Subject: [PATCH] Find Python3 in default env PATH for ACPO
Enable the use of user python version, avoid the wrong version of python without AI infra.
---
llvm/lib/Analysis/ACPOMLInterface.cpp | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Analysis/ACPOMLInterface.cpp b/llvm/lib/Analysis/ACPOMLInterface.cpp
index f48eb46638e3..7d84bd5112d6 100644
--- a/llvm/lib/Analysis/ACPOMLInterface.cpp
+++ b/llvm/lib/Analysis/ACPOMLInterface.cpp
@@ -146,7 +146,15 @@ ACPOMLPythonInterface::ACPOMLPythonInterface() : NextID{0} {
}
int32_t PID = (int32_t) llvm::sys::Process::getProcessId();
- std::string ExecPython = "/usr/bin/python3";
+ std::string ExecPython;
+ llvm::ErrorOr<std::string> Res = llvm::sys::findProgramByName("python3");
+ if (std::error_code EC = Res.getError()) {
+ LLVM_DEBUG(dbgs() << "python3 could not be found, error_code " << EC.value() << "\n");
+ return;
+ } else {
+ ExecPython = Res.get();
+ LLVM_DEBUG(dbgs() << "python3 version found in " << ExecPython << "\n");
+ }
std::string
PythonScript = *Env + "/" + std::string(ACPO_ML_PYTHON_INTERFACE_PY);
std::string PIDStr = std::to_string(PID);
--
2.38.1.windows.1

View File

@ -5,6 +5,7 @@
%bcond_with classic_flang %bcond_with classic_flang
%bcond_with toolchain_clang %bcond_with toolchain_clang
%bcond_without bisheng_autotuner %bcond_without bisheng_autotuner
%bcond_without ACPO
%if %{with toolchain_clang} %if %{with toolchain_clang}
%global toolchain clang %global toolchain clang
@ -46,7 +47,7 @@
Name: %{pkg_name} Name: %{pkg_name}
Version: %{maj_ver}.%{min_ver}.%{patch_ver} Version: %{maj_ver}.%{min_ver}.%{patch_ver}
Release: 26 Release: 28
Summary: The Low Level Virtual Machine Summary: The Low Level Virtual Machine
License: NCSA License: NCSA
@ -87,6 +88,9 @@ Patch27: 0027-AArch64-Delete-hip09-macro.patch
Patch28: 0028-backport-Clang-Fix-crash-with-fzero-call-used-regs.patch Patch28: 0028-backport-Clang-Fix-crash-with-fzero-call-used-regs.patch
Patch29: 0029-SimplifyLibCalls-Merge-sqrt-into-the-power-of-exp-79.patch Patch29: 0029-SimplifyLibCalls-Merge-sqrt-into-the-power-of-exp-79.patch
Patch30: 0030-LICM-Solve-runtime-error-caused-by-the-signal-functi.patch Patch30: 0030-LICM-Solve-runtime-error-caused-by-the-signal-functi.patch
Patch31: 0031-ACPO-ACPO-Infrastructure.patch
Patch32: 0032-ACPO-Introduce-MLInliner-using-ACPO-infrastructure.patch
Patch33: 0033-Find-Python3-in-default-env-PATH-for-ACPO.patch
BuildRequires: binutils-devel BuildRequires: binutils-devel
BuildRequires: cmake BuildRequires: cmake
@ -202,6 +206,12 @@ pathfix.py -i %{__python3} -pn \
utils/update_cc_test_checks.py utils/update_cc_test_checks.py
%build %build
%if %{with ACPO}
echo "enable ACPO"
export CFLAGS="-Wp,-DENABLE_ACPO ${CFLAGS}"
export CXXFLAGS="-Wp,-DENABLE_ACPO ${CXXFLAGS}"
%endif
%cmake -G Ninja \ %cmake -G Ninja \
-DBUILD_SHARED_LIBS:BOOL=OFF \ -DBUILD_SHARED_LIBS:BOOL=OFF \
-DLLVM_PARALLEL_LINK_JOBS=%{max_link_jobs} \ -DLLVM_PARALLEL_LINK_JOBS=%{max_link_jobs} \
@ -380,6 +390,12 @@ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C %{__cmake
%{install_includedir}/llvm-gmock %{install_includedir}/llvm-gmock
%changelog %changelog
* Wed Nov 20 2024 eastb233 <xiezhiheng@huawei.com> - 17.0.6-28
- Find Python3 in default env PATH for ACPO
* Wed Nov 20 2024 eastb233 <xiezhiheng@huawei.com> - 17.0.6-27
- ACPO Infrastructure for ML integration into LLVM compiler
* Wed Nov 20 2024 eastb233 <xiezhiheng@huawei.com> - 17.0.6-26 * Wed Nov 20 2024 eastb233 <xiezhiheng@huawei.com> - 17.0.6-26
- [LICM] Solve runtime error caused by the signal function. - [LICM] Solve runtime error caused by the signal function.