Mercurial > hg > sv-dependency-builds
comparison src/fftw-3.3.5/doc/html/Multi_002ddimensional-MPI-DFTs-of-Real-Data.html @ 127:7867fa7e1b6b
Current fftw source
| author | Chris Cannam <cannam@all-day-breakfast.com> |
|---|---|
| date | Tue, 18 Oct 2016 13:40:26 +0100 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 126:4a7071416412 | 127:7867fa7e1b6b |
|---|---|
| 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
| 2 <html> | |
| 3 <!-- This manual is for FFTW | |
| 4 (version 3.3.5, 30 July 2016). | |
| 5 | |
| 6 Copyright (C) 2003 Matteo Frigo. | |
| 7 | |
| 8 Copyright (C) 2003 Massachusetts Institute of Technology. | |
| 9 | |
| 10 Permission is granted to make and distribute verbatim copies of this | |
| 11 manual provided the copyright notice and this permission notice are | |
| 12 preserved on all copies. | |
| 13 | |
| 14 Permission is granted to copy and distribute modified versions of this | |
| 15 manual under the conditions for verbatim copying, provided that the | |
| 16 entire resulting derived work is distributed under the terms of a | |
| 17 permission notice identical to this one. | |
| 18 | |
| 19 Permission is granted to copy and distribute translations of this manual | |
| 20 into another language, under the above conditions for modified versions, | |
| 21 except that this permission notice may be stated in a translation | |
| 22 approved by the Free Software Foundation. --> | |
| 23 <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ --> | |
| 24 <head> | |
| 25 <title>FFTW 3.3.5: Multi-dimensional MPI DFTs of Real Data</title> | |
| 26 | |
| 27 <meta name="description" content="FFTW 3.3.5: Multi-dimensional MPI DFTs of Real Data"> | |
| 28 <meta name="keywords" content="FFTW 3.3.5: Multi-dimensional MPI DFTs of Real Data"> | |
| 29 <meta name="resource-type" content="document"> | |
| 30 <meta name="distribution" content="global"> | |
| 31 <meta name="Generator" content="makeinfo"> | |
| 32 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
| 33 <link href="index.html#Top" rel="start" title="Top"> | |
| 34 <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index"> | |
| 35 <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> | |
| 36 <link href="Distributed_002dmemory-FFTW-with-MPI.html#Distributed_002dmemory-FFTW-with-MPI" rel="up" title="Distributed-memory FFTW with MPI"> | |
| 37 <link href="Other-Multi_002ddimensional-Real_002ddata-MPI-Transforms.html#Other-Multi_002ddimensional-Real_002ddata-MPI-Transforms" rel="next" title="Other Multi-dimensional Real-data MPI Transforms"> | |
| 38 <link href="One_002ddimensional-distributions.html#One_002ddimensional-distributions" rel="prev" title="One-dimensional distributions"> | |
| 39 <style type="text/css"> | |
| 40 <!-- | |
| 41 a.summary-letter {text-decoration: none} | |
| 42 blockquote.smallquotation {font-size: smaller} | |
| 43 div.display {margin-left: 3.2em} | |
| 44 div.example {margin-left: 3.2em} | |
| 45 div.indentedblock {margin-left: 3.2em} | |
| 46 div.lisp {margin-left: 3.2em} | |
| 47 div.smalldisplay {margin-left: 3.2em} | |
| 48 div.smallexample {margin-left: 3.2em} | |
| 49 div.smallindentedblock {margin-left: 3.2em; font-size: smaller} | |
| 50 div.smalllisp {margin-left: 3.2em} | |
| 51 kbd {font-style:oblique} | |
| 52 pre.display {font-family: inherit} | |
| 53 pre.format {font-family: inherit} | |
| 54 pre.menu-comment {font-family: serif} | |
| 55 pre.menu-preformatted {font-family: serif} | |
| 56 pre.smalldisplay {font-family: inherit; font-size: smaller} | |
| 57 pre.smallexample {font-size: smaller} | |
| 58 pre.smallformat {font-family: inherit; font-size: smaller} | |
| 59 pre.smalllisp {font-size: smaller} | |
| 60 span.nocodebreak {white-space:nowrap} | |
| 61 span.nolinebreak {white-space:nowrap} | |
| 62 span.roman {font-family:serif; font-weight:normal} | |
| 63 span.sansserif {font-family:sans-serif; font-weight:normal} | |
| 64 ul.no-bullet {list-style: none} | |
| 65 --> | |
| 66 </style> | |
| 67 | |
| 68 | |
| 69 </head> | |
| 70 | |
| 71 <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> | |
| 72 <a name="Multi_002ddimensional-MPI-DFTs-of-Real-Data"></a> | |
| 73 <div class="header"> | |
| 74 <p> | |
| 75 Next: <a href="Other-Multi_002ddimensional-Real_002ddata-MPI-Transforms.html#Other-Multi_002ddimensional-Real_002ddata-MPI-Transforms" accesskey="n" rel="next">Other Multi-dimensional Real-data MPI Transforms</a>, Previous: <a href="MPI-Data-Distribution.html#MPI-Data-Distribution" accesskey="p" rel="prev">MPI Data Distribution</a>, Up: <a href="Distributed_002dmemory-FFTW-with-MPI.html#Distributed_002dmemory-FFTW-with-MPI" accesskey="u" rel="up">Distributed-memory FFTW with MPI</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> | |
| 76 </div> | |
| 77 <hr> | |
| 78 <a name="Multi_002ddimensional-MPI-DFTs-of-Real-Data-1"></a> | |
| 79 <h3 class="section">6.5 Multi-dimensional MPI DFTs of Real Data</h3> | |
| 80 | |
| 81 <p>FFTW’s MPI interface also supports multi-dimensional DFTs of real | |
| 82 data, similar to the serial r2c and c2r interfaces. (Parallel | |
| 83 one-dimensional real-data DFTs are not currently supported; you must | |
| 84 use a complex transform and set the imaginary parts of the inputs to | |
| 85 zero.) | |
| 86 </p> | |
| 87 <p>The key points to understand for r2c and c2r MPI transforms (compared | |
| 88 to the MPI complex DFTs or the serial r2c/c2r transforms), are: | |
| 89 </p> | |
| 90 <ul> | |
| 91 <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 | |
| 92 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 | |
| 93 complex data is cut in half (rounded down), plus one. As for the | |
| 94 serial transforms, the sizes you pass to the ‘<samp>plan_dft_r2c</samp>’ and | |
| 95 ‘<samp>plan_dft_c2r</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. | |
| 96 | |
| 97 </li><li> <a name="index-padding-4"></a> | |
| 98 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 | |
| 99 <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 | |
| 100 dimension has been <em>padded</em> to make it the same size as the | |
| 101 complex output. This is much like the in-place serial r2c/c2r | |
| 102 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 | |
| 103 in MPI the padding is required even for out-of-place data. The extra | |
| 104 padding numbers are ignored by FFTW (they are <em>not</em> like | |
| 105 zero-padding the transform to a larger size); they are only used to | |
| 106 determine the data layout. | |
| 107 | |
| 108 </li><li> <a name="index-data-distribution-3"></a> | |
| 109 The data distribution in MPI for <em>both</em> the real and complex data | |
| 110 is determined by the shape of the <em>complex</em> data. That is, you | |
| 111 call the appropriate ‘<samp>local size</samp>’ function for the n<sub>0</sub> × n<sub>1</sub> × n<sub>2</sub> × … × (n<sub>d-1</sub>/2 + 1) | |
| 112 complex data, and then use the <em>same</em> distribution for the real | |
| 113 data except that the last complex dimension is replaced by a (padded) | |
| 114 real dimension of twice the length. | |
| 115 | |
| 116 </li></ul> | |
| 117 | |
| 118 <p>For example suppose we are performing an out-of-place r2c transform of | |
| 119 L × M × N real data [padded to L × M × 2(N/2+1)], | |
| 120 resulting in L × M × N/2+1 complex data. Similar to the | |
| 121 example in <a href="2d-MPI-example.html#g_t2d-MPI-example">2d MPI example</a>, we might do something like: | |
| 122 </p> | |
| 123 <div class="example"> | |
| 124 <pre class="example">#include <fftw3-mpi.h> | |
| 125 | |
| 126 int main(int argc, char **argv) | |
| 127 { | |
| 128 const ptrdiff_t L = ..., M = ..., N = ...; | |
| 129 fftw_plan plan; | |
| 130 double *rin; | |
| 131 fftw_complex *cout; | |
| 132 ptrdiff_t alloc_local, local_n0, local_0_start, i, j, k; | |
| 133 | |
| 134 MPI_Init(&argc, &argv); | |
| 135 fftw_mpi_init(); | |
| 136 | |
| 137 /* <span class="roman">get local data size and allocate</span> */ | |
| 138 alloc_local = fftw_mpi_local_size_3d(L, M, N/2+1, MPI_COMM_WORLD, | |
| 139 &local_n0, &local_0_start); | |
| 140 rin = fftw_alloc_real(2 * alloc_local); | |
| 141 cout = fftw_alloc_complex(alloc_local); | |
| 142 | |
| 143 /* <span class="roman">create plan for out-of-place r2c DFT</span> */ | |
| 144 plan = fftw_mpi_plan_dft_r2c_3d(L, M, N, rin, cout, MPI_COMM_WORLD, | |
| 145 FFTW_MEASURE); | |
| 146 | |
| 147 /* <span class="roman">initialize rin to some function</span> my_func(x,y,z) */ | |
| 148 for (i = 0; i < local_n0; ++i) | |
| 149 for (j = 0; j < M; ++j) | |
| 150 for (k = 0; k < N; ++k) | |
| 151 rin[(i*M + j) * (2*(N/2+1)) + k] = my_func(local_0_start+i, j, k); | |
| 152 | |
| 153 /* <span class="roman">compute transforms as many times as desired</span> */ | |
| 154 fftw_execute(plan); | |
| 155 | |
| 156 fftw_destroy_plan(plan); | |
| 157 | |
| 158 MPI_Finalize(); | |
| 159 } | |
| 160 </pre></div> | |
| 161 | |
| 162 <a name="index-fftw_005falloc_005freal-2"></a> | |
| 163 <a name="index-row_002dmajor-5"></a> | |
| 164 <p>Note that we allocated <code>rin</code> using <code>fftw_alloc_real</code> with an | |
| 165 argument of <code>2 * alloc_local</code>: since <code>alloc_local</code> is the | |
| 166 number of <em>complex</em> values to allocate, the number of <em>real</em> | |
| 167 values is twice as many. The <code>rin</code> array is then | |
| 168 local_n0 × M × 2(N/2+1) in row-major order, so its | |
| 169 <code>(i,j,k)</code> element is at the index <code>(i*M + j) * (2*(N/2+1)) + | |
| 170 k</code> (see <a href="Multi_002ddimensional-Array-Format.html#Multi_002ddimensional-Array-Format">Multi-dimensional Array Format</a>). | |
| 171 </p> | |
| 172 <a name="index-transpose-1"></a> | |
| 173 <a name="index-FFTW_005fTRANSPOSED_005fOUT"></a> | |
| 174 <a name="index-FFTW_005fTRANSPOSED_005fIN"></a> | |
| 175 <p>As for the complex transforms, improved performance can be obtained by | |
| 176 specifying that the output is the transpose of the input or vice versa | |
| 177 (see <a href="Transposed-distributions.html#Transposed-distributions">Transposed distributions</a>). In our L × M × N r2c | |
| 178 example, including <code>FFTW_TRANSPOSED_OUT</code> in the flags means that | |
| 179 the input would be a padded L × M × 2(N/2+1) real array | |
| 180 distributed over the <code>L</code> dimension, while the output would be a | |
| 181 M × L × N/2+1 complex array distributed over the <code>M</code> | |
| 182 dimension. To perform the inverse c2r transform with the same data | |
| 183 distributions, you would use the <code>FFTW_TRANSPOSED_IN</code> flag. | |
| 184 </p> | |
| 185 <hr> | |
| 186 <div class="header"> | |
| 187 <p> | |
| 188 Next: <a href="Other-Multi_002ddimensional-Real_002ddata-MPI-Transforms.html#Other-Multi_002ddimensional-Real_002ddata-MPI-Transforms" accesskey="n" rel="next">Other Multi-dimensional Real-data MPI Transforms</a>, Previous: <a href="MPI-Data-Distribution.html#MPI-Data-Distribution" accesskey="p" rel="prev">MPI Data Distribution</a>, Up: <a href="Distributed_002dmemory-FFTW-with-MPI.html#Distributed_002dmemory-FFTW-with-MPI" accesskey="u" rel="up">Distributed-memory FFTW with MPI</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> | |
| 189 </div> | |
| 190 | |
| 191 | |
| 192 | |
| 193 </body> | |
| 194 </html> |
