annotate src/fftw-3.3.5/doc/FAQ/fftw-faq.bfnn @ 84:08ae793730bd

Add null config files
author Chris Cannam
date Mon, 02 Mar 2020 14:03:47 +0000
parents 2cd0e3b3e1fd
children
rev   line source
Chris@42 1 \comment This is the source for the FFTW FAQ list, in
Chris@42 2 \comment the Bizarre Format With No Name. It is turned into Lout
Chris@42 3 \comment input, HTML, plain ASCII and an Info document by a Perl script.
Chris@42 4 \comment
Chris@42 5 \comment The format and scripts come from the Linux FAQ, by
Chris@42 6 \comment Ian Jackson.
Chris@42 7 \set brieftitle FFTW FAQ
Chris@42 8 \set author <A href="http://www.fftw.org">Matteo Frigo and Steven G. Johnson</A> / <A href="mailto:fftw@fftw.org">fftw@fftw.org</A>
Chris@42 9 \set authormail fftw@fftw.org
Chris@42 10 \set title FFTW Frequently Asked Questions with Answers
Chris@42 11 \set copyholder Matteo Frigo and Massachusetts Institute of Technology
Chris@42 12 \call-html startup html.refs2
Chris@42 13 \copyto ASCII
Chris@42 14 FFTW FREQUENTLY ASKED QUESTIONS WITH ANSWERS
Chris@42 15 `date '+%d %h %Y'`
Chris@42 16 Matteo Frigo
Chris@42 17 Steven G. Johnson
Chris@42 18 <fftw@fftw.org>
Chris@42 19
Chris@42 20 \endcopy
Chris@42 21 \copyto INFO
Chris@42 22 INFO-DIR-SECTION Development
Chris@42 23 START-INFO-DIR-ENTRY
Chris@42 24 * FFTW FAQ: (fftw-faq). FFTW Frequently Asked Questions with Answers.
Chris@42 25 END-INFO-DIR-ENTRY
Chris@42 26
Chris@42 27 
Chris@42 28 File: $prefix.info, Node: Top, Next: Question 1.1, Up: (dir)
Chris@42 29
Chris@42 30 FFTW FREQUENTLY ASKED QUESTIONS WITH ANSWERS
Chris@42 31 `date '+%d %h %Y'`
Chris@42 32 Matteo Frigo
Chris@42 33 Steven G. Johnson
Chris@42 34 <fftw@fftw.org>
Chris@42 35
Chris@42 36 \endcopy
Chris@42 37
Chris@42 38 This is the list of Frequently Asked Questions about FFTW, a
Chris@42 39 collection of fast C routines for computing the Discrete Fourier
Chris@42 40 Transform in one or more dimensions.
Chris@42 41
Chris@42 42 \section Index
Chris@42 43
Chris@42 44 \index
Chris@42 45
Chris@42 46 \comment ######################################################################
Chris@42 47
Chris@42 48 \section Introduction and General Information
Chris@42 49
Chris@42 50 \question 26aug:whatisfftw What is FFTW?
Chris@42 51
Chris@42 52 FFTW is a free collection of fast C routines for computing the
Chris@42 53 Discrete Fourier Transform in one or more dimensions. It includes
Chris@42 54 complex, real, symmetric, and parallel transforms, and can handle
Chris@42 55 arbitrary array sizes efficiently. FFTW is typically faster than
Chris@42 56 other publically-available FFT implementations, and is even
Chris@42 57 competitive with vendor-tuned libraries. (See our web page for
Chris@42 58 extensive benchmarks.) To achieve this performance, FFTW uses novel
Chris@42 59 code-generation and runtime self-optimization techniques (along with
Chris@42 60 many other tricks).
Chris@42 61
Chris@42 62 \question 26aug:whereisfftw How do I obtain FFTW?
Chris@42 63
Chris@42 64 FFTW can be found at \docref{the FFTW web page\}. You can also
Chris@42 65 retrieve it from \ftpon ftp.fftw.org in \ftpin /pub/fftw.
Chris@42 66
Chris@42 67 \question 26aug:isfftwfree Is FFTW free software?
Chris@42 68
Chris@42 69 Starting with version 1.3, FFTW is Free Software in the technical
Chris@42 70 sense defined by the Free Software Foundation (see \docref{Categories
Chris@42 71 of Free and Non-Free Software\}), and is distributed under the terms
Chris@42 72 of the GNU General Public License. Previous versions of FFTW were
Chris@42 73 distributed without fee for noncommercial use, but were not
Chris@42 74 technically ``free.''
Chris@42 75
Chris@42 76 Non-free licenses for FFTW are also available that permit different
Chris@42 77 terms of use than the GPL.
Chris@42 78
Chris@42 79 \question 10apr:nonfree What is this about non-free licenses?
Chris@42 80
Chris@42 81 The non-free licenses are for companies that wish to use FFTW in their
Chris@42 82 products but are unwilling to release their software under the GPL
Chris@42 83 (which would require them to release source code and allow free
Chris@42 84 redistribution). Such users can purchase an unlimited-use license
Chris@42 85 from MIT. Contact us for more details.
Chris@42 86
Chris@42 87 We could instead have released FFTW under the LGPL, or even disallowed
Chris@42 88 non-Free usage. Suffice it to say, however, that MIT owns the
Chris@42 89 copyright to FFTW and they only let us GPL it because we convinced
Chris@42 90 them that it would neither affect their licensing revenue nor irritate
Chris@42 91 existing licensees.
Chris@42 92
Chris@42 93 \question 24oct:west In the West? I thought MIT was in the East?
Chris@42 94
Chris@42 95 Not to an Italian. You could say that we're a Spaghetti Western
Chris@42 96 (with apologies to Sergio Leone).
Chris@42 97
Chris@42 98 \comment ######################################################################
Chris@42 99
Chris@42 100 \section Installing FFTW
Chris@42 101
Chris@42 102 \question 26aug:systems Which systems does FFTW run on?
Chris@42 103
Chris@42 104 FFTW is written in ANSI C, and should work on any system with a decent
Chris@42 105 C compiler. (See also \qref runOnWindows, \qref compilerCrashes.)
Chris@42 106 FFTW can also take advantage of certain hardware-specific features,
Chris@42 107 such as cycle counters and SIMD instructions, but this is optional.
Chris@42 108
Chris@42 109 \question 26aug:runOnWindows Does FFTW run on Windows?
Chris@42 110
Chris@42 111 Yes, many people have reported successfully using FFTW on Windows with
Chris@42 112 various compilers. FFTW was not developed on Windows, but the source
Chris@42 113 code is essentially straight ANSI C. See also the \docref{FFTW
Chris@42 114 Windows installation notes\}, \qref compilerCrashes, and \qref
Chris@42 115 vbetalia.
Chris@42 116
Chris@42 117 \question 26aug:compilerCrashes My compiler has trouble with FFTW.
Chris@42 118
Chris@42 119 Complain fiercely to the vendor of the compiler.
Chris@42 120
Chris@42 121 We have successfully used \courier{gcc\} 3.2.x on x86 and PPC, a
Chris@42 122 recent Compaq C compiler for Alpha, version 6 of IBM's \courier{xlc\}
Chris@42 123 compiler for AIX, Intel's \courier{icc\} versions 5-7, and Sun
Chris@42 124 WorkShop \courier{cc\} version 6.
Chris@42 125
Chris@42 126 FFTW is likely to push compilers to their limits, however, and several
Chris@42 127 compiler bugs have been exposed by FFTW. A partial list follows.
Chris@42 128
Chris@42 129 \courier{gcc\} 2.95.x for Solaris/SPARC produces incorrect code for
Chris@42 130 the test program (workaround: recompile the \courier{libbench2\}
Chris@42 131 directory with \courier{-O2\}).
Chris@42 132
Chris@42 133 NetBSD/macppc 1.6 comes with a \courier{gcc\} version that also
Chris@42 134 miscompiles the test program. (Please report a workaround if you know
Chris@42 135 one.)
Chris@42 136
Chris@42 137 \courier{gcc\} 3.2.3 for ARM reportedly crashes during compilation.
Chris@42 138 This bug is reportedly fixed in later versions of \courier{gcc\}.
Chris@42 139
Chris@42 140 Versions 8.0 and 8.1 of Intel's \courier{icc\} falsely claim to be
Chris@42 141 \courier{gcc\}, so you should specify \courier{CC="icc -no-gcc"\};
Chris@42 142 this is automatic in FFTW 3.1. \courier{icc-8.0.066\} reportely
Chris@42 143 produces incorrect code for FFTW 2.1.5, but is fixed in version 8.1.
Chris@42 144 \courier{icc-7.1\} compiler build 20030402Z appears to produce
Chris@42 145 incorrect dependencies, causing the compilation to fail.
Chris@42 146 \courier{icc-7.1\} build 20030307Z appears to work fine. (Use
Chris@42 147 \courier{icc -V\} to check which build you have.) As of 2003/04/18,
Chris@42 148 build 20030402Z appears not to be available any longer on Intel's
Chris@42 149 website, whereas the older build 20030307Z is available.
Chris@42 150
Chris@42 151 \courier{ranlib\} of GNU \courier{binutils\} 2.9.1 on Irix has been
Chris@42 152 observed to corrupt the FFTW libraries, causing a link failure when
Chris@42 153 FFTW is compiled. Since \courier{ranlib\} is completely superfluous
Chris@42 154 on Irix, we suggest deleting it from your system and replacing it with
Chris@42 155 a symbolic link to \courier{/bin/echo\}.
Chris@42 156
Chris@42 157 If support for SIMD instructions is enabled in FFTW, further compiler
Chris@42 158 problems may appear:
Chris@42 159
Chris@42 160 \courier{gcc\} 3.4.[0123] for x86 produces incorrect SSE2 code for
Chris@42 161 FFTW when \courier{-O2\} (the best choice for FFTW) is used, causing
Chris@42 162 FFTW to crash (\courier{make check\} crashes). This bug is fixed in
Chris@42 163 \courier{gcc\} 3.4.4. On x86_64 (amd64/em64t), \courier{gcc\} 3.4.4
Chris@42 164 reportedly still has a similar problem, but this is fixed as of
Chris@42 165 \courier{gcc\} 3.4.6.
Chris@42 166
Chris@42 167 \courier{gcc-3.2\} for x86 produces incorrect SIMD code if
Chris@42 168 \courier{-O3\} is used. The same compiler produces incorrect SIMD
Chris@42 169 code if no optimization is used, too. When using \courier{gcc-3.2\},
Chris@42 170 it is a good idea not to change the default \courier{CFLAGS\} selected
Chris@42 171 by the \courier{configure\} script.
Chris@42 172
Chris@42 173 Some 3.0.x and 3.1.x versions of \courier{gcc\} on \courier{x86\} may
Chris@42 174 crash. \courier{gcc\} so-called 2.96 shipping with RedHat 7.3 crashes
Chris@42 175 when compiling SIMD code. In both cases, please upgrade to
Chris@42 176 \courier{gcc-3.2\} or later.
Chris@42 177
Chris@42 178 Intel's \courier{icc\} 6.0 misaligns SSE constants, but FFTW has a
Chris@42 179 workaround. \courier{icc\} 8.x fails to compile FFTW 3.0.x because it
Chris@42 180 falsely claims to be \courier{gcc\}; we believe this to be a bug in
Chris@42 181 \courier{icc\}, but FFTW 3.1 has a workaround.
Chris@42 182
Chris@42 183 Visual C++ 2003 reportedly produces incorrect code for SSE/SSE2 when
Chris@42 184 compiling FFTW. This bug was reportedly fixed in VC++ 2005;
Chris@42 185 alternatively, you could switch to the Intel compiler. VC++ 6.0 also
Chris@42 186 reportedly produces incorrect code for the file
Chris@42 187 \courier{reodft11e-r2hc-odd.c\} unless optimizations are disabled for
Chris@42 188 that file.
Chris@42 189
Chris@42 190 \courier{gcc\} 2.95 on MacOS X miscompiles AltiVec code (fixed in
Chris@42 191 later versions). \courier{gcc\} 3.2.x miscompiles AltiVec
Chris@42 192 permutations, but FFTW has a workaround. \courier{gcc\} 4.0.1 on
Chris@42 193 MacOS for Intel crashes when compiling FFTW; a workaround is to
Chris@42 194 compile one file without optimization: \courier{cd kernel; make
Chris@42 195 CFLAGS=" " trig.lo\}.
Chris@42 196
Chris@42 197 \courier{gcc\} 4.1.1 reportedly crashes when compiling FFTW for MIPS;
Chris@42 198 the workaround is to compile the file it crashes on
Chris@42 199 (\courier{t2_64.c\}) with a lower optimization level.
Chris@42 200
Chris@42 201 \courier{gcc\} versions 4.1.2 to 4.2.0 for x86 reportedly miscompile
Chris@42 202 FFTW 3.1's test program, causing \courier{make check\} to crash
Chris@42 203 (\courier{gcc\} bug #26528). The bug was reportedly fixed in
Chris@42 204 \courier{gcc\} version 4.2.1 and later. A workaround is to compile
Chris@42 205 \courier{libbench2/verify-lib.c\} without optimization.
Chris@42 206
Chris@42 207 \question 26aug:solarisSucks FFTW does not compile on Solaris, complaining about \courier{const\}.
Chris@42 208
Chris@42 209 We know that at least on Solaris 2.5.x with Sun's compilers 4.2 you
Chris@42 210 might get error messages from \courier{make\} such as
Chris@42 211
Chris@42 212 \courier{"./fftw.h", line 88: warning: const is a keyword in ANSI C\}
Chris@42 213
Chris@42 214 This is the case when the \courier{configure\} script reports that
Chris@42 215 \courier{const\} does not work:
Chris@42 216
Chris@42 217 \courier{checking for working const... (cached) no\}
Chris@42 218
Chris@42 219 You should be aware that Solaris comes with two compilers, namely,
Chris@42 220 \courier{/opt/SUNWspro/SC4.2/bin/cc\} and \courier{/usr/ucb/cc\}. The
Chris@42 221 latter compiler is non-ANSI. Indeed, it is a perverse shell script
Chris@42 222 that calls the real compiler in non-ANSI mode. In order
Chris@42 223 to compile FFTW, change your path so that the right \courier{cc\}
Chris@42 224 is used.
Chris@42 225
Chris@42 226 To know whether your compiler is the right one, type
Chris@42 227 \courier{cc -V\}. If the compiler prints ``\courier{ucbcc\}'',
Chris@42 228 as in
Chris@42 229
Chris@42 230 \courier{ucbcc: WorkShop Compilers 4.2 30 Oct 1996 C 4.2\}
Chris@42 231
Chris@42 232 then the compiler is wrong. The right message is something like
Chris@42 233
Chris@42 234 \courier{cc: WorkShop Compilers 4.2 30 Oct 1996 C 4.2\}
Chris@42 235
Chris@42 236 \question 19mar:3dnow What's the difference between \courier{--enable-3dnow\} and \courier{--enable-k7\}?
Chris@42 237
Chris@42 238 \courier{--enable-k7\} enables 3DNow! instructions on K7 processors
Chris@42 239 (AMD Athlon and its variants). K7 support is provided by assembly
Chris@42 240 routines generated by a special purpose compiler.
Chris@42 241 As of fftw-3.2, --enable-k7 is no longer supported.
Chris@42 242
Chris@42 243 \courier{--enable-3dnow\} enables generic 3DNow! support using
Chris@42 244 \courier{gcc\} builtin functions. This works on earlier AMD
Chris@42 245 processors, but it is not as fast as our special assembly routines.
Chris@42 246 As of fftw-3.1, --enable-3dnow is no longer supported.
Chris@42 247
Chris@42 248 \question 18apr:fma What's the difference between the fma and the non-fma versions?
Chris@42 249
Chris@42 250 The fma version tries to exploit the fused multiply-add instructions
Chris@42 251 implemented in many processors such as PowerPC, ia-64, and MIPS. The
Chris@42 252 two FFTW packages are otherwise identical. In FFTW 3.1, the fma and
Chris@42 253 non-fma versions were merged together into a single package, and the
Chris@42 254 \courier{configure\} script attempts to automatically guess which
Chris@42 255 version to use.
Chris@42 256
Chris@42 257 The FFTW 3.1 \courier{configure\} script enables fma by default on
Chris@42 258 PowerPC, Itanium, and PA-RISC, and disables it otherwise. You can
Chris@42 259 force one or the other by using the \courier{--enable-fma\} or
Chris@42 260 \courier{--disable-fma\} flag for \courier{configure\}.
Chris@42 261
Chris@42 262 Definitely use fma if you have a PowerPC-based system with
Chris@42 263 \courier{gcc\} (or IBM \courier{xlc\}). This includes all GNU/Linux
Chris@42 264 systems for PowerPC and the older PowerPC-based MacOS systems. Also
Chris@42 265 use it on PA-RISC and Itanium with the HP/UX compiler.
Chris@42 266
Chris@42 267 Definitely do not use the fma version if you have an ia-32 processor
Chris@42 268 (Intel, AMD, MacOS on Intel, etcetera).
Chris@42 269
Chris@42 270 For other architectures/compilers, the situation is not so clear. For
Chris@42 271 example, ia-64 has the fma instruction, but \courier{gcc-3.2\} appears
Chris@42 272 not to exploit it correctly. Other compilers may do the right thing,
Chris@42 273 but we have not tried them. Please send us your feedback so that we
Chris@42 274 can update this FAQ entry.
Chris@42 275
Chris@42 276 \question 26aug:languages Which language is FFTW written in?
Chris@42 277
Chris@42 278 FFTW is written in ANSI C. Most of the code, however, was
Chris@42 279 automatically generated by a program called \courier{genfft\}, written
Chris@42 280 in the Objective Caml dialect of ML. You do not need to know ML or to
Chris@42 281 have an Objective Caml compiler in order to use FFTW.
Chris@42 282
Chris@42 283 \courier{genfft\} is provided with the FFTW sources, which means that
Chris@42 284 you can play with the code generator if you want. In this case, you
Chris@42 285 need a working Objective Caml system. Objective Caml is available
Chris@42 286 from \docref{the Caml web page\}.
Chris@42 287
Chris@42 288 \question 26aug:fortran Can I call FFTW from Fortran?
Chris@42 289
Chris@42 290 Yes, FFTW (versions 1.3 and higher) contains a Fortran-callable
Chris@42 291 interface, documented in the FFTW manual.
Chris@42 292
Chris@42 293 By default, FFTW configures its Fortran interface to work with the
Chris@42 294 first compiler it finds, e.g. \courier{g77\}. To configure for a
Chris@42 295 different, incompatible Fortran compiler \courier{foobar\}, use
Chris@42 296 \courier{./configure F77=foobar\} when installing FFTW. (In the case
Chris@42 297 of \courier{g77\}, however, FFTW 3.x also includes an extra set of
Chris@42 298 Fortran-callable routines with one less underscore at the end of
Chris@42 299 identifiers, which should cover most other Fortran compilers on Linux
Chris@42 300 at least.)
Chris@42 301
Chris@42 302 \question 26aug:cplusplus Can I call FFTW from C++?
Chris@42 303
Chris@42 304 Most definitely. FFTW should compile and/or link under any C++
Chris@42 305 compiler. Moreover, it is likely that the C++ \courier{<complex>\}
Chris@42 306 template class is bit-compatible with FFTW's complex-number format
Chris@42 307 (see the FFTW manual for more details).
Chris@42 308
Chris@42 309 \question 26aug:whynotfortran Why isn't FFTW written in Fortran/C++?
Chris@42 310
Chris@42 311 Because we don't like those languages, and neither approaches the
Chris@42 312 portability of C.
Chris@42 313
Chris@42 314 \question 29mar:singleprec How do I compile FFTW to run in single precision?
Chris@42 315
Chris@42 316 On a Unix system: \courier{configure --enable-float\}. On a non-Unix
Chris@42 317 system: edit \courier{config.h\} to \courier{#define\} the symbol
Chris@42 318 \courier{FFTW_SINGLE\} (for FFTW 3.x). In both cases, you must then
Chris@42 319 recompile FFTW. In FFTW 3, all FFTW identifiers will then begin with
Chris@42 320 \courier{fftwf_\} instead of \courier{fftw_\}.
Chris@42 321
Chris@42 322 \question 28mar:64bitk7 --enable-k7 does not work on x86-64
Chris@42 323
Chris@42 324 Support for --enable-k7 was discontinued in fftw-3.2.
Chris@42 325
Chris@42 326 The fftw-3.1 release supports --enable-k7. This option only works on
Chris@42 327 32-bit x86 machines that implement 3DNow!, including the AMD Athlon
Chris@42 328 and the AMD Opteron in 32-bit mode. --enable-k7 does not work on AMD
Chris@42 329 Opteron in 64-bit mode. Use --enable-sse for x86-64 machines.
Chris@42 330
Chris@42 331 FFTW supports 3DNow! by means of assembly code generated by a
Chris@42 332 special-purpose compiler. It is hard to produce assembly code that
Chris@42 333 works in both 32-bit and 64-bit mode.
Chris@42 334
Chris@42 335 \comment ######################################################################
Chris@42 336
Chris@42 337 \section Using FFTW
Chris@42 338
Chris@42 339 \question 15mar:fftw2to3 Why not support the FFTW 2 interface in FFTW 3?
Chris@42 340
Chris@42 341 FFTW 3 has semantics incompatible with earlier versions: its plans can
Chris@42 342 only be used for a given stride, multiplicity, and other
Chris@42 343 characteristics of the input and output arrays; these stronger
Chris@42 344 semantics are necessary for performance reasons. Thus, it is
Chris@42 345 impossible to efficiently emulate the older interface (whose plans can
Chris@42 346 be used for any transform of the same size). We believe that it
Chris@42 347 should be possible to upgrade most programs without any difficulty,
Chris@42 348 however.
Chris@42 349
Chris@42 350 \question 20mar:planperarray Why do FFTW 3 plans encapsulate the input/output arrays and not just the algorithm?
Chris@42 351
Chris@42 352 There are several reasons:
Chris@42 353
Chris@42 354 \call startlist
Chris@42 355 \call item
Chris@42 356 It was important for performance reasons that the plan be specific to
Chris@42 357 array characteristics like the stride (and alignment, for SIMD), and
Chris@42 358 requiring that the user maintain these invariants is error prone.
Chris@42 359 \call item
Chris@42 360 In most high-performance applications, as far as we can tell, you are
Chris@42 361 usually transforming the same array over and over, so FFTW's semantics
Chris@42 362 should not be a burden.
Chris@42 363 \call item
Chris@42 364 If you need to transform another array of the same size, creating a
Chris@42 365 new plan once the first exists is a cheap operation.
Chris@42 366 \call item
Chris@42 367 If you need to transform many arrays of the same size at once, you
Chris@42 368 should really use the \courier{plan_many\} routines in FFTW's "advanced"
Chris@42 369 interface.
Chris@42 370 \call item
Chris@42 371 If the abovementioned array characteristics are the same, you are
Chris@42 372 willing to pay close attention to the documentation, and you really
Chris@42 373 need to, we provide a "new-array execution" interface to apply a plan
Chris@42 374 to a new array.
Chris@42 375 \call endlist
Chris@42 376
Chris@42 377 \question 25may:slow FFTW seems really slow.
Chris@42 378
Chris@42 379 You are probably recreating the plan before every transform, rather
Chris@42 380 than creating it once and reusing it for all transforms of the same
Chris@42 381 size. FFTW is designed to be used in the following way:
Chris@42 382
Chris@42 383 \call startlist
Chris@42 384 \call item
Chris@42 385 First, you create a plan. This will take several seconds.
Chris@42 386 \call item
Chris@42 387 Then, you reuse the plan many times to perform FFTs. These are fast.
Chris@42 388 \call endlist
Chris@42 389
Chris@42 390 If you don't need to compute many transforms and the time for the
Chris@42 391 planner is significant, you have two options. First, you can use the
Chris@42 392 \courier{FFTW_ESTIMATE\} option in the planner, which uses heuristics
Chris@42 393 instead of runtime measurements and produces a good plan in a short
Chris@42 394 time. Second, you can use the wisdom feature to precompute the plan;
Chris@42 395 see \qref savePlans
Chris@42 396
Chris@42 397 \question 22oct:slows FFTW slows down after repeated calls.
Chris@42 398
Chris@42 399 Probably, NaNs or similar are creeping into your data, and the
Chris@42 400 slowdown is due to the resulting floating-point exceptions. For
Chris@42 401 example, be aware that repeatedly FFTing the same array is a diverging
Chris@42 402 process (because FFTW computes the unnormalized transform).
Chris@42 403
Chris@42 404 \question 22oct:segfault An FFTW routine is crashing when I call it.
Chris@42 405
Chris@42 406 Did the FFTW test programs pass (\courier{make check\}, or \courier{cd
Chris@42 407 tests; make bigcheck\} if you want to be paranoid)? If so, you almost
Chris@42 408 certainly have a bug in your own code. For example, you could be
Chris@42 409 passing invalid arguments (such as wrongly-sized arrays) to FFTW, or
Chris@42 410 you could simply have memory corruption elsewhere in your program that
Chris@42 411 causes random crashes later on. Please don't complain to us unless
Chris@42 412 you can come up with a minimal self-contained program (preferably
Chris@42 413 under 30 lines) that illustrates the problem.
Chris@42 414
Chris@42 415 \question 22oct:fortran64 My Fortran program crashes when calling FFTW.
Chris@42 416
Chris@42 417 As described in the manual, on 64-bit machines you must store the
Chris@42 418 plans in variables large enough to hold a pointer, for example
Chris@42 419 \courier{integer*8\}. We recommend using \courier{integer*8\} on
Chris@42 420 32-bit machines as well, to simplify porting.
Chris@42 421
Chris@42 422 \question 24mar:conventions FFTW gives results different from my old FFT.
Chris@42 423
Chris@42 424 People follow many different conventions for the DFT, and you should
Chris@42 425 be sure to know the ones that we use (described in the FFTW manual).
Chris@42 426 In particular, you should be aware that the
Chris@42 427 \courier{FFTW_FORWARD\}/\courier{FFTW_BACKWARD\} directions correspond
Chris@42 428 to signs of -1/+1 in the exponent of the DFT definition.
Chris@42 429 (\italic{Numerical Recipes\} uses the opposite convention.)
Chris@42 430
Chris@42 431 You should also know that we compute an unnormalized transform. In
Chris@42 432 contrast, Matlab is an example of program that computes a normalized
Chris@42 433 transform. See \qref whyscaled.
Chris@42 434
Chris@42 435 Finally, note that floating-point arithmetic is not exact, so
Chris@42 436 different FFT algorithms will give slightly different results (on the
Chris@42 437 order of the numerical accuracy; typically a fractional difference of
Chris@42 438 1e-15 or so in double precision).
Chris@42 439
Chris@42 440 \question 31aug:nondeterministic FFTW gives different results between runs
Chris@42 441
Chris@42 442 If you use \courier{FFTW_MEASURE\} or \courier{FFTW_PATIENT\} mode,
Chris@42 443 then the algorithm FFTW employs is not deterministic: it depends on
Chris@42 444 runtime performance measurements. This will cause the results to vary
Chris@42 445 slightly from run to run. However, the differences should be slight,
Chris@42 446 on the order of the floating-point precision, and therefore should
Chris@42 447 have no practical impact on most applications.
Chris@42 448
Chris@42 449 If you use saved plans (wisdom) or \courier{FFTW_ESTIMATE\} mode,
Chris@42 450 however, then the algorithm is deterministic and the results should be
Chris@42 451 identical between runs.
Chris@42 452
Chris@42 453 \question 26aug:savePlans Can I save FFTW's plans?
Chris@42 454
Chris@42 455 Yes. Starting with version 1.2, FFTW provides the \courier{wisdom\}
Chris@42 456 mechanism for saving plans; see the FFTW manual.
Chris@42 457
Chris@42 458 \question 14sep:whyscaled Why does your inverse transform return a scaled result?
Chris@42 459
Chris@42 460 Computing the forward transform followed by the backward transform (or
Chris@42 461 vice versa) yields the original array scaled by the size of the array.
Chris@42 462 (For multi-dimensional transforms, the size of the array is the
Chris@42 463 product of the dimensions.) We could, instead, have chosen a
Chris@42 464 normalization that would have returned the unscaled array. Or, to
Chris@42 465 accomodate the many conventions in this matter, the transform routines
Chris@42 466 could have accepted a "scale factor" parameter. We did not do this,
Chris@42 467 however, for two reasons. First, we didn't want to sacrifice
Chris@42 468 performance in the common case where the scale factor is 1. Second, in
Chris@42 469 real applications the FFT is followed or preceded by some computation
Chris@42 470 on the data, into which the scale factor can typically be absorbed at
Chris@42 471 little or no cost.
Chris@42 472
Chris@42 473 \question 02dec:centerorigin How can I make FFTW put the origin (zero frequency) at the center of its output?
Chris@42 474
Chris@42 475 For human viewing of a spectrum, it is often convenient to put the
Chris@42 476 origin in frequency space at the center of the output array, rather
Chris@42 477 than in the zero-th element (the default in FFTW). If all of the
Chris@42 478 dimensions of your array are even, you can accomplish this by simply
Chris@42 479 multiplying each element of the input array by (-1)^(i + j + ...),
Chris@42 480 where i, j, etcetera are the indices of the element. (This trick is a
Chris@42 481 general property of the DFT, and is not specific to FFTW.)
Chris@42 482
Chris@42 483 \question 08may:imageaudio How do I FFT an image/audio file in \italic{foobar\} format?
Chris@42 484
Chris@42 485 FFTW performs an FFT on an array of floating-point values. You can
Chris@42 486 certainly use it to compute the transform of an image or audio stream,
Chris@42 487 but you are responsible for figuring out your data format and
Chris@42 488 converting it to the form FFTW requires.
Chris@42 489
Chris@42 490 \question 09apr:linkfails My program does not link (on Unix).
Chris@42 491
Chris@42 492 The libraries must be listed in the correct order (\courier{-lfftw3
Chris@42 493 -lm\} for FFTW 3.x) and \italic{after\} your program sources/objects.
Chris@42 494 (The general rule is that if \italic{A\} uses \italic{B\}, then
Chris@42 495 \italic{A\} must be listed before \italic{B\} in the link command.).
Chris@42 496
Chris@42 497 \question 15mar:linkheader I included your header, but linking still fails.
Chris@42 498
Chris@42 499 You're a C++ programmer, aren't you? You have to compile the FFTW
Chris@42 500 library and link it into your program, not just \courier{#include
Chris@42 501 <fftw3.h>\}. (Yes, this is really a FAQ.)
Chris@42 502
Chris@42 503 \question 22oct:nostack My program crashes, complaining about stack space.
Chris@42 504
Chris@42 505 You cannot declare large arrays with automatic storage (e.g. via
Chris@42 506 \courier{fftw_complex array[N]\}); you should use
Chris@42 507 \courier{fftw_malloc\} (or equivalent) to allocate the arrays you want
Chris@42 508 to transform if they are larger than a few hundred elements.
Chris@42 509
Chris@42 510 \question 13may:leaks FFTW seems to have a memory leak.
Chris@42 511
Chris@42 512 After you create a plan, FFTW caches the information required to
Chris@42 513 quickly recreate the plan. (See \qref savePlans) It also maintains a
Chris@42 514 small amount of other persistent memory. You can deallocate all of
Chris@42 515 FFTW's internally allocated memory, if you wish, by calling
Chris@42 516 \courier{fftw_cleanup()\}, as documented in the manual.
Chris@42 517
Chris@42 518 \question 16may:allzero The output of FFTW's transform is all zeros.
Chris@42 519
Chris@42 520 You should initialize your input array \italic{after\} creating the
Chris@42 521 plan, unless you use \courier{FFTW_ESTIMATE\}: planning with
Chris@42 522 \courier{FFTW_MEASURE\} or \courier{FFTW_PATIENT\} overwrites the
Chris@42 523 input/output arrays, as described in the manual.
Chris@42 524
Chris@42 525 \question 05sep:vbetalia How do I call FFTW from the Microsoft language du jour?
Chris@42 526
Chris@42 527 Please \italic{do not\} ask us Windows-specific questions. We do not
Chris@42 528 use Windows. We know nothing about Visual Basic, Visual C++, or .NET.
Chris@42 529 Please find the appropriate Usenet discussion group and ask your
Chris@42 530 question there. See also \qref runOnWindows.
Chris@42 531
Chris@42 532 \question 15oct:pruned Can I compute only a subset of the DFT outputs?
Chris@42 533
Chris@42 534 In general, no, an FFT intrinsically computes all outputs from all
Chris@42 535 inputs. In principle, there is something called a \italic{pruned
Chris@42 536 FFT\} that can do what you want, but to compute K outputs out of N the
Chris@42 537 complexity is in general O(N log K) instead of O(N log N), thus saving
Chris@42 538 only a small additive factor in the log. (The same argument holds if
Chris@42 539 you instead have only K nonzero inputs.)
Chris@42 540
Chris@42 541 There are some specific cases in which you can get the O(N log K)
Chris@42 542 performance benefits easily, however, by combining a few ordinary
Chris@42 543 FFTs. In particular, the case where you want the first K outputs,
Chris@42 544 where K divides N, can be handled by performing N/K transforms of size
Chris@42 545 K and then summing the outputs multiplied by appropriate phase
Chris@42 546 factors. For more details, see \docref{pruned FFTs with FFTW\}.
Chris@42 547
Chris@42 548 There are also some algorithms that compute pruned transforms
Chris@42 549 \italic{approximately\}, but they are beyond the scope of this FAQ.
Chris@42 550
Chris@42 551 \question 21jan:transpose Can I use FFTW's routines for in-place and out-of-place matrix transposition?
Chris@42 552
Chris@42 553 You can use the FFTW guru interface to create a rank-0 transform of
Chris@42 554 vector rank 2 where the vector strides are transposed. (A rank-0
Chris@42 555 transform is equivalent to a 1D transform of size 1, which. just
Chris@42 556 copies the input into the output.) Specifying the same location for
Chris@42 557 the input and output makes the transpose in-place.
Chris@42 558
Chris@42 559 For double-valued data stored in row-major format, plan creation looks like
Chris@42 560 this:
Chris@42 561
Chris@42 562 \verbatim
Chris@42 563 fftw_plan plan_transpose(int rows, int cols, double *in, double *out)
Chris@42 564 {
Chris@42 565 const unsigned flags = FFTW_ESTIMATE; /* other flags are possible */
Chris@42 566 fftw_iodim howmany_dims[2];
Chris@42 567
Chris@42 568 howmany_dims[0].n = rows;
Chris@42 569 howmany_dims[0].is = cols;
Chris@42 570 howmany_dims[0].os = 1;
Chris@42 571
Chris@42 572 howmany_dims[1].n = cols;
Chris@42 573 howmany_dims[1].is = 1;
Chris@42 574 howmany_dims[1].os = rows;
Chris@42 575
Chris@42 576 return fftw_plan_guru_r2r(/*rank=*/ 0, /*dims=*/ NULL,
Chris@42 577 /*howmany_rank=*/ 2, howmany_dims,
Chris@42 578 in, out, /*kind=*/ NULL, flags);
Chris@42 579 }
Chris@42 580 \endverbatim
Chris@42 581
Chris@42 582 (This entry was written by Rhys Ulerich.)
Chris@42 583
Chris@42 584 \comment ######################################################################
Chris@42 585
Chris@42 586 \section Internals of FFTW
Chris@42 587
Chris@42 588 \question 26aug:howworks How does FFTW work?
Chris@42 589
Chris@42 590 The innovation (if it can be so called) in FFTW consists in having a
Chris@42 591 variety of composable \italic{solvers\}, representing different FFT
Chris@42 592 algorithms and implementation strategies, whose combination into a
Chris@42 593 particular \italic{plan\} for a given size can be determined at
Chris@42 594 runtime according to the characteristics of your machine/compiler.
Chris@42 595 This peculiar software architecture allows FFTW to adapt itself to
Chris@42 596 almost any machine.
Chris@42 597
Chris@42 598 For more details (albeit somewhat outdated), see the paper "FFTW: An
Chris@42 599 Adaptive Software Architecture for the FFT", by M. Frigo and
Chris@42 600 S. G. Johnson, \italic{Proc. ICASSP\} 3, 1381 (1998), also
Chris@42 601 available at \docref{the FFTW web page\}.
Chris@42 602
Chris@42 603 \question 26aug:whyfast Why is FFTW so fast?
Chris@42 604
Chris@42 605 This is a complex question, and there is no simple answer. In fact,
Chris@42 606 the authors do not fully know the answer, either. In addition to many
Chris@42 607 small performance hacks throughout FFTW, there are three general
Chris@42 608 reasons for FFTW's speed.
Chris@42 609
Chris@42 610 \call startlist
Chris@42 611 \call item
Chris@42 612 FFTW uses a variety of FFT algorithms and implementation styles
Chris@42 613 that can be arbitrarily composed to adapt itself to
Chris@42 614 a machine. See \qref howworks.
Chris@42 615 \call item
Chris@42 616 FFTW uses a code generator to produce highly-optimized
Chris@42 617 routines for computing small transforms.
Chris@42 618 \call item
Chris@42 619 FFTW uses explicit divide-and-conquer to take advantage
Chris@42 620 of the memory hierarchy.
Chris@42 621 \call endlist
Chris@42 622
Chris@42 623 For more details (albeit somewhat outdated), see the paper "FFTW: An
Chris@42 624 Adaptive Software Architecture for the FFT", by M. Frigo and
Chris@42 625 S. G. Johnson, \italic{Proc. ICASSP\} 3, 1381 (1998),
Chris@42 626 available along with other references at \docref{the FFTW web page\}.
Chris@42 627
Chris@42 628 \comment ######################################################################
Chris@42 629
Chris@42 630 \section Known bugs
Chris@42 631
Chris@42 632 \question 27aug:rfftwndbug FFTW 1.1 crashes in rfftwnd on Linux.
Chris@42 633
Chris@42 634 This bug was fixed in FFTW 1.2. There was a bug in \courier{rfftwnd\}
Chris@42 635 causing an incorrect amount of memory to be allocated. The bug showed
Chris@42 636 up in Linux with libc-5.3.12 (and nowhere else that we know of).
Chris@42 637
Chris@42 638 \question 15oct:fftwmpibug The MPI transforms in FFTW 1.2 give incorrect results/leak memory.
Chris@42 639
Chris@42 640 These bugs were corrected in FFTW 1.2.1. The MPI transforms (really,
Chris@42 641 just the transpose routines) in FFTW 1.2 had bugs that could cause
Chris@42 642 errors in some situations.
Chris@42 643
Chris@42 644 \question 05nov:testsingbug The test programs in FFTW 1.2.1 fail when I change FFTW to use single precision.
Chris@42 645
Chris@42 646 This bug was fixed in FFTW 1.3. (Older versions of FFTW did
Chris@42 647 work in single precision, but the test programs didn't--the error
Chris@42 648 tolerances in the tests were set for double precision.)
Chris@42 649
Chris@42 650 \question 24mar:teststoobig The test program in FFTW 1.2.1 fails for n > 46340.
Chris@42 651
Chris@42 652 This bug was fixed in FFTW 1.3. FFTW 1.2.1 produced the right answer,
Chris@42 653 but the test program was wrong. For large n, n*n in the naive
Chris@42 654 transform that we used for comparison overflows 32 bit integer
Chris@42 655 precision, breaking the test.
Chris@42 656
Chris@42 657 \question 24aug:linuxthreads The threaded code fails on Linux Redhat 5.0
Chris@42 658
Chris@42 659 We had problems with glibc-2.0.5. The code should work with
Chris@42 660 glibc-2.0.7.
Chris@42 661
Chris@42 662 \question 26sep:bigrfftwnd FFTW 2.0's rfftwnd fails for rank > 1 transforms with a final dimension >= 65536.
Chris@42 663
Chris@42 664 This bug was fixed in FFTW 2.0.1. (There was a 32-bit integer overflow due
Chris@42 665 to a poorly-parenthesized expression.)
Chris@42 666
Chris@42 667 \question 26mar:primebug FFTW 2.0's complex transforms give the wrong results with prime factors 17 to 97.
Chris@42 668
Chris@42 669 There was a bug in the complex transforms that could cause incorrect
Chris@42 670 results under (hopefully rare) circumstances for lengths with
Chris@42 671 intermediate-size prime factors (17-97). This bug was fixed in FFTW
Chris@42 672 2.1.1.
Chris@42 673
Chris@42 674 \question 05apr:mpichbug FFTW 2.1.1's MPI test programs crash with MPICH.
Chris@42 675
Chris@42 676 This bug was fixed in FFTW 2.1.2. The 2.1/2.1.1 MPI test programs crashed
Chris@42 677 when using the MPICH implementation of MPI with the \courier{ch_p4\}
Chris@42 678 device (TCP/IP); the transforms themselves worked fine.
Chris@42 679
Chris@42 680 \question 25may:aixthreadbug FFTW 2.1.2's multi-threaded transforms don't work on AIX.
Chris@42 681
Chris@42 682 This bug was fixed in FFTW 2.1.3. The multi-threaded transforms in
Chris@42 683 previous versions didn't work with AIX's \courier{pthreads\}
Chris@42 684 implementation, which idiosyncratically creates threads in detached
Chris@42 685 (non-joinable) mode by default.
Chris@42 686
Chris@42 687 \question 27sep:bigprimebug FFTW 2.1.2's complex transforms give incorrect results for large prime sizes.
Chris@42 688
Chris@42 689 This bug was fixed in FFTW 2.1.3. FFTW's complex-transform algorithm
Chris@42 690 for prime sizes (in versions 2.0 to 2.1.2) had an integer overflow
Chris@42 691 problem that caused incorrect results for many primes greater than
Chris@42 692 32768 (on 32-bit machines). (Sizes without large prime factors are
Chris@42 693 not affected.)
Chris@42 694
Chris@42 695 \question 25may:solaristhreadbug FFTW 2.1.3's multi-threaded transforms don't give any speedup on Solaris.
Chris@42 696
Chris@42 697 This bug was fixed in FFTW 2.1.4. (By default, Solaris creates
Chris@42 698 threads that do not parallelize over multiple processors, so one has
Chris@42 699 to request the proper behavior specifically.)
Chris@42 700
Chris@42 701 \question 03may:aixflags FFTW 2.1.3 crashes on AIX.
Chris@42 702
Chris@42 703 The FFTW 2.1.3 \courier{configure\} script picked incorrect compiler
Chris@42 704 flags for the \courier{xlc\} compiler on newer IBM processors. This
Chris@42 705 is fixed in FFTW 2.1.4.
Chris@42 706
Chris@42 707 \comment Here it ends!
Chris@42 708