annotate src/fftw-3.3.3/doc/html/Multi_002ddimensional-MPI-DFTs-of-Real-Data.html @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents 89f5e221ed7b
children
rev   line source
cannam@95 1 <html lang="en">
cannam@95 2 <head>
cannam@95 3 <title>Multi-dimensional MPI DFTs of Real Data - FFTW 3.3.3</title>
cannam@95 4 <meta http-equiv="Content-Type" content="text/html">
cannam@95 5 <meta name="description" content="FFTW 3.3.3">
cannam@95 6 <meta name="generator" content="makeinfo 4.13">
cannam@95 7 <link title="Top" rel="start" href="index.html#Top">
cannam@95 8 <link rel="up" href="Distributed_002dmemory-FFTW-with-MPI.html#Distributed_002dmemory-FFTW-with-MPI" title="Distributed-memory FFTW with MPI">
cannam@95 9 <link rel="prev" href="MPI-Data-Distribution.html#MPI-Data-Distribution" title="MPI Data Distribution">
cannam@95 10 <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">
cannam@95 11 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
cannam@95 12 <!--
cannam@95 13 This manual is for FFTW
cannam@95 14 (version 3.3.3, 25 November 2012).
cannam@95 15
cannam@95 16 Copyright (C) 2003 Matteo Frigo.
cannam@95 17
cannam@95 18 Copyright (C) 2003 Massachusetts Institute of Technology.
cannam@95 19
cannam@95 20 Permission is granted to make and distribute verbatim copies of
cannam@95 21 this manual provided the copyright notice and this permission
cannam@95 22 notice are preserved on all copies.
cannam@95 23
cannam@95 24 Permission is granted to copy and distribute modified versions of
cannam@95 25 this manual under the conditions for verbatim copying, provided
cannam@95 26 that the entire resulting derived work is distributed under the
cannam@95 27 terms of a permission notice identical to this one.
cannam@95 28
cannam@95 29 Permission is granted to copy and distribute translations of this
cannam@95 30 manual into another language, under the above conditions for
cannam@95 31 modified versions, except that this permission notice may be
cannam@95 32 stated in a translation approved by the Free Software Foundation.
cannam@95 33 -->
cannam@95 34 <meta http-equiv="Content-Style-Type" content="text/css">
cannam@95 35 <style type="text/css"><!--
cannam@95 36 pre.display { font-family:inherit }
cannam@95 37 pre.format { font-family:inherit }
cannam@95 38 pre.smalldisplay { font-family:inherit; font-size:smaller }
cannam@95 39 pre.smallformat { font-family:inherit; font-size:smaller }
cannam@95 40 pre.smallexample { font-size:smaller }
cannam@95 41 pre.smalllisp { font-size:smaller }
cannam@95 42 span.sc { font-variant:small-caps }
cannam@95 43 span.roman { font-family:serif; font-weight:normal; }
cannam@95 44 span.sansserif { font-family:sans-serif; font-weight:normal; }
cannam@95 45 --></style>
cannam@95 46 </head>
cannam@95 47 <body>
cannam@95 48 <div class="node">
cannam@95 49 <a name="Multi-dimensional-MPI-DFTs-of-Real-Data"></a>
cannam@95 50 <a name="Multi_002ddimensional-MPI-DFTs-of-Real-Data"></a>
cannam@95 51 <p>
cannam@95 52 Next:&nbsp;<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>,
cannam@95 53 Previous:&nbsp;<a rel="previous" accesskey="p" href="MPI-Data-Distribution.html#MPI-Data-Distribution">MPI Data Distribution</a>,
cannam@95 54 Up:&nbsp;<a rel="up" accesskey="u" href="Distributed_002dmemory-FFTW-with-MPI.html#Distributed_002dmemory-FFTW-with-MPI">Distributed-memory FFTW with MPI</a>
cannam@95 55 <hr>
cannam@95 56 </div>
cannam@95 57
cannam@95 58 <h3 class="section">6.5 Multi-dimensional MPI DFTs of Real Data</h3>
cannam@95 59
cannam@95 60 <p>FFTW's MPI interface also supports multi-dimensional DFTs of real
cannam@95 61 data, similar to the serial r2c and c2r interfaces. (Parallel
cannam@95 62 one-dimensional real-data DFTs are not currently supported; you must
cannam@95 63 use a complex transform and set the imaginary parts of the inputs to
cannam@95 64 zero.)
cannam@95 65
cannam@95 66 <p>The key points to understand for r2c and c2r MPI transforms (compared
cannam@95 67 to the MPI complex DFTs or the serial r2c/c2r transforms), are:
cannam@95 68
cannam@95 69 <ul>
cannam@95 70 <li>Just as for serial transforms, r2c/c2r DFTs transform n<sub>0</sub>&nbsp;&times;&nbsp;n<sub>1</sub>&nbsp;&times;&nbsp;n<sub>2</sub>&nbsp;&times;&nbsp;&hellip;&nbsp;&times;&nbsp;n<sub>d-1</sub> real
cannam@95 71 data to/from n<sub>0</sub>&nbsp;&times;&nbsp;n<sub>1</sub>&nbsp;&times;&nbsp;n<sub>2</sub>&nbsp;&times;&nbsp;&hellip;&nbsp;&times;&nbsp;(n<sub>d-1</sub>/2 + 1) complex data: the last dimension of the
cannam@95 72 complex data is cut in half (rounded down), plus one. As for the
cannam@95 73 serial transforms, the sizes you pass to the &lsquo;<samp><span class="samp">plan_dft_r2c</span></samp>&rsquo; and
cannam@95 74 &lsquo;<samp><span class="samp">plan_dft_c2r</span></samp>&rsquo; are the n<sub>0</sub>&nbsp;&times;&nbsp;n<sub>1</sub>&nbsp;&times;&nbsp;n<sub>2</sub>&nbsp;&times;&nbsp;&hellip;&nbsp;&times;&nbsp;n<sub>d-1</sub> dimensions of the real data.
cannam@95 75
cannam@95 76 <li><a name="index-padding-386"></a>Although the real data is <em>conceptually</em> n<sub>0</sub>&nbsp;&times;&nbsp;n<sub>1</sub>&nbsp;&times;&nbsp;n<sub>2</sub>&nbsp;&times;&nbsp;&hellip;&nbsp;&times;&nbsp;n<sub>d-1</sub>, it is
cannam@95 77 <em>physically</em> stored as an n<sub>0</sub>&nbsp;&times;&nbsp;n<sub>1</sub>&nbsp;&times;&nbsp;n<sub>2</sub>&nbsp;&times;&nbsp;&hellip;&nbsp;&times;&nbsp;[2&nbsp;(n<sub>d-1</sub>/2 + 1)] array, where the last
cannam@95 78 dimension has been <em>padded</em> to make it the same size as the
cannam@95 79 complex output. This is much like the in-place serial r2c/c2r
cannam@95 80 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
cannam@95 81 in MPI the padding is required even for out-of-place data. The extra
cannam@95 82 padding numbers are ignored by FFTW (they are <em>not</em> like
cannam@95 83 zero-padding the transform to a larger size); they are only used to
cannam@95 84 determine the data layout.
cannam@95 85
cannam@95 86 <li><a name="index-data-distribution-387"></a>The data distribution in MPI for <em>both</em> the real and complex data
cannam@95 87 is determined by the shape of the <em>complex</em> data. That is, you
cannam@95 88 call the appropriate &lsquo;<samp><span class="samp">local size</span></samp>&rsquo; function for the n<sub>0</sub>&nbsp;&times;&nbsp;n<sub>1</sub>&nbsp;&times;&nbsp;n<sub>2</sub>&nbsp;&times;&nbsp;&hellip;&nbsp;&times;&nbsp;(n<sub>d-1</sub>/2 + 1)
cannam@95 89
cannam@95 90 <p>complex data, and then use the <em>same</em> distribution for the real
cannam@95 91 data except that the last complex dimension is replaced by a (padded)
cannam@95 92 real dimension of twice the length.
cannam@95 93
cannam@95 94 </ul>
cannam@95 95
cannam@95 96 <p>For example suppose we are performing an out-of-place r2c transform of
cannam@95 97 L&nbsp;&times;&nbsp;M&nbsp;&times;&nbsp;N real data [padded to L&nbsp;&times;&nbsp;M&nbsp;&times;&nbsp;2(N/2+1)],
cannam@95 98 resulting in L&nbsp;&times;&nbsp;M&nbsp;&times;&nbsp;N/2+1 complex data. Similar to the
cannam@95 99 example in <a href="2d-MPI-example.html#g_t2d-MPI-example">2d MPI example</a>, we might do something like:
cannam@95 100
cannam@95 101 <pre class="example"> #include &lt;fftw3-mpi.h&gt;
cannam@95 102
cannam@95 103 int main(int argc, char **argv)
cannam@95 104 {
cannam@95 105 const ptrdiff_t L = ..., M = ..., N = ...;
cannam@95 106 fftw_plan plan;
cannam@95 107 double *rin;
cannam@95 108 fftw_complex *cout;
cannam@95 109 ptrdiff_t alloc_local, local_n0, local_0_start, i, j, k;
cannam@95 110
cannam@95 111 MPI_Init(&amp;argc, &amp;argv);
cannam@95 112 fftw_mpi_init();
cannam@95 113
cannam@95 114 /* <span class="roman">get local data size and allocate</span> */
cannam@95 115 alloc_local = fftw_mpi_local_size_3d(L, M, N/2+1, MPI_COMM_WORLD,
cannam@95 116 &amp;local_n0, &amp;local_0_start);
cannam@95 117 rin = fftw_alloc_real(2 * alloc_local);
cannam@95 118 cout = fftw_alloc_complex(alloc_local);
cannam@95 119
cannam@95 120 /* <span class="roman">create plan for out-of-place r2c DFT</span> */
cannam@95 121 plan = fftw_mpi_plan_dft_r2c_3d(L, M, N, rin, cout, MPI_COMM_WORLD,
cannam@95 122 FFTW_MEASURE);
cannam@95 123
cannam@95 124 /* <span class="roman">initialize rin to some function</span> my_func(x,y,z) */
cannam@95 125 for (i = 0; i &lt; local_n0; ++i)
cannam@95 126 for (j = 0; j &lt; M; ++j)
cannam@95 127 for (k = 0; k &lt; N; ++k)
cannam@95 128 rin[(i*M + j) * (2*(N/2+1)) + k] = my_func(local_0_start+i, j, k);
cannam@95 129
cannam@95 130 /* <span class="roman">compute transforms as many times as desired</span> */
cannam@95 131 fftw_execute(plan);
cannam@95 132
cannam@95 133 fftw_destroy_plan(plan);
cannam@95 134
cannam@95 135 MPI_Finalize();
cannam@95 136 }
cannam@95 137 </pre>
cannam@95 138 <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
cannam@95 139 argument of <code>2 * alloc_local</code>: since <code>alloc_local</code> is the
cannam@95 140 number of <em>complex</em> values to allocate, the number of <em>real</em>
cannam@95 141 values is twice as many. The <code>rin</code> array is then
cannam@95 142 local_n0&nbsp;&times;&nbsp;M&nbsp;&times;&nbsp;2(N/2+1) in row-major order, so its
cannam@95 143 <code>(i,j,k)</code> element is at the index <code>(i*M + j) * (2*(N/2+1)) +
cannam@95 144 k</code> (see <a href="Multi_002ddimensional-Array-Format.html#Multi_002ddimensional-Array-Format">Multi-dimensional Array Format</a>).
cannam@95 145
cannam@95 146 <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
cannam@95 147 specifying that the output is the transpose of the input or vice versa
cannam@95 148 (see <a href="Transposed-distributions.html#Transposed-distributions">Transposed distributions</a>). In our L&nbsp;&times;&nbsp;M&nbsp;&times;&nbsp;N r2c
cannam@95 149 example, including <code>FFTW_TRANSPOSED_OUT</code> in the flags means that
cannam@95 150 the input would be a padded L&nbsp;&times;&nbsp;M&nbsp;&times;&nbsp;2(N/2+1) real array
cannam@95 151 distributed over the <code>L</code> dimension, while the output would be a
cannam@95 152 M&nbsp;&times;&nbsp;L&nbsp;&times;&nbsp;N/2+1 complex array distributed over the <code>M</code>
cannam@95 153 dimension. To perform the inverse c2r transform with the same data
cannam@95 154 distributions, you would use the <code>FFTW_TRANSPOSED_IN</code> flag.
cannam@95 155
cannam@95 156 <!-- -->
cannam@95 157 </body></html>
cannam@95 158