comparison src/fftw-3.3.5/doc/html/Basic-and-advanced-distribution-interfaces.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: Basic and advanced distribution interfaces</title>
26
27 <meta name="description" content="FFTW 3.3.5: Basic and advanced distribution interfaces">
28 <meta name="keywords" content="FFTW 3.3.5: Basic and advanced distribution interfaces">
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="MPI-Data-Distribution.html#MPI-Data-Distribution" rel="up" title="MPI Data Distribution">
37 <link href="Load-balancing.html#Load-balancing" rel="next" title="Load balancing">
38 <link href="MPI-Data-Distribution.html#MPI-Data-Distribution" rel="prev" title="MPI Data Distribution">
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="Basic-and-advanced-distribution-interfaces"></a>
73 <div class="header">
74 <p>
75 Next: <a href="Load-balancing.html#Load-balancing" accesskey="n" rel="next">Load balancing</a>, Previous: <a href="MPI-Data-Distribution.html#MPI-Data-Distribution" accesskey="p" rel="prev">MPI Data Distribution</a>, Up: <a href="MPI-Data-Distribution.html#MPI-Data-Distribution" accesskey="u" rel="up">MPI Data Distribution</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>
76 </div>
77 <hr>
78 <a name="Basic-and-advanced-distribution-interfaces-1"></a>
79 <h4 class="subsection">6.4.1 Basic and advanced distribution interfaces</h4>
80
81 <p>As with the planner interface, the &lsquo;<samp>fftw_mpi_local_size</samp>&rsquo;
82 distribution interface is broken into basic and advanced
83 (&lsquo;<samp>_many</samp>&rsquo;) interfaces, where the latter allows you to specify the
84 block size manually and also to request block sizes when computing
85 multiple transforms simultaneously. These functions are documented
86 more exhaustively by the FFTW MPI Reference, but we summarize the
87 basic ideas here using a couple of two-dimensional examples.
88 </p>
89 <p>For the 100&nbsp;&times;&nbsp;200 complex-DFT example, above, we would find
90 the distribution by calling the following function in the basic
91 interface:
92 </p>
93 <div class="example">
94 <pre class="example">ptrdiff_t fftw_mpi_local_size_2d(ptrdiff_t n0, ptrdiff_t n1, MPI_Comm comm,
95 ptrdiff_t *local_n0, ptrdiff_t *local_0_start);
96 </pre></div>
97 <a name="index-fftw_005fmpi_005flocal_005fsize_005f2d-1"></a>
98
99 <p>Given the total size of the data to be transformed (here, <code>n0 =
100 100</code> and <code>n1 = 200</code>) and an MPI communicator (<code>comm</code>), this
101 function provides three numbers.
102 </p>
103 <p>First, it describes the shape of the local data: the current process
104 should store a <code>local_n0</code> by <code>n1</code> slice of the overall
105 dataset, in row-major order (<code>n1</code> dimension contiguous), starting
106 at index <code>local_0_start</code>. That is, if the total dataset is
107 viewed as a <code>n0</code> by <code>n1</code> matrix, the current process should
108 store the rows <code>local_0_start</code> to
109 <code>local_0_start+local_n0-1</code>. Obviously, if you are running with
110 only a single MPI process, that process will store the entire array:
111 <code>local_0_start</code> will be zero and <code>local_n0</code> will be
112 <code>n0</code>. See <a href="Row_002dmajor-Format.html#Row_002dmajor-Format">Row-major Format</a>.
113 <a name="index-row_002dmajor-4"></a>
114 </p>
115
116 <p>Second, the return value is the total number of data elements (e.g.,
117 complex numbers for a complex DFT) that should be allocated for the
118 input and output arrays on the current process (ideally with
119 <code>fftw_malloc</code> or an &lsquo;<samp>fftw_alloc</samp>&rsquo; function, to ensure optimal
120 alignment). It might seem that this should always be equal to
121 <code>local_n0 * n1</code>, but this is <em>not</em> the case. FFTW&rsquo;s
122 distributed FFT algorithms require data redistributions at
123 intermediate stages of the transform, and in some circumstances this
124 may require slightly larger local storage. This is discussed in more
125 detail below, under <a href="Load-balancing.html#Load-balancing">Load balancing</a>.
126 <a name="index-fftw_005fmalloc-5"></a>
127 <a name="index-fftw_005falloc_005fcomplex-3"></a>
128 </p>
129
130 <a name="index-advanced-interface-4"></a>
131 <p>The advanced-interface &lsquo;<samp>local_size</samp>&rsquo; function for multidimensional
132 transforms returns the same three things (<code>local_n0</code>,
133 <code>local_0_start</code>, and the total number of elements to allocate),
134 but takes more inputs:
135 </p>
136 <div class="example">
137 <pre class="example">ptrdiff_t fftw_mpi_local_size_many(int rnk, const ptrdiff_t *n,
138 ptrdiff_t howmany,
139 ptrdiff_t block0,
140 MPI_Comm comm,
141 ptrdiff_t *local_n0,
142 ptrdiff_t *local_0_start);
143 </pre></div>
144 <a name="index-fftw_005fmpi_005flocal_005fsize_005fmany"></a>
145
146 <p>The two-dimensional case above corresponds to <code>rnk = 2</code> and an
147 array <code>n</code> of length 2 with <code>n[0] = n0</code> and <code>n[1] = n1</code>.
148 This routine is for any <code>rnk &gt; 1</code>; one-dimensional transforms
149 have their own interface because they work slightly differently, as
150 discussed below.
151 </p>
152 <p>First, the advanced interface allows you to perform multiple
153 transforms at once, of interleaved data, as specified by the
154 <code>howmany</code> parameter. (<code>hoamany</code> is 1 for a single
155 transform.)
156 </p>
157 <p>Second, here you can specify your desired block size in the <code>n0</code>
158 dimension, <code>block0</code>. To use FFTW&rsquo;s default block size, pass
159 <code>FFTW_MPI_DEFAULT_BLOCK</code> (0) for <code>block0</code>. Otherwise, on
160 <code>P</code> processes, FFTW will return <code>local_n0</code> equal to
161 <code>block0</code> on the first <code>P / block0</code> processes (rounded down),
162 return <code>local_n0</code> equal to <code>n0 - block0 * (P / block0)</code> on
163 the next process, and <code>local_n0</code> equal to zero on any remaining
164 processes. In general, we recommend using the default block size
165 (which corresponds to <code>n0 / P</code>, rounded up).
166 <a name="index-FFTW_005fMPI_005fDEFAULT_005fBLOCK"></a>
167 <a name="index-block-distribution-1"></a>
168 </p>
169
170 <p>For example, suppose you have <code>P = 4</code> processes and <code>n0 =
171 21</code>. The default will be a block size of <code>6</code>, which will give
172 <code>local_n0 = 6</code> on the first three processes and <code>local_n0 =
173 3</code> on the last process. Instead, however, you could specify
174 <code>block0 = 5</code> if you wanted, which would give <code>local_n0 = 5</code>
175 on processes 0 to 2, <code>local_n0 = 6</code> on process 3. (This choice,
176 while it may look superficially more &ldquo;balanced,&rdquo; has the same
177 critical path as FFTW&rsquo;s default but requires more communications.)
178 </p>
179 <hr>
180 <div class="header">
181 <p>
182 Next: <a href="Load-balancing.html#Load-balancing" accesskey="n" rel="next">Load balancing</a>, Previous: <a href="MPI-Data-Distribution.html#MPI-Data-Distribution" accesskey="p" rel="prev">MPI Data Distribution</a>, Up: <a href="MPI-Data-Distribution.html#MPI-Data-Distribution" accesskey="u" rel="up">MPI Data Distribution</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>
183 </div>
184
185
186
187 </body>
188 </html>