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