Development/FFTW: Difference between revisions
K Siegmund (talk | contribs) (→FFTW) |
No edit summary |
||
Line 82: | Line 82: | ||
variable $FFTW_EXA_DIR. |
variable $FFTW_EXA_DIR. |
||
[[Category:Numerical_libraries]] |
[[Category:Numerical_libraries]][[Category:bwUniCluster]] |
Revision as of 19:48, 28 April 2014
FFTW (Fast Fourier Transform in the West) 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.