Windows下的快速傅里叶变换库fftw


http://fftw.org/install/windows.html

Go back to the FFTW download page. 
  


 

              Windows Installation Notes

This document contains various information regarding installation of FFTW on DOS/Windows. (It was sent in by users, and has not been personally verified by us.) Please contact us if you have any additions or corrections. You should, of course, first read the Installation on non-Unix Systems of the FFTW 3 manual (or the corresponding section of the FFTW 2 manual).

Precompiled FFTW 3.3.4 Windows DLLs

We have created precompiled DLL files for FFTW 3.3.4 in single/double/long-double precision, along with the associated test programs. We hope that these are sufficient for most users, so that you need not worry about compiling FFTW:

These DLLs were created by us, cross-compiled from GNU/Linux using MinGW; the 64-bit version is possible thanks to the mingw-w64 project. You should be able to call them from any compiler. In order to link to them from Visual C++, you will need to create .lib "import libraries" using the lib.exeprogram included with VC++. Run:

     lib /def:libfftw3-3.def
     lib /def:libfftw3f-3.def
     lib /def:libfftw3l-3.def

On Visual Studio 2008 in 64-bit mode, and possibly in other cases, you may need to specify the machine explicitly:

     lib /machine:x64 /def:libfftw3l-3.def

For Borland C++, you instead need to use Borland's implib program, via (thanks to M. Lenarczyk):

     implib -a fftw3-3.lib libfftw3-3.dll
     implib -a fftw3f-3.lib libfftw3f-3.dll
     implib -a fftw3l-3.lib libfftw3l-3.dll

See DLLs and wisdom, below, for important information on using wisdom import/export from a DLL.

Contact us if you have suggestions, but realize that we don't use Windows ourselves.

We created these .zip files with the scripts BUILD-MINGW32.sh and BUILD-MINGW64.sh; see also the MinGW instructions below. Thanks to John Pavel for his extensive feedback.

Compiling FFTW 3 for Windows

If for some reason you need to compile FFTW yourself on Windows, rather than using the above DLLs, you have several options:

  • MinGW: this is a free Unix-like environment for Windows based on the GNU C compiler (gcc). We recommend this route because it produces native Windows executables/libraries, but lets you use our standard Unix build scripts and Makefiles, automatically picks good compiler flags, and so on. See below for instructions.

  • Visual C++: In the past, several users have contributed Visual C++ project files for FFTW which you can download below. However, many older versions of VC++ generate incorrect code for FFTW when SSE/SSE2 is enabled. VC++ 2003 definitely fails. VC++ 2005 may work, and VC++ 2010 has been reported to work.

  • Intel C: you can also use the Intel compilers under VC++ (see below). This may produce marginally faster code than the GNU C compiler, but is probably not worth it for most users. Be cautious with the compiler flags—turning on every optimization under the sun usually makes FFTW slower.

If you do compile FFTW yourself, we encourage you to compare the speed of the resulting executable with the gcc-compiled version that we provide above. In particular, you can use the bench.exe program to benchmark a few typical sizes to get an idea of how they compare:

     bench.exe -opatient 64 128 256 512 1024 2048 4096

Building FFTW 3 under MinGW

The simplest way to compile FFTW on Windows is probably to install the free MinGW Unix environment so that you can use the GNU C compiler (gcc).

There are a few options to our configure script that we especially recommend on Windows:

  • --disable-alloca: as of this writing (14 July 2009), the alloca function seems to be broken under the 64-bit MinGW compilers, so when compiling for Win64 you should pass --disable-alloca to tell FFTW not to use that function
  • --with-our-malloc16: this is required in order to allocate properly aligned memory (for SSE) with gcc
  • --with-windows-f77-mangling: this will include Fortran wrappers for some common Windows Fortran compilers (GNU, Intel, and Digital).
  • --enable-shared --disable-static: this will create DLLs instead of static libraries (since MinGW's static-library format seems to be different from Microsoft's).
  • --enable-threads --with-combined-threads: this will include multi-threading support. The second option puts the multi-threading functions into the main FFTW DLL rather than into a separate DLL (the default under Unix); this is required because MinGW can't create DLLs that depend on one another.
  • --enable-portable-binary: required if you want to create DLLs that will work on any Intel processor.
  • --with-incoming-stack-boundary=2: compile FFTW assuming a 4-byte alignment. On win32, some versions of gcc assume that the stack is 16-byte aligned, but code compiled with other compilers may only guarantee a 4-byte alignment, resulting in mysterious segfaults.
  • Either or both of the following to exploit SSE2/AVX (the DLL is still portable because it checks at runtime to make sure SSE2/AVX is available):
    • [--enable-float] --enable-sse2.
    • [--enable-float] --enable-avx.

So, for example, to build a double-precision library you might use

    ./configure --with-our-malloc16 --with-windows-f77-mangling --enable-shared --disable-static --enable-threads --with-combined-threads --enable-portable-binary --enable-sse2 --with-incoming-stack-boundary=2
    make
    make install

The resulting DLL files are installed in /usr/local/bin.

Important: If you want to call the resulting DLL from another compiler (i.e. not from MinGW), you need to add a line #define FFTW_DLL to fftw3.h (installed in /usr/local/include). This adds some __declspec decorations to the function declarations.

Building FFTW 3.x under Visual C++/Intel compilers

Important: If you want to compile FFTW as a DLL, you should add a line #define FFTW_DLL to fftw3.h and ifftw.h before compiling. This will add the requisite__declspec decorations to function declarations etc.

Project files to compile FFTW 3.3 with Visual Studio 2010 were sent to us by Long To: fftw-3.3-libs-visual-studio-2010.zip.

Project files to compile FFTW 3.2.2 with Visual Studio 2010 were sent to us by Long To: fftw-3.2.2-libs-visual-studio-2010.zip.

Project files to compile FFTW 3.2.2 with Visual Studio 2008 were sent to us by Nathaniel Meyer (nate at nutty dot ca): fftw-3.2.2-vs2008.zip.

Project files to compile FFTW 3.1.2 with the Intel compilers under Visual Studio .NET 2003 were sent to us by Jin Tian (jintian at nlsde dot buaa dot edu dot cn): fftw-3.1.2-vs2003.zip.

Franz Franchetti has graciously offered to provide up-to-date FFTW binaries and project files using Visual Studio and the Intel C compiler at his web page.

DLLs and wisdom

FFTW implements a mechanism called "wisdom" for saving plans to disk (see the manual). FFTW 3.3 includes fftw_export_wisdom_to_filename andfftw_import_wisdom_from_filename functions where you supply a filename to write/read to/from, respectively. We believe that these should work fine from Windows DLLs.

However, FFTW also provides fftw_export_wisdom_to_file and fftw_import_wisdom_from_file routines where you specify a C FILE pointer to a file you have opened yourself, and users have reported that these routines do not work properly from DLLs. (These were the only file I/O routines in versions of FFTW prior to 3.3.) It's been suggested to us that this has to do with there being multiple C runtime libraries in Windows (see here).

We expect that most users will need only the filename functions. However, if you need to use the fftw_export_wisdom_to_file and fftw_import_wisdom_from_filefunctions (e.g. you need to write wisdom to part of a file, and write something else to the rest of the file), then you can use the following workaround in Windows. In particular, FFTW provides generic import/export functions that allow you to specify a routine for reading/writing characters. That way, you can supply a routine to access the file yourself and the DLL never has to see it. You can provide a drop-in replacement for FFTW'sfftw_export_wisdom_to_file and fftw_import_wisdom_from_file functions simply by including the following lines after you #include <fftw3.h>:

static void my_fftw_write_char(char c, void *f) { fputc(c, (FILE *) f); }
#define fftw_export_wisdom_to_file(f) fftw_export_wisdom(my_fftw_write_char, (void*) (f))
#define fftwf_export_wisdom_to_file(f) fftwf_export_wisdom(my_fftw_write_char, (void*) (f))
#define fftwl_export_wisdom_to_file(f) fftwl_export_wisdom(my_fftw_write_char, (void*) (f))

static int my_fftw_read_char(void *f) { return fgetc((FILE *) f); }
#define fftw_import_wisdom_from_file(f) fftw_import_wisdom(my_fftw_read_char, (void*) (f))
#define fftwf_import_wisdom_from_file(f) fftwf_import_wisdom(my_fftw_read_char, (void*) (f))
#define fftwl_import_wisdom_from_file(f) fftwl_import_wisdom(my_fftw_read_char, (void*) (f))

Older stuff

Below are older instructions and packages that were sent to us, but which are now probably out of date.

FFTW 3.0.1 and Visual C++/Intel compilers

Alessio Massaro contributed Windows binaries of fftw-3.0.1, compiled with the Intel C Compiler version 7.1. This package uses SSE/SSE2 instructions when appropriate. This archive is called fftw-3.0.1-w32-pl1.zip and was created on Nov 13, 2003. If you downloaded the older archive fftw-3.0.1-w32.zip, please upgrade. Some library symbols were incorrectly not exported in the older build.

Alessio has also sent us Windows binaries compiled with gcc under MinGW, which support for threads and have AMD K7 (3dNow!) in addition to SSE/SSE2. An updated version of this file was contributed by Boran Car, which incorporates a missing libgcc.a library file. This library can be called from Visual C++ and other Windows compilers.

Klaus Maisinger contributed .def and .lib files for Borland C++ Builder 6 to to allow you to use the above Intel-compiled binaries; you need to use Klaus' fftw3.lib in addition to fix compatibility problems between Borland C++ and Visual C++. See also his description of what he did.

The above binaries were, unfortunately, compiled without the Fortran wrapper routines. Koos Huijssen sent us a library file for Compaq Visual Fortranthat you can use, in addition to Alessio's DLL, to call FFTW from that Fortran compiler.

Stephane Ruel helped us to get FFTW 3 working under Visual C++, and sent us a build file to compile FFTW with that compiler. (Note that this package provides modified versions of some FFTW files, which are no longer necessary with FFTW version 3.0.1. Also, it refers to the files rdft/vrank2-transpose.cand rdft/vrank3-transpose.c, which are no longer included or needed; references to them should be deleted from the build, or you can create empty files with these names. Other compiler warnings can be ignored.)

Mark Roden send us modified build files to use Visual C++ 6.0 with version 8.0 of the Intel compiler and FFTW 3.0.1, with threads and SSE enabled.

Visual C++ Problems

Visual C++ is buggy. Get a real compiler and do not complain to us.

Stephane Ruel was unable to get the SIMD (SSE) code to produce correct results with Visual C++ 6.0; we suspect a compiler bug (the same code works fine with gcc and Intel icc). We have an unconfirmed report of similar problems with version 7.0. If you have a more recent version of VC++, please let us know whether it works.

Stephane recently reported that he was able to compile the SIMD code in FFTW 3.0.1 using the Intel compiler version 7.1 (with flags -O3 -G7 -QxW) with Visual C++. (Modify config.h to #define either HAVE_SSE or HAVE_SSE2, depending upon the precision.)

Visual C++ 4.0 and 5.0 had some problems compiling previous FFTW versions correctly, but these were fixed in later releases of those compilers, which however introduced new bugs for new FFTW versions.

VC++ 6.0 also reportedly produces incorrect code for the file reodft11e-r2hc-odd.c (odd-size type-IV DCTs and DSTs) unless optimizations are disabled for that file.

Visual C++ Project Files and Win32 Binaries for FFTW 2.x

Andrew Sterian  has put together  project workspace files  for Microsoft Visual C++ 5.0 that can be used to build FFTW 2.1.3 smoothly from within the IDE. His workspace also allows building the FFTW library as a DLL. Please read through the README.TXT file for important information about using FFTW as a DLL.

You should note that the FFTW package can be compiled as-is on Windows--you simply need to compile all of the .c files in the fftw and rfftw directories. Andrew's files may provide extra convenience, however, especially when building DLLs.

Andrew's package also includes some code to allow the test program to accept command-line parameters in the DOS shell (otherwise, the test program will run in interactive mode on Windows).

You can also find the latest versions of Andrew's packages, as well as prebuilt binaries for Win32 (x86) on his web site.

FFTW 3.x and Borland Delphi

An updated Delphi/Pascal interface (fftw3-delphi.zip) was contributed by Serder Kacar, which includes double and extended precision, wisdom, and threads support, and works with the precompiled Windows DLLs that we supply above.

Kacar's interface was based on work by George Beckett, who contributed a Pascal interface file (fftw_interface.pas) for calling FFTW from Borland Delphi (Pascal). This file is for the single-precision FFTW, but double-precision could be used as well by changing the appropriate types and renamingfftwf_ to fftw_ in the file. Beckett also sent us his notes on calling FFTW from Delphi as well as on compiling FFTW on Windows with the Borland C++ compiler. Finally, he sent us the compiled library via Borland (see also the material from Klaus Maisinger, above). George recommends using the DLLs from Alessio Massaro instead, though, for better performance (note that Alessio's symbol names do not need to be prepended with an underscore, however).

