valgrind

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
valgrind [2016/10/25 05:25]
meesters [Things to consider when using Valgrind]
valgrind [2018/01/08 14:33]
meesters [On Mogon]
Line 11: Line 11:
 ===== On Mogon ===== ===== On Mogon =====
  
-On Mogon, valgrind is compiled on the a*-nodes and available as the module ''software/valgrind/3.11.0''((as of 21. Oct. 2016)).+On Mogon, valgrind is compiled on the a*-nodes and available as the module ''debugger/Valgrind/<version>-<toolchain>''.
  
 ===== Things to consider when using Valgrind ===== ===== Things to consider when using Valgrind =====
  
 Valgrind's documentation is pretty good and straight forward, we recommend the [[http://valgrind.org/docs/manual/QuickStart.html|quick start tutorial]] as well as the actual [[http://valgrind.org/docs/manual/QuickStart.html|user manual]]. Valgrind's documentation is pretty good and straight forward, we recommend the [[http://valgrind.org/docs/manual/QuickStart.html|quick start tutorial]] as well as the actual [[http://valgrind.org/docs/manual/QuickStart.html|user manual]].
 +
 +==== Submitting jobs ====
  
 When submitting a job for profiling consider the run time overhead or else the profiling might be partial, skewed and the output abbreviated: The run time overhead of valgrind is substantial (sometimes >> 10x), therefore the test case should be small enough to run in reasonable time, yet big enough to yield meaningful results. This might require a trial and error approach for first set-ups. When submitting a job for profiling consider the run time overhead or else the profiling might be partial, skewed and the output abbreviated: The run time overhead of valgrind is substantial (sometimes >> 10x), therefore the test case should be small enough to run in reasonable time, yet big enough to yield meaningful results. This might require a trial and error approach for first set-ups.
  
 +==== Compiling for Valgrind ====
 +
 +Remember to compile with ''-g -O0'' (gcc, apply similar options for other compilers). ''-O1'' might also work, but line numbers will not be accurate any more.
 +
 +===== An example with visualization =====
 +
 +Imaging you submit a job like:
 +<code bash>
 + srun -p short -n 1 --mem 1800M -t 300 valgrind --tool=callgrind <path/to/cmd> [args]
 +</code>
 +where ''cmd'' is the program to profile with its optional arguments (''args'').
 +
 +This will produce an output file (e.g. ''callgrind.out.44289'', with 44289 being the PID of the process) which you can further analyze on the command line:
 +<code bash>
 +callgrind_annotate --auto=yes callgrind.out.44289 |less
 +</code>
 +
 +Or -- on login nodes -- with ''kcachegrind'':
 +<code bash>
 +kcachegrind callgrind.out.44289 &
 +</code>
  
 +giving results like {{ :kcachgrind.png?200 |}} (displaying a function with obvious potential for improvements).