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