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