Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make profilers (valgrind, perf, pprof) pick up / use local version of library with debugging symbols when using mpirun?

Edit: added important note that it is about debugging MPI application

System installed shared library doesn't have debugging symbols:

$ readelf -S /usr/lib64/libfftw3.so | grep debug
$

I have therefore compiled and instaled in my home directory my owne version, with debugging enabled (--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

I have set both LD_LIBRARY_PATH and LD_RUN_PATH to include ~/lib64 first, and ldd program confirms that local version of library should be used:

$ ldd a.out | grep fftw
        libfftw3.so.3 => /home/narebski/lib64/libfftw3.so.3 (0x00007f2ed9a98000)

The program in question is parallel numerical application using MPI (Message Passing Interface). Therefore to run this application one must use mpirun wrapper (e.g. mpirun -np 1 valgrind --tool=callgrind ./a.out). I use OpenMPI implementation.

Nevertheless, various profilers: callgrind tool in Valgrind, CPU profiling google-perfutils and perf doesn't find those debugging symbols, resulting in more or less useless output:

  • calgrind:

    $ 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]
    
  • google-perftools:

    $ 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 events:

    $ 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
    

Edit Added 11-07-2011:
I don't know if it is important, but:

$ 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

and

$ 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
like image 927
Jakub Narębski Avatar asked Jul 09 '11 08:07

Jakub Narębski


1 Answers

If /usr/lib64/libfftw3.so.3.2.4 is listed in callgrind output, then your LD_LIBRARY_PATH=~/lib64 had no effect.

Try again with export LD_LIBRARY_PATH=$HOME/lib64. Also watch out for any shell scripts you invoke, which might reset your environment.

like image 125
Employed Russian Avatar answered Oct 04 '22 04:10

Employed Russian