Personal tools
You are here: Home Support User Guides Short tutorial on using debuggers and profiling tools on UPPMAX

Short tutorial on using debuggers and profiling tools on UPPMAX

— filed under:

Short tutorial on using debuggers and profiling tools on UPPMAX

UPPMAX supports three compilers, GNU project compilers, Portland Group compilers and Intel compilers. This tutorial will show how to use the tools provided with the compilers and some other profiling tools.

Since  all these tools is strongly connected to the compiler they come with, it is recommended to only have that compiler module loaded.

To make sure that you don't have any other compiler loaded:

$ module list
Currently Loaded Modulefiles:
  1) modules   2) uppmax    3) pgi/2010
$ module unload pgi

 

Debugging tools

There are debugging tools provided with each of the three compilers.

 For C, C++, and Fortran 77 programs the ordinary gnu debugger (gdb) works fine, but for Fortran90/95 programs using gdb doesn't work well. With the Portland Group compilers a debugger named pgdbg is included, which is works well for Fortran 90/95 also.

 

The GNU debugger

The GNU debugger, gdb is provided with the GNU compilers.

Read more at: http://www.gnu.org/software/gdb/

In order to use gdb do the following.
load the gcc module

$ module load gcc/4.5.0

compile your program with flags for debugging added, e.g. -ggdb

$ gcc -ggdb your-program.c -o your-program

run the gdb program:

$ gdb your-program

Then you can use the gdb commands, like run, break, step, help, ...

 

The intel debugger

The intel debugger, idb is provided with the intel compiler. In order to run it you have to enable X11 forwarding when you log in to UPPMAX, i.e. use ssh -X

Read more: http://software.intel.com/en-us/articles/intel-c-compiler-professional-edition-for-linux-documentation/

 

In order to use idb do the following.
load the icc module

$ module load intel/12.0

compile your program with flags for debugging added, e.g. -g

$ icc -g your-program.c -o your-program

idb uses java, so you must load the java module

$ module load java/sun_jdk1.6.0_18

run the gdb program:

$ idb your-program

This will open a new window with idb running. Here you can run your code, set breakpoints, step forward in your program, and so on.

 

The Portland debugger

The Portland debugger, pgdbg is provided in the Portland Group compiler pack. It can run either in a graphical mode, if you have enabled X11 forwarding, or a text mode.
pgdbg is capable of debugging MPI-parallel, OpenMP thread-parallel or hybrid combinations of parallel MPI processes and OpenMP threads.

Read more at: http://www.pgroup.com/products/pgdbg.htm

In order to use pgdbg do the following.
load the Portland Group compiler module

$ module load pgi/2011

compile your program with flags for debugging added, e.g. -g

$ pgcc -g your-program.c -o your-program

run the pgdbg program:

$ pgdbg your-program

If you have X11 forwarding enabled it will open a new window with pgdbg, otherwise you can start pgdbg in text mode by giving the flag -text. Regardless of mode, you can run, set breakpoints, step and so on.

 

 

Profiling tools

There are some profiling tools that are available at UPPMAX. Note: profiling works best without optimization, i.e use the -O0 flag.

 

The GNU profiler

The GNU profiler, gprof is provided with the GNU compiler package.

Read more at:  http://sourceware.org/binutils/docs-2.16/gprof/

 

In order to use gprof do the following.
load the gcc module:

$ module load gcc/4.5.0

Compile your program with the -pg -g flags added

$ gcc -O0 -pg -g your-program.c -o your-program

run it:

$ ./your-program

then do:

$ gprof your-program

Here is a tutorial: http://www.cs.utah.edu/dept/old/texinfo/as/gprof.html

 

The Portland Group profiler

The Portland Group profiler, pgprof, is available at UPPMAX

Read more at http://www.pgroup.com/products/pgprof.htm

In order to use gprof do the following.
load the Portland compiler module

$ module load pgi/2011

Compile your program with the -pg -g flags added

$ pgcc -O0 -pg -g your-program.c -o your-program

run it:

$ ./your-program

 then do:

$ pgprof your-program

 

Valgrind


Valgrind is a suite of simulation-based debugging and profiling tools for programs.
Valgrind contains several tools:

memcheck, for detecting memory-management problems in your program
cachegrind, for cache profiling
helgrind, finds data races in multithreded programs
callgrind, a call graph profiler
drd,  a thread error detector
massif, a heap profiler
ptrcheck, a pointer checking tool
lackey, a simple profiler and memory tracer

You can find full documentation on valgrind in /sw/comp/valgrind/x86_64/3.4.1/gcc/share/doc/valgrind/
or http://valgrind.org/docs/manual/manual.html

Valgrind works best with the gcc- and intel compilers.

You should use valgrind with the module system.
With gcc do:

$ module load gcc valgrind

then you can use valgind by:

$ valgrind [options] your-program [your programs options]


With intel compilers do:

$ module load intel/12.0 valgrind

then you can use valgind by:

$ valgrind [options] your-program [your programs options]

 

 

How to use valgrind with mpi programs


Note: valgrind can only be used by gcc- and intel comilers when you want to check programs using mpi.

Load your complier, openmpi and the valgrind module as before:

With gcc,

$ module load gcc/4.4 openmpi/1.4.3 valgrind


Then run:

$ LD_PRELOAD=$VALGRIND_MPI_WRAPPER mpirun -np 2 valgrind ./your-program



With intel:

$ module load intel/12.0 openmpi/1.5.0 valgrind
$ LD_PRELOAD=$VALGRIND_MPI_WRAPPER mpirun -np 2 valgrind ./your-program

 

Document Actions