Debuggers

To use a debugger, it is necessary to rebuild your code with the -g flag added. All object files must be removed anytime compiler flags change. If you have a Makefile run make clean if it is available. The program must then be run under the control of the debugger. For example, if you are using gdb, you run

gdb ./myexec

Adding debugging flags generally disables any optimization flags you may have added, and can slow down the code. Please remember to recompile with -g removed once you have found your bugs.

Gnu Debugger (gdb) and Profiler (gprof)

The Gnu Compiler Collection compilers are free, open-source tools. Additional tools included are the gdb debugger and the gprof performance profiler. For detailed documentation, visit the Gnu website.

The gdb and gprof tools are included with the gcc compiler suite and are loaded with the gcc module.

module load gcc

Both gdb and gprof are text-based, command-line tools.

ModuleVersion Module Load Command
gcc6.5.0 module load gcc/6.5.0
gcc7.1.0 module load gcc/7.1.0
gcc8.3.0 module load gcc/8.3.0
gcc9.2.0 module load gcc/9.2.0
gccsystem module load gcc/system

Intel

To load the Intel compilers and associated tools, run

module load intel

The Intel debugger for versions 16.0 and beyond is a modified gdb and is used in a similar manner. After the Intel module is loaded, it can be accessed as gdb-ia.


**Available Intel Compilers**
ModuleVersion Module Load Command
intel18.0 module load intel/18.0
intel20.0 module load intel/20.0

PGI Compiler

The PGI Server Compilers and tools are licensed for Linux systems.

module load pgi

**Available PGI Compilers**
ModuleVersion Module Load Command
pgi19.10 module load pgi/19.10

PGI provides a very capable debugger, pgdbg. In its default mode, it is graphical, and it requires that an X server run on the user’s local desktop machine. It may be run in command-line mode with the -text option; see the manpage for a full list of options. As with all debuggers, the user’s program must be compiled with the -g flag in order to enable debugging. If you wish to use the graphical debugger and do not have or want to install an X11 server, you can also use FastX.

Totalview

The most powerful debugger available on Rivanna for OpenMP and MPI codes is Totalview. It is also an excellent general-purpose debugger. It has a command line interface but is not easy to use in that mode; it is nearly always used through its graphical user interface, which is highly intuitive. It can be used through FastX and longer debugging runs can occur through an ijob.

Valgrind

Valgrind is a framework for dynamic analysis tools. The most widely used tool is probably memcheck for detecting memory leaks. Build your code as usual with -g, then run it as

valgrind --leak-check=yes ./myprog arg1 arg2 > valgrind.out

The output from memcheck can be voluminous. Running under memcheck will also be much slower than a normal run and can require more memory.

Profilers

Profilers are tools for locating areas where the code can be sped up. Most profilers function by interrupting the code frequently and randomly, determining what subprogram is executing, and counting the time required for a subprogram to execute, how many times it is called, and so forth.

Gnu Profiler (gprof)

The Gnu profiler is a command-line, text-oriented tool. The code must be recompiled with -g -p flags. Run the code and usual. This will produce a binary file called gmon by default. Then run the profiler

gprof > gprof.out

Intel Tools

VTune Profiler

VTune is a powerful profiler for code built with Intel compilers. A getting-started guide is available from Intel.

Intel Trace Analyzer

The Intel Trace Analyzer, which is focused on MPI codes, is included with our Intel compiler licenses. Intel provides a tutorial here. Some modifications are needed to run under SLURM. Add a flag -bootstrap=slurm to the mpirun commmand, and use `-n $SLURM_NTASKS} rather than hard-coding a value.

Open|SpeedShop

Open|SpeedShop is a profiler capable of operating in several different modes, for different “experiments.” Unlike many profilers, it requires that only the -g flag be enabled.

Building on Rivanna

For general information about building your code on Rivanna, please see our howto