annotate src/fftw-3.3.5/doc/html/Multi_002ddimensional-MPI-DFTs-of-Real-Data.html @ 83:ae30d91d2ffe

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