Development/MKL

From bwHPC Wiki
Jump to navigation Jump to search
Navigation: bwHPC BPR


Compilers

GCC

Intel

Debugging

Only for employees of KIT

On bwUniCluster the GUI based distributed debugging tool (ddt) may be used to debug serial as well as parallel applications. For serial applications also the GNU gdb or Intel idb debugger may be used. The Intel idb comes with the compiler and information on this tool is available together with the compiler documentation. In order to debug your program it must be compiled and linked using the -g compiler option. This will force the compiler to add additional information to the object code which is used by the debugger at runtime.

Parallel Debugger ddt

ddt consists of a graphical frontend and a backend serial debugger which controls the application program. One instance of the serial debugger controls one MPI process. Via the frontend the user interacts with the debugger to select the program that will be debugged, to specify different options and to monitor the execution of the program. Debugging commands may be sent to one, all or a subset of the MPI processes. Before the parallel debugger ddt can be used, it is necessary to load the corresponding module file: module add ddt Now ddt may be started with the command ddt program where program is the name of your program that you want to debug. Figure 3: DDT startup window Fig. 3 shows ddt’s startup window. Before actually starting the debugging session you should check the contents of several fields in this window:

Numerical Libraries

FFTW

FFTW is a C subroutine library for computing the discrete Fourier transform (DFT) in one or more dimensions, of arbitrary input size, and of both real and complex data (as well as of even/odd data, i.e. the discrete cosine/sine transforms or DCT/DST).

This package provides three versions of the fftw3 library depending on precision: libfft3, libfftw3f and libfftw3l for double, single and long-double precision libraries.

Online Documentation: http://www.fftw.org/fftw3_doc/

Local documentation:

See 'info fftw3', 'man fftw-wisdom' and 'man fftw-wisdom-to-conf'. See also documentation folder pointed to by shell variable $FFTW_DOC_DIR

Hints for compiling and linking:

Load the fftw module, and, if needed, the corresponding openmpi module.

After having loaded the appropriate module(s), you can use several environment variables to compile and link your application.

  • Compile serial program:
 $ gcc example.c -o example -I$FFTW_INC_DIR -L$FFTW_LIB_DIR -lfftw3 -lm
  • Compile program with support for POSIX threads:
 $ gcc example.c -o example -I$FFTW_INC_DIR -L$FFTW_LIB_DIR -lfftw3_threads -lfftw3 -lpthread -lm
  • Compile program with support for OpenMP threads:
 $ gcc example.c -o example -fopenmp -I$FFTW_INC_DIR -L$FFTW_LIB_DIR -lfftw3_omp -lfftw3 -lm
  • Compile program with support for MPI:
 $ mpicc example.c -o example -I$FFTW_INC_DIR -L$FFTW_LIB_DIR -lfftw3_mpi -lfftw3 -lm 
  • Run program with MPI support:
 $ mpirun -n <ncpu> ./example 

(Replace <ncpu> by number of processor cores.)

Replace -lfftw3, -lfftw3_threads, etc. by -lfftw3f, -lfftw3f_threads, etc. for single precision and by -lfftw3l, -lfftw3l_threads etc. for long-double precision codes, respectively.

These commands will compile your program with dynamic fftw library versions in which case you also have to have the fftw module loaded for running the program. Alternatively, you may want to link your program with static fftw library versions. With static fftw libraries it is only necessary to load the fftw module for compiling but not for executing the program.

  • Compile program with static fftw library versions (example for POSIX threads support):
 $ gcc example.c -o example -I$FFTW_INC_DIR $FFTW_LIB_DIR/{libfftw3_threads.a,libfftw3.a} -lpthread -lm 

or:

 $ gcc example.c -o example -I$FFTW_INC_DIR -L$FFTW_LIB_DIR -Wl,-Bstatic -lfftw3 -lfftw3_threads \
       -Wl,-Bdynamic -lpthread -lm 

Environment variables $FFTW_INC_DIR, $FFTW_LIB_DIR etc. are available after loading the module.

Sample code for various test cases is provided in folder pointed to by environment variable $FFTW_EXA_DIR.

GNU Scientific Library (GSL)

The GNU Scientific Library (or GSL) is a software library for numerical computations in applied mathematics and science. The GSL is written in the C programming language, but bindings exist for other languages as well.

Online-Documentation: http://www.gnu.org/software/gsl/

Local-Documentation:

See 'info gsl', 'man gsl' and 'man gsl-config'.

Tips for compiling and linking:

Load the gsl module. After having loaded the gsl environment module, you can use several environment variables to compile and link your application with the gsl library.

Your source code should contain preprocessor include statements with a gsl/ prefix, such as

 #include <gsl/gsl_math.h>

A typical compilation command for a source file example.c with the Intel C compiler icc is

 $ icc -Wall -I$GSL_INC_DIR  -c example.c 

The $GSL_INC_DIR environment variable points to location of the include path for the gsl header files.

The following command can be used to link the application with the gsl libraries,

 $ icc -L$GSL_LIB_DIR -o example example.o -lgsl -lgslcblas -lm 

The $GSL_LIB_DIR environment variable points to the location of the gsl libraries.

Also make sure to have the gsl module loaded before running applications build with this library.

Example

Create source code file 'intro.c':

#include <stdio.h>
#include <gsl/gsl_sf_bessel.h>

int main (void)
{
  double x = 5.0;
  double y = gsl_sf_bessel_J0 (x);
  printf ("J0(%g) = %.18e\n", x, y);
  return 0;
}

Load the gsl module for the Intel compiler, compile, link and run the program:

$ module load numlib/gsl/1.16-intel-13.1
Loading module dependency 'compiler/intel/13.1'.
$ icc -Wall -I$GSL_INC_DIR  -c intro.c
$ icc -L$GSL_LIB_DIR -o intro intro.o -lgsl -lgslcblas -lm
$ ./intro
J0(5) = -1.775967713143382642e-01

Math Kernel Library (MKL)