Add BiSheng Autotuner support
Signed-off-by: liyunfei <liyunfei33@huawei.com>
This commit is contained in:
parent
955b6790f5
commit
8c1b2b0fcd
56
0006-Add-BiSheng-Autotuner-support-for-LLVM-compiler.patch
Normal file
56
0006-Add-BiSheng-Autotuner-support-for-LLVM-compiler.patch
Normal file
@ -0,0 +1,56 @@
|
||||
From a9863e2b6e6783aa9be0b9d1d187084fd4b32a3a Mon Sep 17 00:00:00 2001
|
||||
From: Muhammad Asif Manzoor <muhammad.asif.manzoor1@huawei.com>
|
||||
Date: Thu, 21 Mar 2024 12:50:38 -0400
|
||||
Subject: [PATCH] Add BiSheng Autotuner support for LLVM compiler
|
||||
|
||||
Automatic tuning is an automatic iterative process that optimizes a given
|
||||
program by manipulating compilation options for optimal performance.
|
||||
BiSheng Autotuner provides a resumable interface for tuning process. BiSheng
|
||||
Autotuner can tune 1) individual code segments/blocks (fine grain turning) like
|
||||
loops, callsites, instructions, etc. and 2) entire modules/programs (coarse
|
||||
grain tuning) for compiler flags, pass ordering, etc.
|
||||
This patch enables LLVM compiler to extract tuneable code regions and then apply
|
||||
suggested configuration (by Autotuner) to find out the optimal configurations.
|
||||
---
|
||||
lld/ELF/Driver.cpp | 18 ++++++++++++++++++
|
||||
1 file changed, 18 insertions(+)
|
||||
|
||||
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
|
||||
index c2059c70e15a..ffd0842b9078 100644
|
||||
--- a/lld/ELF/Driver.cpp
|
||||
+++ b/lld/ELF/Driver.cpp
|
||||
@@ -341,6 +341,18 @@ void LinkerDriver::addLibrary(StringRef name) {
|
||||
// Technically this can be delayed until we read bitcode files, but
|
||||
// we don't bother to do lazily because the initialization is fast.
|
||||
static void initLLVM() {
|
||||
+#if defined(ENABLE_AUTOTUNER)
|
||||
+ // AUTO-TUNING - initialization
|
||||
+ if (Error E = autotuning::Engine.init(config->outputFile.data())) {
|
||||
+ error(toString(std::move(E)));
|
||||
+ return;
|
||||
+ }
|
||||
+ if (autotuning::Engine.isEnabled() && autotuning::Engine.isParseInput() &&
|
||||
+ (autotuning::Engine.LLVMParams.size() ||
|
||||
+ autotuning::Engine.ProgramParams.size()))
|
||||
+ llvm::cl::ParseAutoTunerOptions(autotuning::Engine.LLVMParams,
|
||||
+ autotuning::Engine.ProgramParams);
|
||||
+#endif
|
||||
InitializeAllTargets();
|
||||
InitializeAllTargetMCs();
|
||||
InitializeAllAsmPrinters();
|
||||
@@ -2814,6 +2826,12 @@ void LinkerDriver::link(opt::InputArgList &args) {
|
||||
reportBackrefs();
|
||||
writeArchiveStats();
|
||||
writeWhyExtract();
|
||||
+#if defined(ENABLE_AUTOTUNER)
|
||||
+ // AUTO-TUNING - finalization
|
||||
+ if (Error E = autotuning::Engine.finalize()) {
|
||||
+ error(toString(std::move(E)));
|
||||
+ }
|
||||
+#endif
|
||||
if (errorCount())
|
||||
return;
|
||||
|
||||
--
|
||||
2.33.0
|
||||
|
||||
10
lld.spec
10
lld.spec
@ -1,6 +1,7 @@
|
||||
%bcond_without sys_llvm
|
||||
%bcond_without check
|
||||
%bcond_without toolchain_clang
|
||||
%bcond_without bisheng_autotuner
|
||||
|
||||
%if %{with toolchain_clang}
|
||||
%global toolchain clang
|
||||
@ -37,7 +38,7 @@
|
||||
|
||||
Name: %{pkg_name}
|
||||
Version: %{maj_ver}.%{min_ver}.%{patch_ver}
|
||||
Release: 3
|
||||
Release: 4
|
||||
Summary: The LLVM Linker
|
||||
|
||||
License: NCSA
|
||||
@ -49,6 +50,7 @@ Patch2: 0002-Backport-lld-LoongArch-Support-the-R_LARCH_-ADD-SUB-6-relocation-t
|
||||
Patch3: 0003-Backport-ELF-RISCV-Implement-emit-relocs-with-relaxation.patch
|
||||
Patch4: 0004-Backport-lld-ELF-Support-relax-R_LARCH_ALIGN.patch
|
||||
Patch5: 0005-Backport-lld-LoongArch-Support-the-R_LARCH_-ADD-SUB-_ULEB128-relocation-types.patch
|
||||
Patch6: 0006-Add-BiSheng-Autotuner-support-for-LLVM-compiler.patch
|
||||
|
||||
BuildRequires: clang
|
||||
BuildRequires: cmake
|
||||
@ -112,6 +114,9 @@ cd _build
|
||||
%if "%{toolchain}" == "clang"
|
||||
-DCMAKE_C_COMPILER=clang \
|
||||
-DCMAKE_CXX_COMPILER=clang++ \
|
||||
%endif
|
||||
%if %{with bisheng_autotuner}
|
||||
-DENABLE_AUTOTUNER=ON \
|
||||
%endif
|
||||
-DLLVM_MAIN_SRC_DIR=%{install_prefix}/src
|
||||
|
||||
@ -140,6 +145,9 @@ rm %{buildroot}%{install_includedir}/mach-o/compact_unwind_encoding.h
|
||||
%{install_libdir}/liblld*.so.*
|
||||
|
||||
%changelog
|
||||
* Tue Jul 16 2024 liyunfei <liyunfei33@huawei.com> - 17.0.6-4
|
||||
- Add BiSheng Autotuner support.
|
||||
|
||||
* Fri Jul 5 2024 liyunfei <liyunfei33@huawei.com> - 17.0.6-3
|
||||
- Add toolchain_clang build support
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user