Mercurial > hg > sv-dependency-builds
view 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 |
line wrap: on
line source
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <!-- This manual is for FFTW (version 3.3.5, 30 July 2016). Copyright (C) 2003 Matteo Frigo. Copyright (C) 2003 Massachusetts Institute of Technology. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Free Software Foundation. --> <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ --> <head> <title>FFTW 3.3.5: Basic and advanced distribution interfaces</title> <meta name="description" content="FFTW 3.3.5: Basic and advanced distribution interfaces"> <meta name="keywords" content="FFTW 3.3.5: Basic and advanced distribution interfaces"> <meta name="resource-type" content="document"> <meta name="distribution" content="global"> <meta name="Generator" content="makeinfo"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link href="index.html#Top" rel="start" title="Top"> <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index"> <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> <link href="MPI-Data-Distribution.html#MPI-Data-Distribution" rel="up" title="MPI Data Distribution"> <link href="Load-balancing.html#Load-balancing" rel="next" title="Load balancing"> <link href="MPI-Data-Distribution.html#MPI-Data-Distribution" rel="prev" title="MPI Data Distribution"> <style type="text/css"> <!-- a.summary-letter {text-decoration: none} blockquote.smallquotation {font-size: smaller} div.display {margin-left: 3.2em} div.example {margin-left: 3.2em} div.indentedblock {margin-left: 3.2em} div.lisp {margin-left: 3.2em} div.smalldisplay {margin-left: 3.2em} div.smallexample {margin-left: 3.2em} div.smallindentedblock {margin-left: 3.2em; font-size: smaller} div.smalllisp {margin-left: 3.2em} kbd {font-style:oblique} pre.display {font-family: inherit} pre.format {font-family: inherit} pre.menu-comment {font-family: serif} pre.menu-preformatted {font-family: serif} pre.smalldisplay {font-family: inherit; font-size: smaller} pre.smallexample {font-size: smaller} pre.smallformat {font-family: inherit; font-size: smaller} pre.smalllisp {font-size: smaller} span.nocodebreak {white-space:nowrap} span.nolinebreak {white-space:nowrap} span.roman {font-family:serif; font-weight:normal} span.sansserif {font-family:sans-serif; font-weight:normal} ul.no-bullet {list-style: none} --> </style> </head> <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> <a name="Basic-and-advanced-distribution-interfaces"></a> <div class="header"> <p> 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> [<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> </div> <hr> <a name="Basic-and-advanced-distribution-interfaces-1"></a> <h4 class="subsection">6.4.1 Basic and advanced distribution interfaces</h4> <p>As with the planner interface, the ‘<samp>fftw_mpi_local_size</samp>’ distribution interface is broken into basic and advanced (‘<samp>_many</samp>’) interfaces, where the latter allows you to specify the block size manually and also to request block sizes when computing multiple transforms simultaneously. These functions are documented more exhaustively by the FFTW MPI Reference, but we summarize the basic ideas here using a couple of two-dimensional examples. </p> <p>For the 100 × 200 complex-DFT example, above, we would find the distribution by calling the following function in the basic interface: </p> <div class="example"> <pre class="example">ptrdiff_t fftw_mpi_local_size_2d(ptrdiff_t n0, ptrdiff_t n1, MPI_Comm comm, ptrdiff_t *local_n0, ptrdiff_t *local_0_start); </pre></div> <a name="index-fftw_005fmpi_005flocal_005fsize_005f2d-1"></a> <p>Given the total size of the data to be transformed (here, <code>n0 = 100</code> and <code>n1 = 200</code>) and an MPI communicator (<code>comm</code>), this function provides three numbers. </p> <p>First, it describes the shape of the local data: the current process should store a <code>local_n0</code> by <code>n1</code> slice of the overall dataset, in row-major order (<code>n1</code> dimension contiguous), starting at index <code>local_0_start</code>. That is, if the total dataset is viewed as a <code>n0</code> by <code>n1</code> matrix, the current process should store the rows <code>local_0_start</code> to <code>local_0_start+local_n0-1</code>. Obviously, if you are running with only a single MPI process, that process will store the entire array: <code>local_0_start</code> will be zero and <code>local_n0</code> will be <code>n0</code>. See <a href="Row_002dmajor-Format.html#Row_002dmajor-Format">Row-major Format</a>. <a name="index-row_002dmajor-4"></a> </p> <p>Second, the return value is the total number of data elements (e.g., complex numbers for a complex DFT) that should be allocated for the input and output arrays on the current process (ideally with <code>fftw_malloc</code> or an ‘<samp>fftw_alloc</samp>’ function, to ensure optimal alignment). It might seem that this should always be equal to <code>local_n0 * n1</code>, but this is <em>not</em> the case. FFTW’s distributed FFT algorithms require data redistributions at intermediate stages of the transform, and in some circumstances this may require slightly larger local storage. This is discussed in more detail below, under <a href="Load-balancing.html#Load-balancing">Load balancing</a>. <a name="index-fftw_005fmalloc-5"></a> <a name="index-fftw_005falloc_005fcomplex-3"></a> </p> <a name="index-advanced-interface-4"></a> <p>The advanced-interface ‘<samp>local_size</samp>’ function for multidimensional transforms returns the same three things (<code>local_n0</code>, <code>local_0_start</code>, and the total number of elements to allocate), but takes more inputs: </p> <div class="example"> <pre class="example">ptrdiff_t fftw_mpi_local_size_many(int rnk, const ptrdiff_t *n, ptrdiff_t howmany, ptrdiff_t block0, MPI_Comm comm, ptrdiff_t *local_n0, ptrdiff_t *local_0_start); </pre></div> <a name="index-fftw_005fmpi_005flocal_005fsize_005fmany"></a> <p>The two-dimensional case above corresponds to <code>rnk = 2</code> and an array <code>n</code> of length 2 with <code>n[0] = n0</code> and <code>n[1] = n1</code>. This routine is for any <code>rnk > 1</code>; one-dimensional transforms have their own interface because they work slightly differently, as discussed below. </p> <p>First, the advanced interface allows you to perform multiple transforms at once, of interleaved data, as specified by the <code>howmany</code> parameter. (<code>hoamany</code> is 1 for a single transform.) </p> <p>Second, here you can specify your desired block size in the <code>n0</code> dimension, <code>block0</code>. To use FFTW’s default block size, pass <code>FFTW_MPI_DEFAULT_BLOCK</code> (0) for <code>block0</code>. Otherwise, on <code>P</code> processes, FFTW will return <code>local_n0</code> equal to <code>block0</code> on the first <code>P / block0</code> processes (rounded down), return <code>local_n0</code> equal to <code>n0 - block0 * (P / block0)</code> on the next process, and <code>local_n0</code> equal to zero on any remaining processes. In general, we recommend using the default block size (which corresponds to <code>n0 / P</code>, rounded up). <a name="index-FFTW_005fMPI_005fDEFAULT_005fBLOCK"></a> <a name="index-block-distribution-1"></a> </p> <p>For example, suppose you have <code>P = 4</code> processes and <code>n0 = 21</code>. The default will be a block size of <code>6</code>, which will give <code>local_n0 = 6</code> on the first three processes and <code>local_n0 = 3</code> on the last process. Instead, however, you could specify <code>block0 = 5</code> if you wanted, which would give <code>local_n0 = 5</code> on processes 0 to 2, <code>local_n0 = 6</code> on process 3. (This choice, while it may look superficially more “balanced,” has the same critical path as FFTW’s default but requires more communications.) </p> <hr> <div class="header"> <p> 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> [<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> </div> </body> </html>