diff --git a/docs.it4i/software/debuggers/valgrind.md b/docs.it4i/software/debuggers/valgrind.md index f08d8ce9dbadf8672565f4a50c581c0ff0303923..8c82a7e3683e05c1707ac7a2d1a5412593fda72c 100644 --- a/docs.it4i/software/debuggers/valgrind.md +++ b/docs.it4i/software/debuggers/valgrind.md @@ -15,24 +15,24 @@ The main tools available in Valgrind are: * **Hellgrind** and **DRD** can detect race conditions in multi-threaded applications. * **Cachegrind**, a cache profiler. * **Callgrind**, a callgraph analyzer. -* For a full list and detailed documentation, refer to the [official Valgrind documentation][b]. +* For more information, refer to the [official Valgrind documentation][b]. ## Installed Versions There are two versions of Valgrind available on Anselm. * Version 3.6.0, installed by operating system vendor in /usr/bin/valgrind. This version is available by default, without the need to load any module. This version however does not provide additional MPI support. -* Version 3.9.0 with support for Intel MPI, available in [module][1] valgrind/3.9.0-impi. After loading the module, this version replaces the default valgrind. +* Version 3.9.0 with support for Intel MPI, available in the `valgrind/3.9.0-impi` [module][1]. After loading the module, this version replaces the default Valgrind. There are two versions of Valgrind available on the Salomon. * Version 3.8.1, installed by operating system vendor in /usr/bin/valgrind. This version is available by default, without the need to load any module. However, this version does not provide additional MPI support. Also, it does not support AVX2 instructions - debugging of an AVX2-enabled executable with this version will fail -* Version 3.11.0 built by ICC with support for Intel MPI, available in module Valgrind/3.11.0-intel-2015b. After loading the module, this version replaces the default Valgrind. -* Version 3.11.0 built by GCC with support for OpenMPI, module Valgrind/3.11.0-foss-2015b +* Version 3.11.0 built by ICC with support for Intel MPI, available in module `Valgrind/3.11.0-intel-2015b`. After loading the module, this version replaces the default Valgrind. +* Version 3.11.0 built by GCC with support for OpenMPI, module `Valgrind/3.11.0-foss-2015b` ## Usage -Compile the application which you want to debug as usual. It is advisable to add the compilation flags -g (to add debugging information to the binary so that you will see original source code lines in the output) and -O0 (to disable compiler optimizations). +Compile the application which you want to debug as usual. It is advisable to add the compilation flags `-g` (to add debugging information to the binary so that you will see original source code lines in the output) and `-O0` (to disable compiler optimizations). For example, let us look at this C code, which has two problems: @@ -52,7 +52,7 @@ int main(void) } ``` -Now, compile it with Intel compiler : +Now, compile it with the Intel compiler : ```console $ module add intel @@ -97,7 +97,7 @@ $ valgrind ./valgrind-example ==12652== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 6 from 6) ``` -In the output, we can see that Valgrind has detected both errors - the off-by-one memory access at line 5 and a memory leak of 40 bytes. If we want a detailed analysis of the memory leak, we need to run Valgrind with --leak-check=full option: +In the output, we can see that Valgrind has detected both errors - the off-by-one memory access at line 5 and a memory leak of 40 bytes. If we want a detailed analysis of the memory leak, we need to run Valgrind with the `--leak-check=full` option: ```console $ valgrind --leak-check=full ./valgrind-example @@ -135,7 +135,7 @@ $ valgrind --leak-check=full ./valgrind-example ==23856== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 6 from 6) ``` -Now we can see that the memory leak is due to the malloc() at line 6. +Now we can see that the memory leak is due to `malloc()` at line 6. ## Usage With MPI @@ -167,7 +167,7 @@ So it is better to use the MPI-enabled Valgrind from the module. The MPI version * Anselm: /apps/tools/valgrind/3.9.0/impi/lib/valgrind/libmpiwrap-amd64-linux.so * Salomon: $EBROOTVALGRIND/lib/valgrind/libmpiwrap-amd64-linux.so -which must be included in the LD_PRELOAD environment variable. +which must be included in the `LD_PRELOAD` environment variable. Let us look at this MPI example: