annotate src/fftw-3.3.5/doc/html/Basic-and-advanced-distribution-interfaces.html @ 42:2cd0e3b3e1fd

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