Chris@19: @node Introduction, Tutorial, Top, Top Chris@19: @chapter Introduction Chris@19: This manual documents version @value{VERSION} of FFTW, the Chris@19: @emph{Fastest Fourier Transform in the West}. FFTW is a comprehensive Chris@19: collection of fast C routines for computing the discrete Fourier Chris@19: transform (DFT) and various special cases thereof. Chris@19: @cindex discrete Fourier transform Chris@19: @cindex DFT Chris@19: @itemize @bullet Chris@19: @item FFTW computes the DFT of complex data, real data, even- Chris@19: or odd-symmetric real data (these symmetric transforms are usually Chris@19: known as the discrete cosine or sine transform, respectively), and the Chris@19: discrete Hartley transform (DHT) of real data. Chris@19: Chris@19: @item The input data can have arbitrary length. Chris@19: FFTW employs @Onlogn{} algorithms for all lengths, including Chris@19: prime numbers. Chris@19: Chris@19: @item FFTW supports arbitrary multi-dimensional data. Chris@19: Chris@19: @item FFTW supports the SSE, SSE2, AVX, Altivec, and MIPS PS instruction Chris@19: sets. Chris@19: Chris@19: @item FFTW includes parallel (multi-threaded) transforms Chris@19: for shared-memory systems. Chris@19: @item Starting with version 3.3, FFTW includes distributed-memory parallel Chris@19: transforms using MPI. Chris@19: @end itemize Chris@19: Chris@19: We assume herein that you are familiar with the properties and uses of Chris@19: the DFT that are relevant to your application. Otherwise, see Chris@19: e.g. @cite{The Fast Fourier Transform and Its Applications} by E. O. Brigham Chris@19: (Prentice-Hall, Englewood Cliffs, NJ, 1988). Chris@19: @uref{http://www.fftw.org, Our web page} also has links to FFT-related Chris@19: information online. Chris@19: @cindex FFTW Chris@19: Chris@19: @c TODO: revise. We don't need to brag any longer Chris@19: @c Chris@19: @c FFTW is usually faster (and sometimes much faster) than all other Chris@19: @c freely-available Fourier transform programs found on the Net. It is Chris@19: @c competitive with (and often faster than) the FFT codes in Sun's Chris@19: @c Performance Library, IBM's ESSL library, HP's CXML library, and Chris@19: @c Intel's MKL library, which are targeted at specific machines. Chris@19: @c Moreover, FFTW's performance is @emph{portable}. Indeed, FFTW is Chris@19: @c unique in that it automatically adapts itself to your machine, your Chris@19: @c cache, the size of your memory, your number of registers, and all the Chris@19: @c other factors that normally make it impossible to optimize a program Chris@19: @c for more than one machine. An extensive comparison of FFTW's Chris@19: @c performance with that of other Fourier transform codes has been made, Chris@19: @c and the results are available on the Web at Chris@19: @c @uref{http://fftw.org/benchfft, the benchFFT home page}. Chris@19: @c @cindex benchmark Chris@19: @c @fpindex benchfft Chris@19: Chris@19: In order to use FFTW effectively, you need to learn one basic concept Chris@19: of FFTW's internal structure: FFTW does not use a fixed algorithm for Chris@19: computing the transform, but instead it adapts the DFT algorithm to Chris@19: details of the underlying hardware in order to maximize performance. Chris@19: Hence, the computation of the transform is split into two phases. Chris@19: First, FFTW's @dfn{planner} ``learns'' the fastest way to compute the Chris@19: transform on your machine. The planner Chris@19: @cindex planner Chris@19: produces a data structure called a @dfn{plan} that contains this Chris@19: @cindex plan Chris@19: information. Subsequently, the plan is @dfn{executed} Chris@19: @cindex execute Chris@19: to transform the array of input data as dictated by the plan. The Chris@19: plan can be reused as many times as needed. In typical Chris@19: high-performance applications, many transforms of the same size are Chris@19: computed and, consequently, a relatively expensive initialization of Chris@19: this sort is acceptable. On the other hand, if you need a single Chris@19: transform of a given size, the one-time cost of the planner becomes Chris@19: significant. For this case, FFTW provides fast planners based on Chris@19: heuristics or on previously computed plans. Chris@19: Chris@19: FFTW supports transforms of data with arbitrary length, rank, Chris@19: multiplicity, and a general memory layout. In simple cases, however, Chris@19: this generality may be unnecessary and confusing. Consequently, we Chris@19: organized the interface to FFTW into three levels of increasing Chris@19: generality. Chris@19: @itemize @bullet Chris@19: @item The @dfn{basic interface} computes a single Chris@19: transform of contiguous data. Chris@19: @item The @dfn{advanced interface} computes transforms Chris@19: of multiple or strided arrays. Chris@19: @item The @dfn{guru interface} supports the most general data Chris@19: layouts, multiplicities, and strides. Chris@19: @end itemize Chris@19: We expect that most users will be best served by the basic interface, Chris@19: whereas the guru interface requires careful attention to the Chris@19: documentation to avoid problems. Chris@19: @cindex basic interface Chris@19: @cindex advanced interface Chris@19: @cindex guru interface Chris@19: Chris@19: Chris@19: Besides the automatic performance adaptation performed by the planner, Chris@19: it is also possible for advanced users to customize FFTW manually. For Chris@19: example, if code space is a concern, we provide a tool that links only Chris@19: the subset of FFTW needed by your application. Conversely, you may need Chris@19: to extend FFTW because the standard distribution is not sufficient for Chris@19: your needs. For example, the standard FFTW distribution works most Chris@19: efficiently for arrays whose size can be factored into small primes Chris@19: (@math{2}, @math{3}, @math{5}, and @math{7}), and otherwise it uses a Chris@19: slower general-purpose routine. If you need efficient transforms of Chris@19: other sizes, you can use FFTW's code generator, which produces fast C Chris@19: programs (``codelets'') for any particular array size you may care Chris@19: about. Chris@19: @cindex code generator Chris@19: @cindex codelet Chris@19: For example, if you need transforms of size Chris@19: @ifinfo Chris@19: @math{513 = 19 x 3^3}, Chris@19: @end ifinfo Chris@19: @tex Chris@19: $513 = 19 \cdot 3^3$, Chris@19: @end tex Chris@19: @html Chris@19: 513 = 19*33, Chris@19: @end html Chris@19: you can customize FFTW to support the factor @math{19} efficiently. Chris@19: Chris@19: For more information regarding FFTW, see the paper, ``The Design and Chris@19: Implementation of FFTW3,'' by M. Frigo and S. G. Johnson, which was an Chris@19: invited paper in @cite{Proc. IEEE} @b{93} (2), p. 216 (2005). The Chris@19: code generator is described in the paper ``A fast Fourier transform Chris@19: compiler'', Chris@19: @cindex compiler Chris@19: by M. Frigo, in the @cite{Proceedings of the 1999 ACM SIGPLAN Conference Chris@19: on Programming Language Design and Implementation (PLDI), Atlanta, Chris@19: Georgia, May 1999}. These papers, along with the latest version of Chris@19: FFTW, the FAQ, benchmarks, and other links, are available at Chris@19: @uref{http://www.fftw.org, the FFTW home page}. Chris@19: Chris@19: The current version of FFTW incorporates many good ideas from the past Chris@19: thirty years of FFT literature. In one way or another, FFTW uses the Chris@19: Cooley-Tukey algorithm, the prime factor algorithm, Rader's algorithm Chris@19: for prime sizes, and a split-radix algorithm (with a Chris@19: ``conjugate-pair'' variation pointed out to us by Dan Bernstein). Chris@19: FFTW's code generator also produces new algorithms that we do not Chris@19: completely understand. Chris@19: @cindex algorithm Chris@19: The reader is referred to the cited papers for the appropriate Chris@19: references. Chris@19: Chris@19: The rest of this manual is organized as follows. We first discuss the Chris@19: sequential (single-processor) implementation. We start by describing Chris@19: the basic interface/features of FFTW in @ref{Tutorial}. Chris@19: Next, @ref{Other Important Topics} discusses data alignment Chris@19: (@pxref{SIMD alignment and fftw_malloc}), Chris@19: the storage scheme of multi-dimensional arrays Chris@19: (@pxref{Multi-dimensional Array Format}), and FFTW's mechanism for Chris@19: storing plans on disk (@pxref{Words of Wisdom-Saving Plans}). Next, Chris@19: @ref{FFTW Reference} provides comprehensive documentation of all Chris@19: FFTW's features. Parallel transforms are discussed in their own Chris@19: chapters: @ref{Multi-threaded FFTW} and @ref{Distributed-memory FFTW Chris@19: with MPI}. Fortran programmers can also use FFTW, as described in Chris@19: @ref{Calling FFTW from Legacy Fortran} and @ref{Calling FFTW from Chris@19: Modern Fortran}. @ref{Installation and Customization} explains how to Chris@19: install FFTW in your computer system and how to adapt FFTW to your Chris@19: needs. License and copyright information is given in @ref{License and Chris@19: Copyright}. Finally, we thank all the people who helped us in Chris@19: @ref{Acknowledgments}. Chris@19: