- Infos im HLRS Wiki sind nicht rechtsverbindlich und ohne Gewähr -
- Information contained in the HLRS Wiki is not legally binding and HLRS is not responsible for any damages that might result from its use -

FFTW: Difference between revisions

From HLRS Platforms
Jump to navigationJump to search
No edit summary
No edit summary
(32 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Infobox software
{{Infobox software
| description = '''FFTW''' (Fastest Fourier Transform in the West) is a free collection of fast C routines for computing the Discrete Fourier Transform in one or more dimensions. It includes complex, real, symmetric and parallel transforms and can handle arbitrary array sizes efficiently. FFTW is typically faster than other publically-available FFT implementations and is even competitive with vendor-tuned libraries.
| description = '''FFTW''' (Fastest Fourier Transform in the West) is a free collection of fast C routines for computing the Discrete Fourier Transform in one or more dimensions. It includes complex, real, symmetric and parallel transforms and can handle arbitrary array sizes efficiently. FFTW is typically faster than other publically-available FFT implementations and is even competitive with vendor-tuned libraries.
| logo = [[Image:fftw-logo.gif]]
| developer              =  
| developer              =  
| available on      = [[NEC Nehalem Cluster]]
| available on      = [[NEC Nehalem Cluster]]
| category                 = [[:Category:Numerical Library | Numerical Library]]
| category           = [[:Category:Numerical Library | Numerical Library]]
| license               =  
| license           = Open Source / GNU GPL
| website               = [http://www.fftw.org/  FFTW Home Page]  
| website           = [http://www.fftw.org/  FFTW Home Page]  
}}
}}
=== Using FFTW on Nehalem cluster ===
The library has been compiled with type-prefix for both single and double precision.
There are two versions of FFTW instaled on Nehalem cluster:
* intel
* gnu
=== Example ===
This example shows the basic steps when using fftw.
Load the necessary module. For example:
{{Command| command =<nowiki>
module load numlib/fftw/3.3.2-typeprefix-openmpi-1.6-intel-12.1.5
</nowiki>
}}
=== Simple example ===
{{File|filename = ex1_fftw.c
| content = <pre>
      /*
      * fft.c: compute FFT and IFFT from an array
      */
      #include <stdio.h>
      #include <fftw3.h>
      #define SIZE 4
      int main( int argc, char** argv )
      {
          double          input[SIZE] = { 1.0, 1.0, 1.0, 1.0 };
          fftw_complex    *data, *fft_result, *ifft_result;
          fftw_plan      plan_forward, plan_backward;
          int            i;
          data        = ( fftw_complex* ) fftw_malloc( sizeof( fftw_complex ) * SIZE );
          fft_result  = ( fftw_complex* ) fftw_malloc( sizeof( fftw_complex ) * SIZE );
          ifft_result = ( fftw_complex* ) fftw_malloc( sizeof( fftw_complex ) * SIZE );
          plan_forward  = fftw_plan_dft_1d( SIZE, data, fft_result, FFTW_FORWARD, FFTW_ESTIMATE );
          plan_backward = fftw_plan_dft_1d( SIZE, fft_result, ifft_result, FFTW_BACKWARD,
                                            FFTW_ESTIMATE );
          /* populate input data */
          for( i = 0 ; i < SIZE ; i++ ) {
              data[i][0] = input[i];
              data[i][1] = 0.0;
          }
          /* print initial data */
          for( i = 0 ; i < SIZE ; i++ ) {
              fprintf( stdout, "data[%d] = { %2.2f, %2.2f }\n",
                          i, data[i][0], data[i][1] );
          }
          fftw_execute( plan_forward );
          /* print fft result */
          for( i = 0 ; i < SIZE ; i++ ) {
              fprintf( stdout, "fft_result[%d] = { %2.2f, %2.2f }\n",
                          i, fft_result[i][0], fft_result[i][1] );
          }
          fftw_execute( plan_backward );
          /* print ifft result */
          for( i = 0 ; i < SIZE ; i++ ) {
              fprintf( stdout, "ifft_result[%d] = { %2.2f, %2.2f }\n",
                          i, ifft_result[i][0] / SIZE, ifft_result[i][1] / SIZE );
          }
          /* free memory */
          fftw_destroy_plan( plan_forward );
          fftw_destroy_plan( plan_backward );
          fftw_free( data );
          fftw_free( fft_result );
          fftw_free( ifft_result );
          return 0;
      }
</pre>}}
=== Compile with ===
{{Command| command = icc ex1_fftw.c -o ex1 -I/$FFTW_HOME/include -L/$FFTW_HOME/lib -lfftw3
(lfftw3f for single version)
}}
The shell variable $FFTW_HOME is available after loading the required modules.
For the single precision version all FFTW identifiers will begin with fftwf_ instead of fftw_.
== See also ==
* [[Software Development Tools, Compilers & Libraries]]
== External links ==
* [http://www.fftw.org  FFTW Home Page]
[[Category:Numerical Library]]

Revision as of 10:58, 2 May 2013

FFTW (Fastest Fourier Transform in the West) is a free collection of fast C routines for computing the Discrete Fourier Transform in one or more dimensions. It includes complex, real, symmetric and parallel transforms and can handle arbitrary array sizes efficiently. FFTW is typically faster than other publically-available FFT implementations and is even competitive with vendor-tuned libraries.
Fftw-logo.gif
Developer:
Platforms: NEC Nehalem Cluster
Category: Numerical Library
License: Open Source / GNU GPL
Website: FFTW Home Page


Using FFTW on Nehalem cluster

The library has been compiled with type-prefix for both single and double precision.

There are two versions of FFTW instaled on Nehalem cluster:

  • intel
  • gnu

Example

This example shows the basic steps when using fftw.

Load the necessary module. For example:

module load numlib/fftw/3.3.2-typeprefix-openmpi-1.6-intel-12.1.5


Simple example

File: ex1_fftw.c
      /*
       * fft.c: compute FFT and IFFT from an array
       */
      #include <stdio.h>
      #include <fftw3.h>

      #define SIZE 4

      int main( int argc, char** argv )
      {
          double          input[SIZE] = { 1.0, 1.0, 1.0, 1.0 };
          fftw_complex    *data, *fft_result, *ifft_result;
          fftw_plan       plan_forward, plan_backward;
          int             i;

          data        = ( fftw_complex* ) fftw_malloc( sizeof( fftw_complex ) * SIZE );
          fft_result  = ( fftw_complex* ) fftw_malloc( sizeof( fftw_complex ) * SIZE );
          ifft_result = ( fftw_complex* ) fftw_malloc( sizeof( fftw_complex ) * SIZE );

          plan_forward  = fftw_plan_dft_1d( SIZE, data, fft_result, FFTW_FORWARD, FFTW_ESTIMATE );
          plan_backward = fftw_plan_dft_1d( SIZE, fft_result, ifft_result, FFTW_BACKWARD, 
                                            FFTW_ESTIMATE );

          /* populate input data */
          for( i = 0 ; i < SIZE ; i++ ) {
              data[i][0] = input[i];
              data[i][1] = 0.0;
          }

          /* print initial data */
          for( i = 0 ; i < SIZE ; i++ ) {
              fprintf( stdout, "data[%d] = { %2.2f, %2.2f }\n",
                          i, data[i][0], data[i][1] );
          }

          fftw_execute( plan_forward );

          /* print fft result */
          for( i = 0 ; i < SIZE ; i++ ) {
              fprintf( stdout, "fft_result[%d] = { %2.2f, %2.2f }\n",
                          i, fft_result[i][0], fft_result[i][1] );
          }

          fftw_execute( plan_backward );

          /* print ifft result */
          for( i = 0 ; i < SIZE ; i++ ) {
              fprintf( stdout, "ifft_result[%d] = { %2.2f, %2.2f }\n",
                          i, ifft_result[i][0] / SIZE, ifft_result[i][1] / SIZE );
          }
          /* free memory */
          fftw_destroy_plan( plan_forward );
          fftw_destroy_plan( plan_backward );

          fftw_free( data );
          fftw_free( fft_result );
          fftw_free( ifft_result );

          return 0;
      }


Compile with

icc ex1_fftw.c -o ex1 -I/$FFTW_HOME/include -L/$FFTW_HOME/lib -lfftw3 (lfftw3f for single version)

The shell variable $FFTW_HOME is available after loading the required modules.

For the single precision version all FFTW identifiers will begin with fftwf_ instead of fftw_.

See also

External links