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).
Both FFTW Version 2 and FFTW Version 3 are available on NERSC systems but there are significant differences between these two versions, as shown below.
NOTE: As of July, 2013, Version 3 is the default on Hopper! Version 3 will be the default on Edison Phase 2. Version 2 remains the default on Carver.
Differences between Version 2 and Version:
- Different names for include files
- Different names for FFTW routines
- Different arguments for FFTW routines
- Different data structure methods for fftw_complex
- Different approach to plan preparation and execution
Using FFTW on Hopper
Although FFTW is nominally "free" software, highly optimized versions of the libraries are provided by Cray on the NERSC XE6 system. To use:
module load fftw
To see which versions are available:
module avail fftw
A selection of sample codes using FFTW is given in a later section on this web page. Sample compile lines for Hopper are given below; note that all of these commands work for all of the compiler environments available on Hopper.
To compile the sample serial 1-D code on Hopper with Version 2 use the following:
cc FFTW2Serial1DExample.c $FFTW_POST_LINK_OPTS -lfftw
ftn FFTW2Serial1DExample.f $FFTW_POST_LINK_OPTS -lfftw
Those commands work for the arrays declared as either "complex" or "double complex."
To compile the sample MPI 3-D code on Hopper with Version 2 use:
cc FFTW2MPI3DExample.c $FFTW_POST_LINK_OPTS -ldfftw_mpi -ldfftw
ftn FFTW2MPI3DExample.f $FFTW_POST_LINK_OPTS -ldfftw_mpi -ldfftw
Note that the order of the libraries given on the above command is significant.
To compile the sample serial 1-D code on Hopper with FFTW version 3 use the following (after the appropriate module load command):
module load fftw/18.104.22.168
Using FFW on Carver
FFW on Carver is installed and maintained by NERSC and is made available via the module utility. Separate versions are available for the three compilers available on Carver: PGI (which is the default), Intel, and GNU. The Version 2 library is the default. To see all versions available:
module avail fftw
To load a non-default version use a command similar to one of the following:
module load fftw/3.2.2
module load fftw-Intel/2.1.5
module load fftw-gnu/3.2.2
To compile the sample serial 1-D code on Carver with Version 2 use the following (after the appropriate module load command):
mpicc FFTW2Serial1DExample.c $FFTW -lfftw
mpif90 FFTW2Serial1DExample.f $FFTW -lfftw
To compile the sample MPI 3-D code on Carver or with Version 2 use:
mpicc FFTW2MPI3DExample.c $FFTW -ldfftw_mpi -ldfftw
mpif90 FFTW2MPI3DExample.f $FFTW -ldfftw_mpi -ldfftw
To compile the sample serial 1-D code on Carver with FFTW version 3 use the following (after the appropriate module load command):
mpicc FFTW3Serial1DExample.c $FFTW -lfftw3
mpif90 FFTW3Serial1DExample.f $FFTW -lfftw3
FFTW Example Codes
These simple examples demonstrate that (1) not all FFTW routines, which are written in C, have Fortran wrappers; and (2) the Fortran function arguments differ from the C arguments. In particular, the utility to print the plan structure does not have a Fortran wrapper, and the Fortran code example can only give the value of the pointer, not the data in the plan structure.
In addition, there are significant differences between Version 2 and Version 3 of the FFTW library. The data structures are different, the routine names are different, the arguments are different. Conversion of a code from Version 2 to Version 3 will require extensive source code changes.
FFTW2 Serial 1D Example
FFTW2 MPI 3D Example
FFTW3 Serial 1D Example
FFTW3 MPI Example
MPI is enabled only in FFTW versions 3.3+. You can find this on Hopper and on Carver for GNU only. Compile using mpicc $FFTW -l fftw3_mpi -lfftw3
For the Cray systems the document to look for is the Programming Environment User's Guide. The base document number for this is S–2396. Cray documents are generally of the form S-xxxx-nn, where nn relates to the release. The June, 2010 release of the Programming Environment User's Guide is S–2396–50. Man pages are available via man fftw and/or man libsci.
General information FFTW is available at fftw.org.
For questions about FFTW on any NERSC systems send e-mail to firstname.lastname@example.org
Availability at NERSC
|Package||Platform||Category||Version||Module||Install Date||Date Made Default|