User Tools

Site Tools


dev:debugging

Differences

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

Link to this comparison view

Next revision
Previous revision
dev:debugging [2014/05/10 07:16] – created debug info page vondeledev:debugging [2020/08/21 10:15] (current) – external edit 127.0.0.1
Line 27: Line 27:
  
 ===== valgrind ===== ===== valgrind =====
 +==== undefined variables ====
  
 [[ http://valgrind.org/ | valgrind ]] is very useful to find additional bugs, most commonly related to undefined variables. Unfortunately, the slowdown caused by valgrind makes this practical only for test cases that run within seconds/minutes. The full regtester is run from time to time under valgrind. [[ http://valgrind.org/ | valgrind ]] is very useful to find additional bugs, most commonly related to undefined variables. Unfortunately, the slowdown caused by valgrind makes this practical only for test cases that run within seconds/minutes. The full regtester is run from time to time under valgrind.
Line 52: Line 53:
 Run valgrind with  Run valgrind with 
 <code> <code>
-valgrind --max-stackframe=2100192  --leak-check=full --track-origins=yes+valgrind --max-stackframe=2100192 --leak-check=full --track-origins=yes
 </code> </code>
 to get the origin of undefined variables in addition to a leak check report. to get the origin of undefined variables in addition to a leak check report.
 +
 +
 +==== understanding memory usage ====
 +
 +valgrind also comes with the 'massif' tool, which can provide detailed information about memory usage. How much is the peak allocated memory, and where do most of these allocations come from? 
 +
 +Rather easy with
 +
 +<code>
 +valgrind --tool=massif ../../../exe/local_valgrind/cp2k.sopt test.inp 
 +ms_print massif.out.XYZ
 +</code>
 +
 +The valgrind homepage has [[http://valgrind.org/docs/manual/ms-manual.html | detailed description of massif]].
 +
 +==== valgrind in parallel ====
 +
 +valgrind can also be used for debugging parallel code, eg.:
 +
 +<code>
 +mpirun -np 2 -x OMP_NUM_THREADS=2  valgrind --max-stackframe=2100192 --leak-check=full --track-origins=yes cp2k.psmp cp2k.inp
 +</code>
  
 ===== Memory leak checking ===== ===== Memory leak checking =====
Line 68: Line 91:
 for the format of the file see [[ https://code.google.com/p/address-sanitizer/wiki/LeakSanitizer | LeakSanitizer ]] docs. for the format of the file see [[ https://code.google.com/p/address-sanitizer/wiki/LeakSanitizer | LeakSanitizer ]] docs.
  
 +===== Compiler warnings =====
  
 +Unfortunately is the GNU Fortran compiler not on the same level concerning warnings as its C/C++ counterparts. Especially the ''-Wunitialized'' which is part of ''-Wall'' may give spurious warnings of the following kind when building together with ''-O1'' (or greater):
  
 +<code>
 +attention : ‘arr.offset’ may be used uninitialized in this function [-Wuninitialized]
 +attention : ‘arr.dim[1].stride’ may be used uninitialized in this function [-Wuninitialized]
 +attention : ‘arr.dim[0].ubound’ may be used uninitialized in this function [-Wuninitialized]
 +</code>
  
- +This is tracked at GNU/gfortran upstream here [[https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66459|Bug 66459]] and [[https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60500|Bug 60500]]
- +
- +
  
dev/debugging.txt · Last modified: 2020/08/21 10:15 by 127.0.0.1