comparison src/fftw-3.3.8/doc/html/Multi_002ddimensional-MPI-DFTs-of-Real-Data.html @ 167:bd3cc4d1df30

Add FFTW 3.3.8 source, and a Linux build
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 19 Nov 2019 14:52:55 +0000
parents
children
comparison
equal deleted inserted replaced
166:cbd6d7e562c7 167:bd3cc4d1df30
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.8, 24 May 2018).
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 6.3, http://www.gnu.org/software/texinfo/ -->
24 <head>
25 <title>FFTW 3.3.8: Multi-dimensional MPI DFTs of Real Data</title>
26
27 <meta name="description" content="FFTW 3.3.8: Multi-dimensional MPI DFTs of Real Data">
28 <meta name="keywords" content="FFTW 3.3.8: 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.indentedblock {margin-right: 0em}
43 blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
44 blockquote.smallquotation {font-size: smaller}
45 div.display {margin-left: 3.2em}
46 div.example {margin-left: 3.2em}
47 div.lisp {margin-left: 3.2em}
48 div.smalldisplay {margin-left: 3.2em}
49 div.smallexample {margin-left: 3.2em}
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.nolinebreak {white-space: nowrap}
61 span.roman {font-family: initial; font-weight: normal}
62 span.sansserif {font-family: sans-serif; font-weight: normal}
63 ul.no-bullet {list-style: none}
64 -->
65 </style>
66
67
68 </head>
69
70 <body lang="en">
71 <a name="Multi_002ddimensional-MPI-DFTs-of-Real-Data"></a>
72 <div class="header">
73 <p>
74 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>
75 </div>
76 <hr>
77 <a name="Multi_002ddimensional-MPI-DFTs-of-Real-Data-1"></a>
78 <h3 class="section">6.5 Multi-dimensional MPI DFTs of Real Data</h3>
79
80 <p>FFTW&rsquo;s MPI interface also supports multi-dimensional DFTs of real
81 data, similar to the serial r2c and c2r interfaces. (Parallel
82 one-dimensional real-data DFTs are not currently supported; you must
83 use a complex transform and set the imaginary parts of the inputs to
84 zero.)
85 </p>
86 <p>The key points to understand for r2c and c2r MPI transforms (compared
87 to the MPI complex DFTs or the serial r2c/c2r transforms), are:
88 </p>
89 <ul>
90 <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>
91 real
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)
93 complex data: the last dimension of the
94 complex data is cut in half (rounded down), plus one. As for the
95 serial transforms, the sizes you pass to the &lsquo;<samp>plan_dft_r2c</samp>&rsquo; and
96 &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>
97 dimensions of the real data.
98
99 </li><li> <a name="index-padding-4"></a>
100 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>
101 , it is
102 <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)]
103 array, where the last
104 dimension has been <em>padded</em> to make it the same size as the
105 complex output. This is much like the in-place serial r2c/c2r
106 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
107 in MPI the padding is required even for out-of-place data. The extra
108 padding numbers are ignored by FFTW (they are <em>not</em> like
109 zero-padding the transform to a larger size); they are only used to
110 determine the data layout.
111
112 </li><li> <a name="index-data-distribution-3"></a>
113 The data distribution in MPI for <em>both</em> the real and complex data
114 is determined by the shape of the <em>complex</em> data. That is, you
115 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)
116
117 complex data, and then use the <em>same</em> distribution for the real
118 data except that the last complex dimension is replaced by a (padded)
119 real dimension of twice the length.
120
121 </li></ul>
122
123 <p>For example suppose we are performing an out-of-place r2c transform of
124 L&nbsp;&times;&nbsp;M&nbsp;&times;&nbsp;N
125 real data [padded to L&nbsp;&times;&nbsp;M&nbsp;&times;&nbsp;2(N/2+1)
126 ],
127 resulting in L&nbsp;&times;&nbsp;M&nbsp;&times;&nbsp;N/2+1
128 complex data. Similar to the
129 example in <a href="2d-MPI-example.html#g_t2d-MPI-example">2d MPI example</a>, we might do something like:
130 </p>
131 <div class="example">
132 <pre class="example">#include &lt;fftw3-mpi.h&gt;
133
134 int main(int argc, char **argv)
135 {
136 const ptrdiff_t L = ..., M = ..., N = ...;
137 fftw_plan plan;
138 double *rin;
139 fftw_complex *cout;
140 ptrdiff_t alloc_local, local_n0, local_0_start, i, j, k;
141
142 MPI_Init(&amp;argc, &amp;argv);
143 fftw_mpi_init();
144
145 /* <span class="roman">get local data size and allocate</span> */
146 alloc_local = fftw_mpi_local_size_3d(L, M, N/2+1, MPI_COMM_WORLD,
147 &amp;local_n0, &amp;local_0_start);
148 rin = fftw_alloc_real(2 * alloc_local);
149 cout = fftw_alloc_complex(alloc_local);
150
151 /* <span class="roman">create plan for out-of-place r2c DFT</span> */
152 plan = fftw_mpi_plan_dft_r2c_3d(L, M, N, rin, cout, MPI_COMM_WORLD,
153 FFTW_MEASURE);
154
155 /* <span class="roman">initialize rin to some function</span> my_func(x,y,z) */
156 for (i = 0; i &lt; local_n0; ++i)
157 for (j = 0; j &lt; M; ++j)
158 for (k = 0; k &lt; N; ++k)
159 rin[(i*M + j) * (2*(N/2+1)) + k] = my_func(local_0_start+i, j, k);
160
161 /* <span class="roman">compute transforms as many times as desired</span> */
162 fftw_execute(plan);
163
164 fftw_destroy_plan(plan);
165
166 MPI_Finalize();
167 }
168 </pre></div>
169
170 <a name="index-fftw_005falloc_005freal-2"></a>
171 <a name="index-row_002dmajor-5"></a>
172 <p>Note that we allocated <code>rin</code> using <code>fftw_alloc_real</code> with an
173 argument of <code>2 * alloc_local</code>: since <code>alloc_local</code> is the
174 number of <em>complex</em> values to allocate, the number of <em>real</em>
175 values is twice as many. The <code>rin</code> array is then
176 local_n0&nbsp;&times;&nbsp;M&nbsp;&times;&nbsp;2(N/2+1)
177 in row-major order, so its
178 <code>(i,j,k)</code> element is at the index <code>(i*M + j) * (2*(N/2+1)) +
179 k</code> (see <a href="Multi_002ddimensional-Array-Format.html#Multi_002ddimensional-Array-Format">Multi-dimensional Array Format</a>).
180 </p>
181 <a name="index-transpose-1"></a>
182 <a name="index-FFTW_005fTRANSPOSED_005fOUT"></a>
183 <a name="index-FFTW_005fTRANSPOSED_005fIN"></a>
184 <p>As for the complex transforms, improved performance can be obtained by
185 specifying that the output is the transpose of the input or vice versa
186 (see <a href="Transposed-distributions.html#Transposed-distributions">Transposed distributions</a>). In our L&nbsp;&times;&nbsp;M&nbsp;&times;&nbsp;N
187 r2c
188 example, including <code>FFTW_TRANSPOSED_OUT</code> in the flags means that
189 the input would be a padded L&nbsp;&times;&nbsp;M&nbsp;&times;&nbsp;2(N/2+1)
190 real array
191 distributed over the <code>L</code> dimension, while the output would be a
192 M&nbsp;&times;&nbsp;L&nbsp;&times;&nbsp;N/2+1
193 complex array distributed over the <code>M</code>
194 dimension. To perform the inverse c2r transform with the same data
195 distributions, you would use the <code>FFTW_TRANSPOSED_IN</code> flag.
196 </p>
197 <hr>
198 <div class="header">
199 <p>
200 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>
201 </div>
202
203
204
205 </body>
206 </html>