计算精度分析工具用于定位x86和鲲鹏指令引起的C/C++语言精度差异问题。
此处以扫描“/home/test/demo2”路径下源码文件为例,编译命令为cmake ..、make,请根据实际情况进行修改。
demo2文件目录结构:
1 2 3 4 5 6 7 8 9 10 11 12 |
demo2 ├── benchmark.c ├── build ├── CMakeLists.txt ├── include │ ├── complex.h │ └── fft.h ├── lib │ ├── complex.c │ └── fft.c ├── README.md └── test.c |
1 2 3 |
cd /home/test/demo2/build cmake .. devkit advisor precision -instrument -c make -p /home/test/demo2 -e test.c:main -d 1 |
回显信息如下:
Perform the instrumentation and compilation mode. Finish run precision check tool. For detail logs on the tool, see /Path_to_DevKit_CLI/advisor/logs/preccheck.log and /home/test/demo2/build/precision_20250221082942_78fd.txt Please check whether error information exists in above two files to ensure that the project can run properly. Before running the project to get the log file, please add: 1) the libcorrect.mod file path: export LD_LIBRARY_PATH=/ /Path_to_DevKit_CLI//advisor/devkitplugins/affinity/tools/compileopt/libcruiser/gnu_lib:$LD_LIBRARY_PATH 2) the log file path: export CRUISER_LOG=/LOGPATH/
export LD_LIBRARY_PATH=/Path_to_DevKit_CLI/advisor/devkitplugins/affinity/tools/compileopt/libcruiser/gnu_lib:$LD_LIBRARY_PATH
Clang:
export LD_LIBRARY_PATH=/Path_to_DevKit_CLI/advisor/devkitplugins/affinity/tools/compileopt/libcruiser/bisheng_lib:$LD_LIBRARY_PATH
icc:
export LD_LIBRARY_PATH=/Path_to_DevKit_CLI/advisor/devkitplugins/affinity/tools/compileopt/libcruiser/user_lib:$LD_LIBRARY_PATH
export CRUISER_LOG=/LOGPATH/
“/LOGPATH/”:生成的日志文件存放路径,存放路径下必须为空。
./test
运行可执行文件后若有以下输出信息,表示日志文件所在路径磁盘空间已不满足5G,请清理磁盘空间。
1
|
[WARNING] The remaining space is less than 5 GB in /home/test1, please clear enough space and run the program again. |
test:生成的可执行文件。
生成日志时请注意磁盘空间大小。
1 2 3 4 5 6 7 |
test.c|main|=|37|array_p[0]|2167530|886b21e841552361bf877c4e7801931e test.c|main|=|42|*(p.p)|2167530|2f8f10c2df86a30c87871a57a85bed5c test.c|main|=|44|p.p[0]|2167530|886b21e841552361bf877c4e7801931e test.c|main|=|48|*(p.pa[0])|2167530|2f8f10c2df86a30c87871a57a85bed5c test.c|main|=|50|p.pa[0][1]|2167530|2f8f10c2df86a30c87871a57a85bed5c test.c|main|=|59|array1|2167530|40fa79220b4a04a64e4d49b542c45ee2 test.c|main|=|74|res|2167530|57f18dfd63d01a1223a0d88683fcca95 |
日志文件中的每条日志分为七部分内容,以图中日志信息为例,对每部分内容进行解释。
1:文件名。
2:第三部分内容表达式语句所在的当前最小作用域名称,可能是函数、子例程或主程序。
3:当插桩变量位于函数调用语句(作为函数参数)时,此处为被调用函数名;当插桩变量位于赋值语句时,此处为“=”号。
4:行号。
5:插桩变量名。
6:线程ID。
7:插桩变量值对应的HASH值。
1
|
devkit advisor precision -analysis -i "/home/kunpeng;/home/x86" |
回显信息如下:
Perform the logs analysis mode. Finish run precision check tool. For detail logs on the tool, see /Path_to_DevKit_CLI/advisor/logs/preccheck.log and /home/test1/demo2/build/precision_20250221083857_c23f.txt The analysis result is in /home/test1/demo2/build/analysis_diff_20250221083926_423d.txt