NERSCPowering Scientific Discovery Since 1974

FFTW

Description

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/3.2.2.1
cc FFTW3Serial1DExample.c
ftn FFTW3Serial1DExample.f

Using FFW on Carver and Euclid

FFW on Carver and Euclid 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 on both machines. Presently, Euclid has the GNU-compiled library for Version 3 only.  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

On Euclid use -ldfftw.

To compile the sample MPI 3-D code on Carver or Euclid 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 or Euclid 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

C source code
Fortran source code

FFTW2 MPI 3D Example

C source code
Fortran source code

FFTW3 Serial 1D Example

C source code
Fortran source code

Differences between FFTW 3 and FFTW 2 source code

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

C source code

Documentation

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 consult@nersc.gov

Availability at NERSC

PackagePlatformCategoryVersionModuleInstall DateDate Made Default
fftw carver libraries/ math 2.1.5 fftw/2.1.5 2010-02-04 2010-02-04
FFTW carver libraries/ math 2.1.5 fftw-Intel/2.1.5 2012-10-12
FFTW carver libraries/ math 3.2.2 fftw/3.2.2 2010-03-05
FFTW carver libraries/ math 3.2.2 fftw-gnu/3.2.2 2010-03-05
FFTW carver libraries/ math 3.2.2 fftw-Intel/3.2.2 2012-10-12
FFTW carver libraries/ math 3.3.2 fftw-Intel/3.3.2 2013-01-14
FFTW carver libraries/ math 3.3.2 fftw/3.3.2 2013-01-14
FFTW carver libraries/ math 3.3.2-gnu fftw/3.3.2-gnu 2012-08-29
fftw genepool pe_libraries/ math 3.3.3 fftw/3.3.3 2013-09-12 2013-09-12
FFTW hopper libraries/ math 2.1.5.3 fftw/2.1.5.3 2011-11-07 2012-01-18
FFTW hopper libraries/ math 2.1.5.4 fftw/2.1.5.4 2013-01-15 2013-02-27
FFTW hopper libraries/ math 2.1.5.6 fftw/2.1.5.6 2013-09-25
FFTW hopper libraries/ math 3.2.2.1 fftw/3.2.2.1 2010-08-18 2010-08-18
FFTW hopper libraries/ math 3.3.0.0 fftw/3.3.0.0 2013-07-28
FFTW hopper libraries/ math 3.3.0.1 fftw/3.3.0.1 2013-12-04
FFTW hopper libraries/ math 3.3.0.2 fftw/3.3.0.2 2013-05-24 2013-06-20
FFTW hopper libraries/ math 3.3.0.4 fftw/3.3.0.4 2013-09-25 2013-12-11