FFTW 2.x and Dev-C++/MinGW

Marek Januszewski has created an FFTW 2.x DevPak for use with Dev-C++ (a MinGW front-end).

Alignment with FFTW 2.x

FFTW includes special hacks to align double-precision variables on the stack for gcc on x86. One of our users, Jonathan Hardwick, has done a detailed study of how these hacks might be extended to Visual C++ and the Intel C++ compiler, and what their performance effects are.

Fortran with FFTW 2.x

FFTW can include Fortran-callable wrapper routines so that you can call the FFTW functions from a Fortran program. These routines are not available automatically on Windows, however.

The problem is that FFTW does not know how to mangle its subroutine names for the Fortran linker (Fortran expects all identifiers to be in a canonical case and format). On Unix systems, our configure script can automatically detect the name-mangling scheme, but this is not possible on Windows. So, you have to specify it manually in order to use the Fortran wrappers.

To do this, go to the end of the fftw/config.h file and #define the appropriate symbol according to the comments. There are eight possibilities: all upper or lower case, and zero, one, or two appended underscores. For example, Digital Visual Fortran (reportedly) uses all lower case with no appended underscore, so you should #define FFTW_FORTRANIZE_LOWERCASE. (If you don't know, you can experiment with a small Fortran and C program until you find something that works. Your Fortran manual may also document how to link with C.) Let us know how it works with your Fortran compiler.

There is another issue to be aware of with Digital Fortran: for every routine that you want to call (e.g. fftw_f77), you must include an instruction like the following at the beginning of your Fortran program:

!DEC$ ATTRIBUTES C, REFERENCE :: fftw_f77

(Thanks to Dima Berkov for this note.)

Timer with FFTW 2.x

FFTW includes a high-precision timer that will be automatically (see below) enabled under Win32, contributed by Andrew Sterian.

We have not tested this code ourselves, however, and it may cause problems for some users. (In particular, problems have been reported with its use of the header file windows.h, which is not recognized in some configurations.) To disable the use of this timing code (and revert to the default clock()function), comment out the line:

#define HAVE_WIN32_TIMER
in  config.h .

If you want to make sure that the timer is automatically enabled in your compiler, delete the #if directive surrounding the above line. (This directive is used to automatically enable the timer, but it won't work if your compiler doesn't define __WIN32__WIN32, or _WINDOWS. Visual C++ and Borland C/C++ should be fine.)

Watcom with FFTW 2.x

Daniel Q. Naiman  emailed us to say that he got FFTW running under Watcom's C compiler, version 10.6. He had to  #include  the file  watcom\h\nt\windows.h  in config.h  to get things running (presumably because of the timer code).

FFTW 1.2

Here are some changes to the Makefile sent in by Robert Jansen to get FFTW 1.2 running under the DOS shell with gcc:

  • RM = del
  • CP = copy
  • AR = ar
  • In the library compilation part, use:
    $(AR) rv $(LIBFFT) *.o
    
    due to argument number constraints in make (there are likely other work-arounds).
  • Change $(RM) -f to $(RM)
  • Remove all _64 modules in config.c and the Makefile due to a stack limit problem. (This might be solved by simply increasing the stack size inconfig.sys; he didn't check.)
(Many of these changes may not be necessary with other compilers or if you install a DOS-UNIX package like like uxut123 from the Oakland software repository.)


Be sure to  let us know  if you have to make any other changes to get things working under Windows.
Go  back  to the FFTW download page.




Introduction

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 or DCT/DST). We believe that FFTW, which is  free software , should become the  FFT  library of choice for most applications.

The latest official release of FFTW is version 3.3.4, available from our download page. Version 3.3 introduced support for the AVX x86 extensions, a distributed-memory implementation on top of MPI, and a Fortran 2003 API. Version 3.3.1 introduced support for the ARM Neon extensions. See the release notes for more information.

