Compilers supported at UPPMAX
UPPMAX supports three kind of compilers:
- GNU project compilers
- Portland Group compilers
- 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: some profiling works best without optimization, i.e using the -O0 flag.
Intel VTune Amplifier and Advisor
Intel's performance analysis suite can probably answer any question you have about the performance of your code, including MPI and OpenMP code.
Read more at http://software.intel.com/en-us/intel-vtune-amplifier-xe. A quick tutorial is located here: https://software.intel.com/en-us/node/589636.
In order to use Amplifier or Advisor, do the following. Load the latest Intel compiler and the Amplifier/Advisor module:
$ module load intel/16.1 amplifier advisor
Making sure you have a graphical connection through X or ThinLinc, run Amplifier or Advisor graphically:
$ amplxe-gui$ advixe-gui
Advisor is focused choosing optimising techniques that will yield good results, whereas Amplifier is more broadly aimed at performance analysis.
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