FFTW at PDC
FFTW is a freely available library for performing Fast Fourier Transforms. It is available as source code and can be compiled on most platforms and generally is one of the fastest FFT libraries on any platform.
To see which FFTW versions are available use the command
module avail fftw
FFTW on Ferlin/Ekman/Povel/Ellen
Because in general librarys built with different compileres are not compatable with each other FFTW has been built with a variety of compilers. The different modules include the name of the compiler that was used to build the library, e.g. FFTW/3.2.2-intel is FFTW version 3.2.2 built using the Intel compiler.
Latest version: 3.3.2 -- Also available: 3.2.2, 2.1.5
In most cases only the static library has been built, so the librarys will be linked staticlaly and the module does not need to be loaded as it is only there for information. The command
module show fftw/3.2.2-intel
will give information on the relevant compile and link time flags needed to successfully compile and link that version of the library in your program.
FFTW V3.3.2
FFTW is provided with more pre-compiled variants in this version. FFTW can be compiled for different precisions of floating-point numbers as well as for serial or parallel use. There is a module file for serial and multi-threaded use of FFTW as well as one for the use with MPI.
Use of Modules, Compiling and Linking
Module name scheme.
| Compiler | Serial/Multi-threaded | MPI parallel |
|---|---|---|
| intel-12 |
fftw/3.3.2-intel-12 Precisions: single, double, long double |
fftw/3.3.2-mpi-intel-12 Precisions: single, double, long double |
| gnu-4.6 |
fftw/3.3.2-gnu-4.6 Precisions: single, double, long-double, quad-precision |
fftw/3.3.2-mpi-gnu-4.6 Precisions: single, double, long-double, quad-precision |
The module command "load" defines the environment variable FFTW_HOME that can be used further on in scripts and makefiles to specify the base directory of the installation. The module command "show" provides a short example how to compile and link applications with the libraries.
The header and libraries for the different provided floating-point precisions are installed in subdirectories of ${FFTW_HOME}.
Compiling. Typically one has to provide the path to the include directory to the compiler. A makefile could contain for example the definition.
CFLAGS = -I$(FFTW_HOME)/double/include
Liniking. Typically one has to provide the path to the directory comtaining libraries and the name of the library to the linkage editor. This could look in a makefile like the following definition.
LDFLAGS = -L$(FFTW_HOME)/double/lib -lfftw3
Version 3.3.2 of FFTW is provided as static as well as shared library for use in single-threaded, multi-threaded and OpenMP parallel programs. A look into the directory "$FFTW_HOME/<precision>/lib" make the naming scheme of the libraries clear.
You maybe have to set the environment variable LD_LIBRARY_PATH if shared libraries are used. Otherwise, the definition could be compiled as runpath into the executable.
LD_LIBRARY_PATH=${FFTW_HOME}/double/lib:${LD_LIBRARY_PATH}
For more information: FFTW V.3.3.2 Online Documentation (PDF).
FFTW on Lindgren
FFTW3.3
FFTW 3.3 reintroduces the MPI transforms into FFTW, and is used in a slightly different way to FFTW 3.2 (and more similar to FFTW 2)
Firstly load the module
module load fftw/3.3
Then at link time you have to specify the librarys you want to link yourself e,g,
ftn foo.o bar.o -lfftw3_mpi -lfftw3
for the double precision MPI version or
ftn foo.o bar.o -lfftw3f_mpi -lfftw3f
For the single precision MPI version etc.
Note if you have the module loaded it should find the libraries and include files (for C) automatically so you do not need to specify the path. It is necessary to specify which libraries should be used though as there are a few different options.
FFTW 3.2
FFTW 3.2 is relatively simple to use on Lindgren, as if the FFTW module is loaded then the correct include files are automatically found and the library is automatically linked by the cc/CC/ftn scripts.
i.e. just do for example
module load fftw/3.2.2.1
then use
ftn foo.f cc foo.c CC foo.cpp
as normal.
FFTW 2
As FFTW 2 has more options in terms of which libraries you want to link then as well as loading the module e.g
module load fftw/2.1.5.2
it is necessary to explicitly link the required FFTW components e.g. at the link stage, to use the double precision FFTW library use
ftn foo.o bar.o -ldrfftw -ldfftw
or for the single precision FFTW library
ftn foo.o bar.o -lsrfftw -lsfftw
If you use gcc then you will also need to explictiy link to the maths library i.e. with -lm in addition
The flags for the include files are set as above, so at the compile stage everything is done automatically.