The FFTW package was developed at MIT by Matteo Frigo and Steven G. Johnson.

Our benchmarks, performed on on a variety of platforms, show that FFTW's performance is typically superior to that of other publicly available FFT software, and is even competitive with vendor-tuned codes. In contrast to vendor-tuned codes, however, FFTW's performance is portable: the same program will perform well on most architectures without modification. Hence the name, "FFTW," which stands for the somewhat whimsical title of "Fastest Fourier Transform in the West."

Subscribe to the fftw-announce mailing list to receive release announcements (or use the web feed RSS).

Features

FFTW 3.3.4 is the latest official version of FFTW (refer to the  release notes  to find out what is new).  Here is a list of some of FFTW's more interesting features:
  • Speed. (Supports SSE/SSE2/Altivec, since version 3.0. Version 3.3.1 supports AVX and ARM Neon.)
  • Both one-dimensional and multi-dimensional transforms.
  • Arbitrary-size transforms. (Sizes with small prime factors are best, but FFTW uses O(N log N) algorithms even for prime sizes.)
  • Fast transforms of purely real input or output data.
  • Transforms of real even/odd data: the discrete cosine transform (DCT) and the discrete sine transform (DST), types I-IV. (Version 3.0 or later.)
  • Efficient handling of multiple, strided transforms. (This lets you do things like transform multiple arrays at once, transform one dimension of a multi-dimensional array, or transform one field of a multi-component array.)
  • Parallel transforms: parallelized code for platforms with SMP machines with some flavor of threads (e.g. POSIX) or OpenMP. An MPI version for distributed-memory transforms is also available in FFTW 3.3.
  • Portable to any platform with a C compiler.
  • Documentation in HTML and other formats.
  • Both C and Fortran interfaces.
  • Free software, released under the GNU General Public License (GPL, see FFTW license). (Non-free licenses may also be purchased from MIT, for users who do not want their programs protected by the GPL. Contact us for details.) (See also the FAQ.)

If you are still using FFTW 2.x, please note that FFTW 2.x was last updated in 1999 and it is obsolete. Please upgrade to FFTW 3.x. The API of FFTW 3.x is incompatible with that of FFTW 2.x, for reasons of performance and generality (see the FAQ or the manual).

Documentation

First, read the  FFTW Frequently Asked Questions  document.

Manual: HTML or PDF.

man pages: the fftw-wisdom and fftw-wisdom-to-conf utilities.

For general questions about Fourier transforms, see our links to FFT-related resources. People often ask us how to compute a subset of the FFT outputs, so we have posted a short discussion of pruned FFTs.

We benchmarked FFTW against many other FFT programs, in one to three dimensions, on a variety of platforms. You can view the results from this benchmark, or download it to run on your own machine and compiler, at the benchFFT web page.

An audio interview of the FFTW authors is available from the RCE podcast program.

Downloading

Versions 3.3.4 and 2.1.5 of FFTW may be  downloaded from this site . Feel free to post FFTW on your own site, but be sure to tell us so that we can link to your page and notify you of updates to the software.

Literature.

Awards

FFTW received the 1999 J. H. Wilkinson Prize for Numerical Software, which is awarded every four years to the software that "best addresses all phases of the preparation of high quality numerical software." Wilkinson was a seminal figure in modern numerical analysis as well as a key proponent of the notion of reusable, common libraries for scientific computing, and we are especially honored to receive this award in his memory.

Our paper "A Fast Fourier Transform Compiler" (in PLDI 1999) received the Most Influential PLDI Paper award in 2009.

Acknowledgements

We are grateful for the support of many people and companies, including Sun, Intel, the GNU project, and the Linux community. Please see the acknowledgements section  of our manual for a more complete list of those who helped us. We are especially thankful to all of our users for their continuing support, feedback, and interest in the development of FFTW.

Related Links

We have put together a  list of links  to other interesting sites with FFT-related code or information. This should be helpful if you want to know more about Fourier transforms or if for some reason FFTW doesn't satisfy your needs.

Feedback

If you have comments, questions, or suggestions regarding FFTW, don't hesitate to email us at  fftw@fftw.org . We support encrypted/signed email. Use  our public keys .
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值