11 Star 4 Fork 12

openEuler/A-FOT

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
auto_prefetch.sh 2.95 KB
一键复制 编辑 原始数据 按行查看 历史
yb 提交于 2024-08-29 12:40 . add auto_pgo and add support for llvm
#!/bin/bash
# 检测依赖软件是否已经安装
function check_dependency() {
check_common_dependency
if ! type create_gcov &>/dev/null; then
echo "[ERROR] Optimization mode ${opt_mode} but autofdo is missing, try 'yum install autofdo'."
exit 1
fi
}
# 根据模式选择Wrapper或者Bear模式构建
function prepare_env() {
case ${build_mode} in
"Wrapper")
create_wrapper
;;
"Bear")
export COMPILATION_OPTIONS="-g"
export LINK_OPTIONS="-g"
;;
*)
echo "[ERROR] Build mode ${build_mode} is not supported, the value is : Wrapper/Bear"
exit 1
;;
esac
}
# 创建原始wrapper
function create_wrapper() {
echo "[INFO] Start generating the original wrapper."
echo "${compiler_path}/bin/${c_compiler} -g \"\$@\"" >${compiler_wrapper}/${c_compiler}
echo "${compiler_path}/bin/${cxx_compiler} -g \"\$@\"" >${compiler_wrapper}/${cxx_compiler}
post_create_wrapper
}
# 执行perf采样,生成profile文件
function profiling () {
echo "[INFO] Start perf record by ${opt_mode} and generate a profile file."
process_id=$(pidof ${application_name})
get_arch=$(arch)
if [[ ${get_arch} =~ "x86_64" ]]; then
perf_event="inst_retired.prec_dist:u,cache-misses:u"
gcov_file_name="${profile_data_path}/${gcov_name}.inst_retired.prec_dist:u"
elif [[ ${get_arch} =~ "aarch64" ]]; then
perf_event="inst_retired:u,cache-misses:u"
gcov_file_name="${profile_data_path}/${gcov_name}.inst_retired:u"
else
echo "[ERROR] Unsupport arch: ${get_arch}"
exit 1
fi
perf record -e ${perf_event} -o ${profile_data_path}/${profile_name} -p ${process_id} -- sleep ${perf_time} >>${log_file} 2>&1
is_file_exist "${profile_data_path}/${profile_name}"
create_gcov --binary=${bin_file} --profile=${profile_data_path}/${profile_name} --gcov=${profile_data_path}/${gcov_name} --gcov_version=1 --use_lbr=0 >>${log_file} 2>&1
is_file_exist "${gcov_file_name}"
is_file_exist "${profile_data_path}/${gcov_name}.cache-misses:u"
pkill ${application_name}
}
# 根据模式选择Wrapper或者Bear模式构建
function prepare_new_env() {
case ${build_mode} in
"Wrapper")
create_new_wrapper
;;
"Bear")
export COMPILATION_OPTIONS="-fauto-profile=${gcov_file_name} -fcache-misses-profile=${profile_data_path}/${gcov_name}.cache-misses:u -fprefetch-loop-arrays=2"
;;
*)
echo "[ERROR] Build mode ${build_mode} is not supported, the value is : Wrapper/Bear"
exit 1
;;
esac
}
#生成新的wrapper
function create_new_wrapper() {
echo "[INFO] Start to generate a new wrapper."
echo "${compiler_path}/bin/${c_compiler} -fauto-profile=${gcov_file_name} -fcache-misses-profile=${profile_data_path}/${gcov_name}.cache-misses\:u -fprefetch-loop-arrays=2 \"\$@\"" >${compiler_wrapper}/${c_compiler}
echo "${compiler_path}/bin/${cxx_compiler} -fauto-profile=${gcov_file_name} -fcache-misses-profile=${profile_data_path}/${gcov_name}.cache-misses\:u -fprefetch-loop-arrays=2 \"\$@\"" >${compiler_wrapper}/${cxx_compiler}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openeuler/A-FOT.git
git@gitee.com:openeuler/A-FOT.git
openeuler
A-FOT
A-FOT
master

搜索帮助