annotate src/fftw-3.3.3/doc/html/Thread-safety.html @ 83:ae30d91d2ffe

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