编辑: 添加了关于调试 MPI 应用程序的重要说明
系统安装的共享库没有调试符号:
$ readelf -S /usr/lib64/libfftw3.so | grep debug
$
因此,我在我的主目录中编译并安装了我自己的版本,并启用了调试 (--with-debug CFLAGS=-g
):
$ $ readelf -S ~/lib64/libfftw3.so | grep debug
[26] .debug_aranges PROGBITS 0000000000000000 001d3902
[27] .debug_pubnames PROGBITS 0000000000000000 001d8552
[28] .debug_info PROGBITS 0000000000000000 001ddebd
[29] .debug_abbrev PROGBITS 0000000000000000 003e221c
[30] .debug_line PROGBITS 0000000000000000 00414306
[31] .debug_str PROGBITS 0000000000000000 0044aa23
[32] .debug_loc PROGBITS 0000000000000000 004514de
[33] .debug_ranges PROGBITS 0000000000000000 0046bc82
我已经将 LD_LIBRARY_PATH 和 LD_RUN_PATH 设置为首先包含 ~/lib64
,ldd program
确认应该使用本地版本的库:
$ ldd a.out | grep fftw
libfftw3.so.3 => /home/narebski/lib64/libfftw3.so.3 (0x00007f2ed9a98000)
有问题的程序是并行数值应用,使用 MPI (消息传递接口(interface))。因此,要运行此应用程序,必须使用 mpirun
包装器(例如 mpirun -np 1 valgrind --tool=callgrind ./a.out
)。我使用 OpenMPI 实现。
然而,各种分析器:callgrind Valgrind 中的工具, CPU profiling google-perfutils和 perf没有找到那些调试符号,导致或多或少的无用输出:
钙磨:
$ callgrind_annotate --include=~/prog/src --inclusive=no --tree=none [...] -------------------------------------------------------------------------------- Ir file:function -------------------------------------------------------------------------------- 32,765,904,336 ???:0x000000000014e500 [/usr/lib64/libfftw3.so.3.2.4] 31,342,886,912 /home/narebski/prog/src/nonlinearity.F90:__nonlinearity_MOD_calc_nonlinearity_kxky [/home/narebski/prog/bin/a.out] 30,288,261,120 /home/narebski/gene11/src/axpy.F90:__axpy_MOD_axpy_ij [/home/narebski/prog/bin/a.out] 23,429,390,736 ???:0x00000000000fc5e0 [/usr/lib64/libfftw3.so.3.2.4] 17,851,018,186 ???:0x00000000000fdb80 [/usr/lib64/libmpi.so.1.0.1]
谷歌性能工具:
$ pprof --text a.out prog.prof Total: 8401 samples 842 10.0% 10.0% 842 10.0% 00007f200522d5f0 619 7.4% 17.4% 5025 59.8% calc_nonlinearity_kxky 517 6.2% 23.5% 517 6.2% axpy_ij 427 5.1% 28.6% 3156 37.6% nl_to_direct_xy 307 3.7% 32.3% 1234 14.7% nl_to_fourier_xy_1d
性能事件:
$ perf report --sort comm,dso,symbol # Events: 80K cycles # # Overhead Command Shared Object Symbol # ........ ....... .................... ............................................ # 32.42% a.out libfftw3.so.3.2.4 [.] fdc4c 16.25% a.out 7fddcd97bb22 [.] 7fddcd97bb22 7.51% a.out libatlas.so.0.0.0 [.] ATL_dcopy_xp1yp1aXbX 6.98% a.out a.out [.] __nonlinearity_MOD_calc_nonlinearity_kxky 5.82% a.out a.out [.] __axpy_MOD_axpy_ij
编辑于 2011 年 7 月 11 日添加:
我不知道这是否重要,但是:
$ file /usr/lib64/libfftw3.so.3.2.4
/usr/lib64/libfftw3.so.3.2.4: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, stripped
和
$ file ~/lib64/libfftw3.so.3.2.4
/home/narebski/lib64/libfftw3.so.3.2.4: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, not stripped
最佳答案
如果 /usr/lib64/libfftw3.so.3.2.4
列在 callgrind 输出中,那么您的 LD_LIBRARY_PATH=~/lib64
没有效果.
再试一次 export LD_LIBRARY_PATH=$HOME/lib64
。还要注意您调用的任何 shell 脚本,它们可能会重置您的环境。
关于linux - 使用 mpirun 时,如何使分析器(valgrind、perf、pprof)获取/使用带有调试符号的本地版本的库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6633615/