annotate src/fftw-3.3.3/doc/html/Thread-safety.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>Thread safety - 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="Multi_002dthreaded-FFTW.html#Multi_002dthreaded-FFTW" title="Multi-threaded FFTW">
cannam@95 9 <link rel="prev" href="How-Many-Threads-to-Use_003f.html#How-Many-Threads-to-Use_003f" title="How Many Threads to Use?">
cannam@95 10 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
cannam@95 11 <!--
cannam@95 12 This manual is for FFTW
cannam@95 13 (version 3.3.3, 25 November 2012).
cannam@95 14
cannam@95 15 Copyright (C) 2003 Matteo Frigo.
cannam@95 16
cannam@95 17 Copyright (C) 2003 Massachusetts Institute of Technology.
cannam@95 18
cannam@95 19 Permission is granted to make and distribute verbatim copies of
cannam@95 20 this manual provided the copyright notice and this permission
cannam@95 21 notice are preserved on all copies.
cannam@95 22
cannam@95 23 Permission is granted to copy and distribute modified versions of
cannam@95 24 this manual under the conditions for verbatim copying, provided
cannam@95 25 that the entire resulting derived work is distributed under the
cannam@95 26 terms of a permission notice identical to this one.
cannam@95 27
cannam@95 28 Permission is granted to copy and distribute translations of this
cannam@95 29 manual into another language, under the above conditions for
cannam@95 30 modified versions, except that this permission notice may be
cannam@95 31 stated in a translation approved by the Free Software Foundation.
cannam@95 32 -->
cannam@95 33 <meta http-equiv="Content-Style-Type" content="text/css">
cannam@95 34 <style type="text/css"><!--
cannam@95 35 pre.display { font-family:inherit }
cannam@95 36 pre.format { font-family:inherit }
cannam@95 37 pre.smalldisplay { font-family:inherit; font-size:smaller }
cannam@95 38 pre.smallformat { font-family:inherit; font-size:smaller }
cannam@95 39 pre.smallexample { font-size:smaller }
cannam@95 40 pre.smalllisp { font-size:smaller }
cannam@95 41 span.sc { font-variant:small-caps }
cannam@95 42 span.roman { font-family:serif; font-weight:normal; }
cannam@95 43 span.sansserif { font-family:sans-serif; font-weight:normal; }
cannam@95 44 --></style>
cannam@95 45 </head>
cannam@95 46 <body>
cannam@95 47 <div class="node">
cannam@95 48 <a name="Thread-safety"></a>
cannam@95 49 <p>
cannam@95 50 Previous:&nbsp;<a rel="previous" accesskey="p" href="How-Many-Threads-to-Use_003f.html#How-Many-Threads-to-Use_003f">How Many Threads to Use?</a>,
cannam@95 51 Up:&nbsp;<a rel="up" accesskey="u" href="Multi_002dthreaded-FFTW.html#Multi_002dthreaded-FFTW">Multi-threaded FFTW</a>
cannam@95 52 <hr>
cannam@95 53 </div>
cannam@95 54
cannam@95 55 <h3 class="section">5.4 Thread safety</h3>
cannam@95 56
cannam@95 57 <p><a name="index-threads-341"></a><a name="index-OpenMP-342"></a><a name="index-thread-safety-343"></a>Users writing multi-threaded programs (including OpenMP) must concern
cannam@95 58 themselves with the <dfn>thread safety</dfn> of the libraries they
cannam@95 59 use&mdash;that is, whether it is safe to call routines in parallel from
cannam@95 60 multiple threads. FFTW can be used in such an environment, but some
cannam@95 61 care must be taken because the planner routines share data
cannam@95 62 (e.g. wisdom and trigonometric tables) between calls and plans.
cannam@95 63
cannam@95 64 <p>The upshot is that the only thread-safe (re-entrant) routine in FFTW is
cannam@95 65 <code>fftw_execute</code> (and the new-array variants thereof). All other routines
cannam@95 66 (e.g. the planner) should only be called from one thread at a time. So,
cannam@95 67 for example, you can wrap a semaphore lock around any calls to the
cannam@95 68 planner; even more simply, you can just create all of your plans from
cannam@95 69 one thread. We do not think this should be an important restriction
cannam@95 70 (FFTW is designed for the situation where the only performance-sensitive
cannam@95 71 code is the actual execution of the transform), and the benefits of
cannam@95 72 shared data between plans are great.
cannam@95 73
cannam@95 74 <p>Note also that, since the plan is not modified by <code>fftw_execute</code>,
cannam@95 75 it is safe to execute the <em>same plan</em> in parallel by multiple
cannam@95 76 threads. However, since a given plan operates by default on a fixed
cannam@95 77 array, you need to use one of the new-array execute functions (see <a href="New_002darray-Execute-Functions.html#New_002darray-Execute-Functions">New-array Execute Functions</a>) so that different threads compute the transform of different data.
cannam@95 78
cannam@95 79 <p>(Users should note that these comments only apply to programs using
cannam@95 80 shared-memory threads or OpenMP. Parallelism using MPI or forked processes
cannam@95 81 involves a separate address-space and global variables for each process,
cannam@95 82 and is not susceptible to problems of this sort.)
cannam@95 83
cannam@95 84 <p>If you are configured FFTW with the <code>--enable-debug</code> or
cannam@95 85 <code>--enable-debug-malloc</code> flags (see <a href="Installation-on-Unix.html#Installation-on-Unix">Installation on Unix</a>),
cannam@95 86 then <code>fftw_execute</code> is not thread-safe. These flags are not
cannam@95 87 documented because they are intended only for developing
cannam@95 88 and debugging FFTW, but if you must use <code>--enable-debug</code> then you
cannam@95 89 should also specifically pass <code>--disable-debug-malloc</code> for
cannam@95 90 <code>fftw_execute</code> to be thread-safe.
cannam@95 91
cannam@95 92 </body></html>
cannam@95 93