Development/MKL: Difference between revisions
Line 112: | Line 112: | ||
prefix, such as |
prefix, such as |
||
#include <gsl/gsl_math.h> |
<source> #include <gsl/gsl_math.h> </source> |
||
A typical compilation command for a source file example.c with the |
A typical compilation command for a source file example.c with the |
Revision as of 23:52, 8 November 2013
Introduction
Modules Environment
Applications
MATLAB/Simulink
Octave
R
Programming
Compilers
GCC
Intel
Debugging
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:
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
GNU C compiler gcc is
gcc -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,
gcc -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.
Math Kernel Library (MKL)
MPI
OpenMP