annotate fft/fftw/fftw-3.3.4/doc/html/FFTW-MPI-Wisdom.html @ 40:223f770b5341 kissfft-double tip

Try a double-precision kissfft
author Chris Cannam
date Wed, 07 Sep 2016 10:40:32 +0100
parents 26056e866c29
children
rev   line source
Chris@19 1 <html lang="en">
Chris@19 2 <head>
Chris@19 3 <title>FFTW MPI Wisdom - FFTW 3.3.4</title>
Chris@19 4 <meta http-equiv="Content-Type" content="text/html">
Chris@19 5 <meta name="description" content="FFTW 3.3.4">
Chris@19 6 <meta name="generator" content="makeinfo 4.13">
Chris@19 7 <link title="Top" rel="start" href="index.html#Top">
Chris@19 8 <link rel="up" href="Distributed_002dmemory-FFTW-with-MPI.html#Distributed_002dmemory-FFTW-with-MPI" title="Distributed-memory FFTW with MPI">
Chris@19 9 <link rel="prev" href="FFTW-MPI-Transposes.html#FFTW-MPI-Transposes" title="FFTW MPI Transposes">
Chris@19 10 <link rel="next" href="Avoiding-MPI-Deadlocks.html#Avoiding-MPI-Deadlocks" title="Avoiding MPI Deadlocks">
Chris@19 11 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
Chris@19 12 <!--
Chris@19 13 This manual is for FFTW
Chris@19 14 (version 3.3.4, 20 September 2013).
Chris@19 15
Chris@19 16 Copyright (C) 2003 Matteo Frigo.
Chris@19 17
Chris@19 18 Copyright (C) 2003 Massachusetts Institute of Technology.
Chris@19 19
Chris@19 20 Permission is granted to make and distribute verbatim copies of
Chris@19 21 this manual provided the copyright notice and this permission
Chris@19 22 notice are preserved on all copies.
Chris@19 23
Chris@19 24 Permission is granted to copy and distribute modified versions of
Chris@19 25 this manual under the conditions for verbatim copying, provided
Chris@19 26 that the entire resulting derived work is distributed under the
Chris@19 27 terms of a permission notice identical to this one.
Chris@19 28
Chris@19 29 Permission is granted to copy and distribute translations of this
Chris@19 30 manual into another language, under the above conditions for
Chris@19 31 modified versions, except that this permission notice may be
Chris@19 32 stated in a translation approved by the Free Software Foundation.
Chris@19 33 -->
Chris@19 34 <meta http-equiv="Content-Style-Type" content="text/css">
Chris@19 35 <style type="text/css"><!--
Chris@19 36 pre.display { font-family:inherit }
Chris@19 37 pre.format { font-family:inherit }
Chris@19 38 pre.smalldisplay { font-family:inherit; font-size:smaller }
Chris@19 39 pre.smallformat { font-family:inherit; font-size:smaller }
Chris@19 40 pre.smallexample { font-size:smaller }
Chris@19 41 pre.smalllisp { font-size:smaller }
Chris@19 42 span.sc { font-variant:small-caps }
Chris@19 43 span.roman { font-family:serif; font-weight:normal; }
Chris@19 44 span.sansserif { font-family:sans-serif; font-weight:normal; }
Chris@19 45 --></style>
Chris@19 46 </head>
Chris@19 47 <body>
Chris@19 48 <div class="node">
Chris@19 49 <a name="FFTW-MPI-Wisdom"></a>
Chris@19 50 <p>
Chris@19 51 Next:&nbsp;<a rel="next" accesskey="n" href="Avoiding-MPI-Deadlocks.html#Avoiding-MPI-Deadlocks">Avoiding MPI Deadlocks</a>,
Chris@19 52 Previous:&nbsp;<a rel="previous" accesskey="p" href="FFTW-MPI-Transposes.html#FFTW-MPI-Transposes">FFTW MPI Transposes</a>,
Chris@19 53 Up:&nbsp;<a rel="up" accesskey="u" href="Distributed_002dmemory-FFTW-with-MPI.html#Distributed_002dmemory-FFTW-with-MPI">Distributed-memory FFTW with MPI</a>
Chris@19 54 <hr>
Chris@19 55 </div>
Chris@19 56
Chris@19 57 <h3 class="section">6.8 FFTW MPI Wisdom</h3>
Chris@19 58
Chris@19 59 <p><a name="index-wisdom-413"></a><a name="index-saving-plans-to-disk-414"></a>
Chris@19 60 FFTW's &ldquo;wisdom&rdquo; facility (see <a href="Words-of-Wisdom_002dSaving-Plans.html#Words-of-Wisdom_002dSaving-Plans">Words of Wisdom-Saving Plans</a>) can
Chris@19 61 be used to save MPI plans as well as to save uniprocessor plans.
Chris@19 62 However, for MPI there are several unavoidable complications.
Chris@19 63
Chris@19 64 <p><a name="index-MPI-I_002fO-415"></a>First, the MPI standard does not guarantee that every process can
Chris@19 65 perform file I/O (at least, not using C stdio routines)&mdash;in general,
Chris@19 66 we may only assume that process 0 is capable of I/O.<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a> So, if we
Chris@19 67 want to export the wisdom from a single process to a file, we must
Chris@19 68 first export the wisdom to a string, then send it to process 0, then
Chris@19 69 write it to a file.
Chris@19 70
Chris@19 71 <p>Second, in principle we may want to have separate wisdom for every
Chris@19 72 process, since in general the processes may run on different hardware
Chris@19 73 even for a single MPI program. However, in practice FFTW's MPI code
Chris@19 74 is designed for the case of homogeneous hardware (see <a href="Load-balancing.html#Load-balancing">Load balancing</a>), and in this case it is convenient to use the same wisdom
Chris@19 75 for every process. Thus, we need a mechanism to synchronize the wisdom.
Chris@19 76
Chris@19 77 <p>To address both of these problems, FFTW provides the following two
Chris@19 78 functions:
Chris@19 79
Chris@19 80 <pre class="example"> void fftw_mpi_broadcast_wisdom(MPI_Comm comm);
Chris@19 81 void fftw_mpi_gather_wisdom(MPI_Comm comm);
Chris@19 82 </pre>
Chris@19 83 <p><a name="index-fftw_005fmpi_005fgather_005fwisdom-416"></a><a name="index-fftw_005fmpi_005fbroadcast_005fwisdom-417"></a>
Chris@19 84 Given a communicator <code>comm</code>, <code>fftw_mpi_broadcast_wisdom</code>
Chris@19 85 will broadcast the wisdom from process 0 to all other processes.
Chris@19 86 Conversely, <code>fftw_mpi_gather_wisdom</code> will collect wisdom from all
Chris@19 87 processes onto process 0. (If the plans created for the same problem
Chris@19 88 by different processes are not the same, <code>fftw_mpi_gather_wisdom</code>
Chris@19 89 will arbitrarily choose one of the plans.) Both of these functions
Chris@19 90 may result in suboptimal plans for different processes if the
Chris@19 91 processes are running on non-identical hardware. Both of these
Chris@19 92 functions are <em>collective</em> calls, which means that they must be
Chris@19 93 executed by all processes in the communicator.
Chris@19 94 <a name="index-collective-function-418"></a>
Chris@19 95
Chris@19 96 <p>So, for example, a typical code snippet to import wisdom from a file
Chris@19 97 and use it on all processes would be:
Chris@19 98
Chris@19 99 <pre class="example"> {
Chris@19 100 int rank;
Chris@19 101
Chris@19 102 fftw_mpi_init();
Chris@19 103 MPI_Comm_rank(MPI_COMM_WORLD, &amp;rank);
Chris@19 104 if (rank == 0) fftw_import_wisdom_from_filename("mywisdom");
Chris@19 105 fftw_mpi_broadcast_wisdom(MPI_COMM_WORLD);
Chris@19 106 }
Chris@19 107 </pre>
Chris@19 108 <p>(Note that we must call <code>fftw_mpi_init</code> before importing any
Chris@19 109 wisdom that might contain MPI plans.) Similarly, a typical code
Chris@19 110 snippet to export wisdom from all processes to a file is:
Chris@19 111 <a name="index-fftw_005fmpi_005finit-419"></a>
Chris@19 112 <pre class="example"> {
Chris@19 113 int rank;
Chris@19 114
Chris@19 115 fftw_mpi_gather_wisdom(MPI_COMM_WORLD);
Chris@19 116 MPI_Comm_rank(MPI_COMM_WORLD, &amp;rank);
Chris@19 117 if (rank == 0) fftw_export_wisdom_to_filename("mywisdom");
Chris@19 118 }
Chris@19 119 </pre>
Chris@19 120 <!-- -->
Chris@19 121 <div class="footnote">
Chris@19 122 <hr>
Chris@19 123 <h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1" href="#fnd-1">1</a>]</small> In fact,
Chris@19 124 even this assumption is not technically guaranteed by the standard,
Chris@19 125 although it seems to be universal in actual MPI implementations and is
Chris@19 126 widely assumed by MPI-using software. Technically, you need to query
Chris@19 127 the <code>MPI_IO</code> attribute of <code>MPI_COMM_WORLD</code> with
Chris@19 128 <code>MPI_Attr_get</code>. If this attribute is <code>MPI_PROC_NULL</code>, no
Chris@19 129 I/O is possible. If it is <code>MPI_ANY_SOURCE</code>, any process can
Chris@19 130 perform I/O. Otherwise, it is the rank of a process that can perform
Chris@19 131 I/O ... but since it is not guaranteed to yield the <em>same</em> rank
Chris@19 132 on all processes, you have to do an <code>MPI_Allreduce</code> of some kind
Chris@19 133 if you want all processes to agree about which is going to do I/O.
Chris@19 134 And even then, the standard only guarantees that this process can
Chris@19 135 perform output, but not input. See e.g. <cite>Parallel Programming
Chris@19 136 with MPI</cite> by P. S. Pacheco, section 8.1.3. Needless to say, in our
Chris@19 137 experience virtually no MPI programmers worry about this.</p>
Chris@19 138
Chris@19 139 <hr></div>
Chris@19 140
Chris@19 141 </body></html>
Chris@19 142