annotate src/fftw-3.3.3/doc/html/FFTW-MPI-Wisdom.html @ 95:89f5e221ed7b

Add FFTW3
author Chris Cannam <cannam@all-day-breakfast.com>
date Wed, 20 Mar 2013 15:35:50 +0000
parents
children
rev   line source
cannam@95 1 <html lang="en">
cannam@95 2 <head>
cannam@95 3 <title>FFTW MPI Wisdom - 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="Distributed_002dmemory-FFTW-with-MPI.html#Distributed_002dmemory-FFTW-with-MPI" title="Distributed-memory FFTW with MPI">
cannam@95 9 <link rel="prev" href="FFTW-MPI-Transposes.html#FFTW-MPI-Transposes" title="FFTW MPI Transposes">
cannam@95 10 <link rel="next" href="Avoiding-MPI-Deadlocks.html#Avoiding-MPI-Deadlocks" title="Avoiding MPI Deadlocks">
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="FFTW-MPI-Wisdom"></a>
cannam@95 50 <p>
cannam@95 51 Next:&nbsp;<a rel="next" accesskey="n" href="Avoiding-MPI-Deadlocks.html#Avoiding-MPI-Deadlocks">Avoiding MPI Deadlocks</a>,
cannam@95 52 Previous:&nbsp;<a rel="previous" accesskey="p" href="FFTW-MPI-Transposes.html#FFTW-MPI-Transposes">FFTW MPI Transposes</a>,
cannam@95 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>
cannam@95 54 <hr>
cannam@95 55 </div>
cannam@95 56
cannam@95 57 <h3 class="section">6.8 FFTW MPI Wisdom</h3>
cannam@95 58
cannam@95 59 <p><a name="index-wisdom-410"></a><a name="index-saving-plans-to-disk-411"></a>
cannam@95 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
cannam@95 61 be used to save MPI plans as well as to save uniprocessor plans.
cannam@95 62 However, for MPI there are several unavoidable complications.
cannam@95 63
cannam@95 64 <p><a name="index-MPI-I_002fO-412"></a>First, the MPI standard does not guarantee that every process can
cannam@95 65 perform file I/O (at least, not using C stdio routines)&mdash;in general,
cannam@95 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
cannam@95 67 want to export the wisdom from a single process to a file, we must
cannam@95 68 first export the wisdom to a string, then send it to process 0, then
cannam@95 69 write it to a file.
cannam@95 70
cannam@95 71 <p>Second, in principle we may want to have separate wisdom for every
cannam@95 72 process, since in general the processes may run on different hardware
cannam@95 73 even for a single MPI program. However, in practice FFTW's MPI code
cannam@95 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
cannam@95 75 for every process. Thus, we need a mechanism to synchronize the wisdom.
cannam@95 76
cannam@95 77 <p>To address both of these problems, FFTW provides the following two
cannam@95 78 functions:
cannam@95 79
cannam@95 80 <pre class="example"> void fftw_mpi_broadcast_wisdom(MPI_Comm comm);
cannam@95 81 void fftw_mpi_gather_wisdom(MPI_Comm comm);
cannam@95 82 </pre>
cannam@95 83 <p><a name="index-fftw_005fmpi_005fgather_005fwisdom-413"></a><a name="index-fftw_005fmpi_005fbroadcast_005fwisdom-414"></a>
cannam@95 84 Given a communicator <code>comm</code>, <code>fftw_mpi_broadcast_wisdom</code>
cannam@95 85 will broadcast the wisdom from process 0 to all other processes.
cannam@95 86 Conversely, <code>fftw_mpi_gather_wisdom</code> will collect wisdom from all
cannam@95 87 processes onto process 0. (If the plans created for the same problem
cannam@95 88 by different processes are not the same, <code>fftw_mpi_gather_wisdom</code>
cannam@95 89 will arbitrarily choose one of the plans.) Both of these functions
cannam@95 90 may result in suboptimal plans for different processes if the
cannam@95 91 processes are running on non-identical hardware. Both of these
cannam@95 92 functions are <em>collective</em> calls, which means that they must be
cannam@95 93 executed by all processes in the communicator.
cannam@95 94 <a name="index-collective-function-415"></a>
cannam@95 95
cannam@95 96 <p>So, for example, a typical code snippet to import wisdom from a file
cannam@95 97 and use it on all processes would be:
cannam@95 98
cannam@95 99 <pre class="example"> {
cannam@95 100 int rank;
cannam@95 101
cannam@95 102 fftw_mpi_init();
cannam@95 103 MPI_Comm_rank(MPI_COMM_WORLD, &amp;rank);
cannam@95 104 if (rank == 0) fftw_import_wisdom_from_filename("mywisdom");
cannam@95 105 fftw_mpi_broadcast_wisdom(MPI_COMM_WORLD);
cannam@95 106 }
cannam@95 107 </pre>
cannam@95 108 <p>(Note that we must call <code>fftw_mpi_init</code> before importing any
cannam@95 109 wisdom that might contain MPI plans.) Similarly, a typical code
cannam@95 110 snippet to export wisdom from all processes to a file is:
cannam@95 111 <a name="index-fftw_005fmpi_005finit-416"></a>
cannam@95 112 <pre class="example"> {
cannam@95 113 int rank;
cannam@95 114
cannam@95 115 fftw_mpi_gather_wisdom(MPI_COMM_WORLD);
cannam@95 116 MPI_Comm_rank(MPI_COMM_WORLD, &amp;rank);
cannam@95 117 if (rank == 0) fftw_export_wisdom_to_filename("mywisdom");
cannam@95 118 }
cannam@95 119 </pre>
cannam@95 120 <!-- -->
cannam@95 121 <div class="footnote">
cannam@95 122 <hr>
cannam@95 123 <h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1" href="#fnd-1">1</a>]</small> In fact,
cannam@95 124 even this assumption is not technically guaranteed by the standard,
cannam@95 125 although it seems to be universal in actual MPI implementations and is
cannam@95 126 widely assumed by MPI-using software. Technically, you need to query
cannam@95 127 the <code>MPI_IO</code> attribute of <code>MPI_COMM_WORLD</code> with
cannam@95 128 <code>MPI_Attr_get</code>. If this attribute is <code>MPI_PROC_NULL</code>, no
cannam@95 129 I/O is possible. If it is <code>MPI_ANY_SOURCE</code>, any process can
cannam@95 130 perform I/O. Otherwise, it is the rank of a process that can perform
cannam@95 131 I/O ... but since it is not guaranteed to yield the <em>same</em> rank
cannam@95 132 on all processes, you have to do an <code>MPI_Allreduce</code> of some kind
cannam@95 133 if you want all processes to agree about which is going to do I/O.
cannam@95 134 And even then, the standard only guarantees that this process can
cannam@95 135 perform output, but not input. See e.g. <cite>Parallel Programming
cannam@95 136 with MPI</cite> by P. S. Pacheco, section 8.1.3. Needless to say, in our
cannam@95 137 experience virtually no MPI programmers worry about this.</p>
cannam@95 138
cannam@95 139 <hr></div>
cannam@95 140
cannam@95 141 </body></html>
cannam@95 142