Mercurial > hg > sv-dependency-builds
diff src/fftw-3.3.3/doc/html/Multi_002ddimensional-MPI-DFTs-of-Real-Data.html @ 10:37bf6b4a2645
Add FFTW3
author | Chris Cannam |
---|---|
date | Wed, 20 Mar 2013 15:35:50 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/fftw-3.3.3/doc/html/Multi_002ddimensional-MPI-DFTs-of-Real-Data.html Wed Mar 20 15:35:50 2013 +0000 @@ -0,0 +1,158 @@ +<html lang="en"> +<head> +<title>Multi-dimensional MPI DFTs of Real Data - FFTW 3.3.3</title> +<meta http-equiv="Content-Type" content="text/html"> +<meta name="description" content="FFTW 3.3.3"> +<meta name="generator" content="makeinfo 4.13"> +<link title="Top" rel="start" href="index.html#Top"> +<link rel="up" href="Distributed_002dmemory-FFTW-with-MPI.html#Distributed_002dmemory-FFTW-with-MPI" title="Distributed-memory FFTW with MPI"> +<link rel="prev" href="MPI-Data-Distribution.html#MPI-Data-Distribution" title="MPI Data Distribution"> +<link rel="next" href="Other-Multi_002ddimensional-Real_002ddata-MPI-Transforms.html#Other-Multi_002ddimensional-Real_002ddata-MPI-Transforms" title="Other Multi-dimensional Real-data MPI Transforms"> +<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> +<!-- +This manual is for FFTW +(version 3.3.3, 25 November 2012). + +Copyright (C) 2003 Matteo Frigo. + +Copyright (C) 2003 Massachusetts Institute of Technology. + + Permission is granted to make and distribute verbatim copies of + this manual provided the copyright notice and this permission + notice are preserved on all copies. + + Permission is granted to copy and distribute modified versions of + this manual under the conditions for verbatim copying, provided + that the entire resulting derived work is distributed under the + terms of a permission notice identical to this one. + + Permission is granted to copy and distribute translations of this + manual into another language, under the above conditions for + modified versions, except that this permission notice may be + stated in a translation approved by the Free Software Foundation. + --> +<meta http-equiv="Content-Style-Type" content="text/css"> +<style type="text/css"><!-- + pre.display { font-family:inherit } + pre.format { font-family:inherit } + pre.smalldisplay { font-family:inherit; font-size:smaller } + pre.smallformat { font-family:inherit; font-size:smaller } + pre.smallexample { font-size:smaller } + pre.smalllisp { font-size:smaller } + span.sc { font-variant:small-caps } + span.roman { font-family:serif; font-weight:normal; } + span.sansserif { font-family:sans-serif; font-weight:normal; } +--></style> +</head> +<body> +<div class="node"> +<a name="Multi-dimensional-MPI-DFTs-of-Real-Data"></a> +<a name="Multi_002ddimensional-MPI-DFTs-of-Real-Data"></a> +<p> +Next: <a rel="next" accesskey="n" href="Other-Multi_002ddimensional-Real_002ddata-MPI-Transforms.html#Other-Multi_002ddimensional-Real_002ddata-MPI-Transforms">Other Multi-dimensional Real-data MPI Transforms</a>, +Previous: <a rel="previous" accesskey="p" href="MPI-Data-Distribution.html#MPI-Data-Distribution">MPI Data Distribution</a>, +Up: <a rel="up" accesskey="u" href="Distributed_002dmemory-FFTW-with-MPI.html#Distributed_002dmemory-FFTW-with-MPI">Distributed-memory FFTW with MPI</a> +<hr> +</div> + +<h3 class="section">6.5 Multi-dimensional MPI DFTs of Real Data</h3> + +<p>FFTW's MPI interface also supports multi-dimensional DFTs of real +data, similar to the serial r2c and c2r interfaces. (Parallel +one-dimensional real-data DFTs are not currently supported; you must +use a complex transform and set the imaginary parts of the inputs to +zero.) + + <p>The key points to understand for r2c and c2r MPI transforms (compared +to the MPI complex DFTs or the serial r2c/c2r transforms), are: + + <ul> +<li>Just as for serial transforms, r2c/c2r DFTs transform n<sub>0</sub> × n<sub>1</sub> × n<sub>2</sub> × … × n<sub>d-1</sub> real +data to/from n<sub>0</sub> × n<sub>1</sub> × n<sub>2</sub> × … × (n<sub>d-1</sub>/2 + 1) complex data: the last dimension of the +complex data is cut in half (rounded down), plus one. As for the +serial transforms, the sizes you pass to the ‘<samp><span class="samp">plan_dft_r2c</span></samp>’ and +‘<samp><span class="samp">plan_dft_c2r</span></samp>’ are the n<sub>0</sub> × n<sub>1</sub> × n<sub>2</sub> × … × n<sub>d-1</sub> dimensions of the real data. + + <li><a name="index-padding-386"></a>Although the real data is <em>conceptually</em> n<sub>0</sub> × n<sub>1</sub> × n<sub>2</sub> × … × n<sub>d-1</sub>, it is +<em>physically</em> stored as an n<sub>0</sub> × n<sub>1</sub> × n<sub>2</sub> × … × [2 (n<sub>d-1</sub>/2 + 1)] array, where the last +dimension has been <em>padded</em> to make it the same size as the +complex output. This is much like the in-place serial r2c/c2r +interface (see <a href="Multi_002dDimensional-DFTs-of-Real-Data.html#Multi_002dDimensional-DFTs-of-Real-Data">Multi-Dimensional DFTs of Real Data</a>), except that +in MPI the padding is required even for out-of-place data. The extra +padding numbers are ignored by FFTW (they are <em>not</em> like +zero-padding the transform to a larger size); they are only used to +determine the data layout. + + <li><a name="index-data-distribution-387"></a>The data distribution in MPI for <em>both</em> the real and complex data +is determined by the shape of the <em>complex</em> data. That is, you +call the appropriate ‘<samp><span class="samp">local size</span></samp>’ function for the n<sub>0</sub> × n<sub>1</sub> × n<sub>2</sub> × … × (n<sub>d-1</sub>/2 + 1) + + <p>complex data, and then use the <em>same</em> distribution for the real +data except that the last complex dimension is replaced by a (padded) +real dimension of twice the length. + + </ul> + + <p>For example suppose we are performing an out-of-place r2c transform of +L × M × N real data [padded to L × M × 2(N/2+1)], +resulting in L × M × N/2+1 complex data. Similar to the +example in <a href="2d-MPI-example.html#g_t2d-MPI-example">2d MPI example</a>, we might do something like: + +<pre class="example"> #include <fftw3-mpi.h> + + int main(int argc, char **argv) + { + const ptrdiff_t L = ..., M = ..., N = ...; + fftw_plan plan; + double *rin; + fftw_complex *cout; + ptrdiff_t alloc_local, local_n0, local_0_start, i, j, k; + + MPI_Init(&argc, &argv); + fftw_mpi_init(); + + /* <span class="roman">get local data size and allocate</span> */ + alloc_local = fftw_mpi_local_size_3d(L, M, N/2+1, MPI_COMM_WORLD, + &local_n0, &local_0_start); + rin = fftw_alloc_real(2 * alloc_local); + cout = fftw_alloc_complex(alloc_local); + + /* <span class="roman">create plan for out-of-place r2c DFT</span> */ + plan = fftw_mpi_plan_dft_r2c_3d(L, M, N, rin, cout, MPI_COMM_WORLD, + FFTW_MEASURE); + + /* <span class="roman">initialize rin to some function</span> my_func(x,y,z) */ + for (i = 0; i < local_n0; ++i) + for (j = 0; j < M; ++j) + for (k = 0; k < N; ++k) + rin[(i*M + j) * (2*(N/2+1)) + k] = my_func(local_0_start+i, j, k); + + /* <span class="roman">compute transforms as many times as desired</span> */ + fftw_execute(plan); + + fftw_destroy_plan(plan); + + MPI_Finalize(); + } +</pre> + <p><a name="index-fftw_005falloc_005freal-388"></a><a name="index-row_002dmajor-389"></a>Note that we allocated <code>rin</code> using <code>fftw_alloc_real</code> with an +argument of <code>2 * alloc_local</code>: since <code>alloc_local</code> is the +number of <em>complex</em> values to allocate, the number of <em>real</em> +values is twice as many. The <code>rin</code> array is then +local_n0 × M × 2(N/2+1) in row-major order, so its +<code>(i,j,k)</code> element is at the index <code>(i*M + j) * (2*(N/2+1)) + +k</code> (see <a href="Multi_002ddimensional-Array-Format.html#Multi_002ddimensional-Array-Format">Multi-dimensional Array Format</a>). + + <p><a name="index-transpose-390"></a><a name="index-FFTW_005fTRANSPOSED_005fOUT-391"></a><a name="index-FFTW_005fTRANSPOSED_005fIN-392"></a>As for the complex transforms, improved performance can be obtained by +specifying that the output is the transpose of the input or vice versa +(see <a href="Transposed-distributions.html#Transposed-distributions">Transposed distributions</a>). In our L × M × N r2c +example, including <code>FFTW_TRANSPOSED_OUT</code> in the flags means that +the input would be a padded L × M × 2(N/2+1) real array +distributed over the <code>L</code> dimension, while the output would be a +M × L × N/2+1 complex array distributed over the <code>M</code> +dimension. To perform the inverse c2r transform with the same data +distributions, you would use the <code>FFTW_TRANSPOSED_IN</code> flag. + +<!-- --> + </body></html> +