| cannam@167 | 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | 
| cannam@167 | 2 <html> | 
| cannam@167 | 3 <!-- This manual is for FFTW | 
| cannam@167 | 4 (version 3.3.8, 24 May 2018). | 
| cannam@167 | 5 | 
| cannam@167 | 6 Copyright (C) 2003 Matteo Frigo. | 
| cannam@167 | 7 | 
| cannam@167 | 8 Copyright (C) 2003 Massachusetts Institute of Technology. | 
| cannam@167 | 9 | 
| cannam@167 | 10 Permission is granted to make and distribute verbatim copies of this | 
| cannam@167 | 11 manual provided the copyright notice and this permission notice are | 
| cannam@167 | 12 preserved on all copies. | 
| cannam@167 | 13 | 
| cannam@167 | 14 Permission is granted to copy and distribute modified versions of this | 
| cannam@167 | 15 manual under the conditions for verbatim copying, provided that the | 
| cannam@167 | 16 entire resulting derived work is distributed under the terms of a | 
| cannam@167 | 17 permission notice identical to this one. | 
| cannam@167 | 18 | 
| cannam@167 | 19 Permission is granted to copy and distribute translations of this manual | 
| cannam@167 | 20 into another language, under the above conditions for modified versions, | 
| cannam@167 | 21 except that this permission notice may be stated in a translation | 
| cannam@167 | 22 approved by the Free Software Foundation. --> | 
| cannam@167 | 23 <!-- Created by GNU Texinfo 6.3, http://www.gnu.org/software/texinfo/ --> | 
| cannam@167 | 24 <head> | 
| cannam@167 | 25 <title>FFTW 3.3.8: Transposed distributions</title> | 
| cannam@167 | 26 | 
| cannam@167 | 27 <meta name="description" content="FFTW 3.3.8: Transposed distributions"> | 
| cannam@167 | 28 <meta name="keywords" content="FFTW 3.3.8: Transposed distributions"> | 
| cannam@167 | 29 <meta name="resource-type" content="document"> | 
| cannam@167 | 30 <meta name="distribution" content="global"> | 
| cannam@167 | 31 <meta name="Generator" content="makeinfo"> | 
| cannam@167 | 32 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | 
| cannam@167 | 33 <link href="index.html#Top" rel="start" title="Top"> | 
| cannam@167 | 34 <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index"> | 
| cannam@167 | 35 <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> | 
| cannam@167 | 36 <link href="MPI-Data-Distribution.html#MPI-Data-Distribution" rel="up" title="MPI Data Distribution"> | 
| cannam@167 | 37 <link href="One_002ddimensional-distributions.html#One_002ddimensional-distributions" rel="next" title="One-dimensional distributions"> | 
| cannam@167 | 38 <link href="Load-balancing.html#Load-balancing" rel="prev" title="Load balancing"> | 
| cannam@167 | 39 <style type="text/css"> | 
| cannam@167 | 40 <!-- | 
| cannam@167 | 41 a.summary-letter {text-decoration: none} | 
| cannam@167 | 42 blockquote.indentedblock {margin-right: 0em} | 
| cannam@167 | 43 blockquote.smallindentedblock {margin-right: 0em; font-size: smaller} | 
| cannam@167 | 44 blockquote.smallquotation {font-size: smaller} | 
| cannam@167 | 45 div.display {margin-left: 3.2em} | 
| cannam@167 | 46 div.example {margin-left: 3.2em} | 
| cannam@167 | 47 div.lisp {margin-left: 3.2em} | 
| cannam@167 | 48 div.smalldisplay {margin-left: 3.2em} | 
| cannam@167 | 49 div.smallexample {margin-left: 3.2em} | 
| cannam@167 | 50 div.smalllisp {margin-left: 3.2em} | 
| cannam@167 | 51 kbd {font-style: oblique} | 
| cannam@167 | 52 pre.display {font-family: inherit} | 
| cannam@167 | 53 pre.format {font-family: inherit} | 
| cannam@167 | 54 pre.menu-comment {font-family: serif} | 
| cannam@167 | 55 pre.menu-preformatted {font-family: serif} | 
| cannam@167 | 56 pre.smalldisplay {font-family: inherit; font-size: smaller} | 
| cannam@167 | 57 pre.smallexample {font-size: smaller} | 
| cannam@167 | 58 pre.smallformat {font-family: inherit; font-size: smaller} | 
| cannam@167 | 59 pre.smalllisp {font-size: smaller} | 
| cannam@167 | 60 span.nolinebreak {white-space: nowrap} | 
| cannam@167 | 61 span.roman {font-family: initial; font-weight: normal} | 
| cannam@167 | 62 span.sansserif {font-family: sans-serif; font-weight: normal} | 
| cannam@167 | 63 ul.no-bullet {list-style: none} | 
| cannam@167 | 64 --> | 
| cannam@167 | 65 </style> | 
| cannam@167 | 66 | 
| cannam@167 | 67 | 
| cannam@167 | 68 </head> | 
| cannam@167 | 69 | 
| cannam@167 | 70 <body lang="en"> | 
| cannam@167 | 71 <a name="Transposed-distributions"></a> | 
| cannam@167 | 72 <div class="header"> | 
| cannam@167 | 73 <p> | 
| cannam@167 | 74 Next: <a href="One_002ddimensional-distributions.html#One_002ddimensional-distributions" accesskey="n" rel="next">One-dimensional distributions</a>, Previous: <a href="Load-balancing.html#Load-balancing" accesskey="p" rel="prev">Load balancing</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> | 
| cannam@167 | 75 </div> | 
| cannam@167 | 76 <hr> | 
| cannam@167 | 77 <a name="Transposed-distributions-1"></a> | 
| cannam@167 | 78 <h4 class="subsection">6.4.3 Transposed distributions</h4> | 
| cannam@167 | 79 | 
| cannam@167 | 80 <p>Internally, FFTW’s MPI transform algorithms work by first computing | 
| cannam@167 | 81 transforms of the data local to each process, then by globally | 
| cannam@167 | 82 <em>transposing</em> the data in some fashion to redistribute the data | 
| cannam@167 | 83 among the processes, transforming the new data local to each process, | 
| cannam@167 | 84 and transposing back.  For example, a two-dimensional <code>n0</code> by | 
| cannam@167 | 85 <code>n1</code> array, distributed across the <code>n0</code> dimension, is | 
| cannam@167 | 86 transformd by: (i) transforming the <code>n1</code> dimension, which are | 
| cannam@167 | 87 local to each process; (ii) transposing to an <code>n1</code> by <code>n0</code> | 
| cannam@167 | 88 array, distributed across the <code>n1</code> dimension; (iii) transforming | 
| cannam@167 | 89 the <code>n0</code> dimension, which is now local to each process; (iv) | 
| cannam@167 | 90 transposing back. | 
| cannam@167 | 91 <a name="index-transpose"></a> | 
| cannam@167 | 92 </p> | 
| cannam@167 | 93 | 
| cannam@167 | 94 <p>However, in many applications it is acceptable to compute a | 
| cannam@167 | 95 multidimensional DFT whose results are produced in transposed order | 
| cannam@167 | 96 (e.g., <code>n1</code> by <code>n0</code> in two dimensions).  This provides a | 
| cannam@167 | 97 significant performance advantage, because it means that the final | 
| cannam@167 | 98 transposition step can be omitted.  FFTW supports this optimization, | 
| cannam@167 | 99 which you specify by passing the flag <code>FFTW_MPI_TRANSPOSED_OUT</code> | 
| cannam@167 | 100 to the planner routines.  To compute the inverse transform of | 
| cannam@167 | 101 transposed output, you specify <code>FFTW_MPI_TRANSPOSED_IN</code> to tell | 
| cannam@167 | 102 it that the input is transposed.  In this section, we explain how to | 
| cannam@167 | 103 interpret the output format of such a transform. | 
| cannam@167 | 104 <a name="index-FFTW_005fMPI_005fTRANSPOSED_005fOUT"></a> | 
| cannam@167 | 105 <a name="index-FFTW_005fMPI_005fTRANSPOSED_005fIN"></a> | 
| cannam@167 | 106 </p> | 
| cannam@167 | 107 | 
| cannam@167 | 108 <p>Suppose you have are transforming multi-dimensional data with (at | 
| cannam@167 | 109 least two) dimensions n<sub>0</sub> × n<sub>1</sub> × n<sub>2</sub> × … × n<sub>d-1</sub> | 
| cannam@167 | 110 .  As always, it is distributed along | 
| cannam@167 | 111 the first dimension n<sub>0</sub> | 
| cannam@167 | 112 .  Now, if we compute its DFT with the | 
| cannam@167 | 113 <code>FFTW_MPI_TRANSPOSED_OUT</code> flag, the resulting output data are stored | 
| cannam@167 | 114 with the first <em>two</em> dimensions transposed: n<sub>1</sub> × n<sub>0</sub> × n<sub>2</sub> ×…× n<sub>d-1</sub> | 
| cannam@167 | 115 , | 
| cannam@167 | 116 distributed along the n<sub>1</sub> | 
| cannam@167 | 117  dimension.  Conversely, if we take the | 
| cannam@167 | 118 n<sub>1</sub> × n<sub>0</sub> × n<sub>2</sub> ×…× n<sub>d-1</sub> | 
| cannam@167 | 119  data and transform it with the | 
| cannam@167 | 120 <code>FFTW_MPI_TRANSPOSED_IN</code> flag, then the format goes back to the | 
| cannam@167 | 121 original n<sub>0</sub> × n<sub>1</sub> × n<sub>2</sub> × … × n<sub>d-1</sub> | 
| cannam@167 | 122  array. | 
| cannam@167 | 123 </p> | 
| cannam@167 | 124 <p>There are two ways to find the portion of the transposed array that | 
| cannam@167 | 125 resides on the current process.  First, you can simply call the | 
| cannam@167 | 126 appropriate ‘<samp>local_size</samp>’ function, passing n<sub>1</sub> × n<sub>0</sub> × n<sub>2</sub> ×…× n<sub>d-1</sub> | 
| cannam@167 | 127  (the | 
| cannam@167 | 128 transposed dimensions).  This would mean calling the ‘<samp>local_size</samp>’ | 
| cannam@167 | 129 function twice, once for the transposed and once for the | 
| cannam@167 | 130 non-transposed dimensions.  Alternatively, you can call one of the | 
| cannam@167 | 131 ‘<samp>local_size_transposed</samp>’ functions, which returns both the | 
| cannam@167 | 132 non-transposed and transposed data distribution from a single call. | 
| cannam@167 | 133 For example, for a 3d transform with transposed output (or input), you | 
| cannam@167 | 134 might call: | 
| cannam@167 | 135 </p> | 
| cannam@167 | 136 <div class="example"> | 
| cannam@167 | 137 <pre class="example">ptrdiff_t fftw_mpi_local_size_3d_transposed( | 
| cannam@167 | 138                 ptrdiff_t n0, ptrdiff_t n1, ptrdiff_t n2, MPI_Comm comm, | 
| cannam@167 | 139                 ptrdiff_t *local_n0, ptrdiff_t *local_0_start, | 
| cannam@167 | 140                 ptrdiff_t *local_n1, ptrdiff_t *local_1_start); | 
| cannam@167 | 141 </pre></div> | 
| cannam@167 | 142 <a name="index-fftw_005fmpi_005flocal_005fsize_005f3d_005ftransposed"></a> | 
| cannam@167 | 143 | 
| cannam@167 | 144 <p>Here, <code>local_n0</code> and <code>local_0_start</code> give the size and | 
| cannam@167 | 145 starting index of the <code>n0</code> dimension for the | 
| cannam@167 | 146 <em>non</em>-transposed data, as in the previous sections.  For | 
| cannam@167 | 147 <em>transposed</em> data (e.g. the output for | 
| cannam@167 | 148 <code>FFTW_MPI_TRANSPOSED_OUT</code>), <code>local_n1</code> and | 
| cannam@167 | 149 <code>local_1_start</code> give the size and starting index of the <code>n1</code> | 
| cannam@167 | 150 dimension, which is the first dimension of the transposed data | 
| cannam@167 | 151 (<code>n1</code> by <code>n0</code> by <code>n2</code>). | 
| cannam@167 | 152 </p> | 
| cannam@167 | 153 <p>(Note that <code>FFTW_MPI_TRANSPOSED_IN</code> is completely equivalent to | 
| cannam@167 | 154 performing <code>FFTW_MPI_TRANSPOSED_OUT</code> and passing the first two | 
| cannam@167 | 155 dimensions to the planner in reverse order, or vice versa.  If you | 
| cannam@167 | 156 pass <em>both</em> the <code>FFTW_MPI_TRANSPOSED_IN</code> and | 
| cannam@167 | 157 <code>FFTW_MPI_TRANSPOSED_OUT</code> flags, it is equivalent to swapping the | 
| cannam@167 | 158 first two dimensions passed to the planner and passing <em>neither</em> | 
| cannam@167 | 159 flag.) | 
| cannam@167 | 160 </p> | 
| cannam@167 | 161 <hr> | 
| cannam@167 | 162 <div class="header"> | 
| cannam@167 | 163 <p> | 
| cannam@167 | 164 Next: <a href="One_002ddimensional-distributions.html#One_002ddimensional-distributions" accesskey="n" rel="next">One-dimensional distributions</a>, Previous: <a href="Load-balancing.html#Load-balancing" accesskey="p" rel="prev">Load balancing</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> | 
| cannam@167 | 165 </div> | 
| cannam@167 | 166 | 
| cannam@167 | 167 | 
| cannam@167 | 168 | 
| cannam@167 | 169 </body> | 
| cannam@167 | 170 </html> |