cannam@95
|
1 <html lang="en">
|
cannam@95
|
2 <head>
|
cannam@95
|
3 <title>Basic and advanced distribution interfaces - 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="MPI-Data-Distribution.html#MPI-Data-Distribution" title="MPI Data Distribution">
|
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="Load-balancing.html#Load-balancing" title="Load balancing">
|
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="Basic-and-advanced-distribution-interfaces"></a>
|
cannam@95
|
50 <p>
|
cannam@95
|
51 Next: <a rel="next" accesskey="n" href="Load-balancing.html#Load-balancing">Load balancing</a>,
|
cannam@95
|
52 Previous: <a rel="previous" accesskey="p" href="MPI-Data-Distribution.html#MPI-Data-Distribution">MPI Data Distribution</a>,
|
cannam@95
|
53 Up: <a rel="up" accesskey="u" href="MPI-Data-Distribution.html#MPI-Data-Distribution">MPI Data Distribution</a>
|
cannam@95
|
54 <hr>
|
cannam@95
|
55 </div>
|
cannam@95
|
56
|
cannam@95
|
57 <h4 class="subsection">6.4.1 Basic and advanced distribution interfaces</h4>
|
cannam@95
|
58
|
cannam@95
|
59 <p>As with the planner interface, the ‘<samp><span class="samp">fftw_mpi_local_size</span></samp>’
|
cannam@95
|
60 distribution interface is broken into basic and advanced
|
cannam@95
|
61 (‘<samp><span class="samp">_many</span></samp>’) interfaces, where the latter allows you to specify the
|
cannam@95
|
62 block size manually and also to request block sizes when computing
|
cannam@95
|
63 multiple transforms simultaneously. These functions are documented
|
cannam@95
|
64 more exhaustively by the FFTW MPI Reference, but we summarize the
|
cannam@95
|
65 basic ideas here using a couple of two-dimensional examples.
|
cannam@95
|
66
|
cannam@95
|
67 <p>For the 100 × 200 complex-DFT example, above, we would find
|
cannam@95
|
68 the distribution by calling the following function in the basic
|
cannam@95
|
69 interface:
|
cannam@95
|
70
|
cannam@95
|
71 <pre class="example"> ptrdiff_t fftw_mpi_local_size_2d(ptrdiff_t n0, ptrdiff_t n1, MPI_Comm comm,
|
cannam@95
|
72 ptrdiff_t *local_n0, ptrdiff_t *local_0_start);
|
cannam@95
|
73 </pre>
|
cannam@95
|
74 <p><a name="index-fftw_005fmpi_005flocal_005fsize_005f2d-370"></a>
|
cannam@95
|
75 Given the total size of the data to be transformed (here, <code>n0 =
|
cannam@95
|
76 100</code> and <code>n1 = 200</code>) and an MPI communicator (<code>comm</code>), this
|
cannam@95
|
77 function provides three numbers.
|
cannam@95
|
78
|
cannam@95
|
79 <p>First, it describes the shape of the local data: the current process
|
cannam@95
|
80 should store a <code>local_n0</code> by <code>n1</code> slice of the overall
|
cannam@95
|
81 dataset, in row-major order (<code>n1</code> dimension contiguous), starting
|
cannam@95
|
82 at index <code>local_0_start</code>. That is, if the total dataset is
|
cannam@95
|
83 viewed as a <code>n0</code> by <code>n1</code> matrix, the current process should
|
cannam@95
|
84 store the rows <code>local_0_start</code> to
|
cannam@95
|
85 <code>local_0_start+local_n0-1</code>. Obviously, if you are running with
|
cannam@95
|
86 only a single MPI process, that process will store the entire array:
|
cannam@95
|
87 <code>local_0_start</code> will be zero and <code>local_n0</code> will be
|
cannam@95
|
88 <code>n0</code>. See <a href="Row_002dmajor-Format.html#Row_002dmajor-Format">Row-major Format</a>.
|
cannam@95
|
89 <a name="index-row_002dmajor-371"></a>
|
cannam@95
|
90
|
cannam@95
|
91 <p>Second, the return value is the total number of data elements (e.g.,
|
cannam@95
|
92 complex numbers for a complex DFT) that should be allocated for the
|
cannam@95
|
93 input and output arrays on the current process (ideally with
|
cannam@95
|
94 <code>fftw_malloc</code> or an ‘<samp><span class="samp">fftw_alloc</span></samp>’ function, to ensure optimal
|
cannam@95
|
95 alignment). It might seem that this should always be equal to
|
cannam@95
|
96 <code>local_n0 * n1</code>, but this is <em>not</em> the case. FFTW's
|
cannam@95
|
97 distributed FFT algorithms require data redistributions at
|
cannam@95
|
98 intermediate stages of the transform, and in some circumstances this
|
cannam@95
|
99 may require slightly larger local storage. This is discussed in more
|
cannam@95
|
100 detail below, under <a href="Load-balancing.html#Load-balancing">Load balancing</a>.
|
cannam@95
|
101 <a name="index-fftw_005fmalloc-372"></a><a name="index-fftw_005falloc_005fcomplex-373"></a>
|
cannam@95
|
102
|
cannam@95
|
103 <p><a name="index-advanced-interface-374"></a>The advanced-interface ‘<samp><span class="samp">local_size</span></samp>’ function for multidimensional
|
cannam@95
|
104 transforms returns the same three things (<code>local_n0</code>,
|
cannam@95
|
105 <code>local_0_start</code>, and the total number of elements to allocate),
|
cannam@95
|
106 but takes more inputs:
|
cannam@95
|
107
|
cannam@95
|
108 <pre class="example"> ptrdiff_t fftw_mpi_local_size_many(int rnk, const ptrdiff_t *n,
|
cannam@95
|
109 ptrdiff_t howmany,
|
cannam@95
|
110 ptrdiff_t block0,
|
cannam@95
|
111 MPI_Comm comm,
|
cannam@95
|
112 ptrdiff_t *local_n0,
|
cannam@95
|
113 ptrdiff_t *local_0_start);
|
cannam@95
|
114 </pre>
|
cannam@95
|
115 <p><a name="index-fftw_005fmpi_005flocal_005fsize_005fmany-375"></a>
|
cannam@95
|
116 The two-dimensional case above corresponds to <code>rnk = 2</code> and an
|
cannam@95
|
117 array <code>n</code> of length 2 with <code>n[0] = n0</code> and <code>n[1] = n1</code>.
|
cannam@95
|
118 This routine is for any <code>rnk > 1</code>; one-dimensional transforms
|
cannam@95
|
119 have their own interface because they work slightly differently, as
|
cannam@95
|
120 discussed below.
|
cannam@95
|
121
|
cannam@95
|
122 <p>First, the advanced interface allows you to perform multiple
|
cannam@95
|
123 transforms at once, of interleaved data, as specified by the
|
cannam@95
|
124 <code>howmany</code> parameter. (<code>hoamany</code> is 1 for a single
|
cannam@95
|
125 transform.)
|
cannam@95
|
126
|
cannam@95
|
127 <p>Second, here you can specify your desired block size in the <code>n0</code>
|
cannam@95
|
128 dimension, <code>block0</code>. To use FFTW's default block size, pass
|
cannam@95
|
129 <code>FFTW_MPI_DEFAULT_BLOCK</code> (0) for <code>block0</code>. Otherwise, on
|
cannam@95
|
130 <code>P</code> processes, FFTW will return <code>local_n0</code> equal to
|
cannam@95
|
131 <code>block0</code> on the first <code>P / block0</code> processes (rounded down),
|
cannam@95
|
132 return <code>local_n0</code> equal to <code>n0 - block0 * (P / block0)</code> on
|
cannam@95
|
133 the next process, and <code>local_n0</code> equal to zero on any remaining
|
cannam@95
|
134 processes. In general, we recommend using the default block size
|
cannam@95
|
135 (which corresponds to <code>n0 / P</code>, rounded up).
|
cannam@95
|
136 <a name="index-FFTW_005fMPI_005fDEFAULT_005fBLOCK-376"></a><a name="index-block-distribution-377"></a>
|
cannam@95
|
137
|
cannam@95
|
138 <p>For example, suppose you have <code>P = 4</code> processes and <code>n0 =
|
cannam@95
|
139 21</code>. The default will be a block size of <code>6</code>, which will give
|
cannam@95
|
140 <code>local_n0 = 6</code> on the first three processes and <code>local_n0 =
|
cannam@95
|
141 3</code> on the last process. Instead, however, you could specify
|
cannam@95
|
142 <code>block0 = 5</code> if you wanted, which would give <code>local_n0 = 5</code>
|
cannam@95
|
143 on processes 0 to 2, <code>local_n0 = 6</code> on process 3. (This choice,
|
cannam@95
|
144 while it may look superficially more “balanced,” has the same
|
cannam@95
|
145 critical path as FFTW's default but requires more communications.)
|
cannam@95
|
146
|
cannam@95
|
147 </body></html>
|
cannam@95
|
148
|