Profile信息指导优化
在原有的HBM静态方案的基础上,编译器提供了利用SPE、BRBE等profile信息指导HBM优化的功能。使用profile信息需要先进行一次编译执行用于profile信息采样,使用autofdo进行解析和转换后再进行二次编译,以下以SPE信息为为例。
- 获取profile信息:
- 首次编译,保留debug信息
1 2
// test.c为测试用例 clang -O3 -mcpu=hip11 -g -fdebug-info-for-profiling -Wl,--build-id test.c -o test.out
- 运行并利用perf采样, 获取spe.data(当前主要使用spe信息)
1perf record -o spe.data -e arm_spe// ./test.out
- 利用AutoFDO工具分析转换采样信息。 (过程中可能会报"Unsupported event"问题,是autofdo问题,不影响使用,输出spe.afdo非空即可)
1 2
export LD_LIBRARY_PATH=/home/user/gcc12.1-release/lib64/:$LD_LIBRARY_PATH create_llvm_prof --profiler=cachemisses --binary=./test.out --out=spe.afdo --profile=spe.data --perf_event_filter=llc_misses &> temp.txt
- 首次编译,保留debug信息
- 基于profile信息的HBM Cache自动预取选项"-fhbm-mode=cache"指定编译为HBM Cache模式,“-cachemiss-profile-llc=spe.afdo”指定使用spe.afdo文件中的profile信息作为LLC cache miss信息指导优化
1clang -O3 -mcpu=hip11 -fhbm-mode=cache -g -fdebug-info-for-profiling -mllvm -cachemiss-profile-llc=spe.afdo test.c -o test
- 基于profile信息的HBM Flat模式自动分配选项"-fhbm-mode=flat"指定编译为HBM Flat模式
1clang -O3 -mcpu=hip11 -fhbm-mode=flat -g -fdebug-info-for-profiling -mllvm -cachemiss-profile-llc=spe.afdo test.c -o test
父主题: HBM优化指导