comparison src/fftw-3.3.8/doc/html/Usage-of-Multi_002dthreaded-FFTW.html @ 167:bd3cc4d1df30

Add FFTW 3.3.8 source, and a Linux build
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 19 Nov 2019 14:52:55 +0000
parents
children
comparison
equal deleted inserted replaced
166:cbd6d7e562c7 167:bd3cc4d1df30
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <!-- This manual is for FFTW
4 (version 3.3.8, 24 May 2018).
5
6 Copyright (C) 2003 Matteo Frigo.
7
8 Copyright (C) 2003 Massachusetts Institute of Technology.
9
10 Permission is granted to make and distribute verbatim copies of this
11 manual provided the copyright notice and this permission notice are
12 preserved on all copies.
13
14 Permission is granted to copy and distribute modified versions of this
15 manual under the conditions for verbatim copying, provided that the
16 entire resulting derived work is distributed under the terms of a
17 permission notice identical to this one.
18
19 Permission is granted to copy and distribute translations of this manual
20 into another language, under the above conditions for modified versions,
21 except that this permission notice may be stated in a translation
22 approved by the Free Software Foundation. -->
23 <!-- Created by GNU Texinfo 6.3, http://www.gnu.org/software/texinfo/ -->
24 <head>
25 <title>FFTW 3.3.8: Usage of Multi-threaded FFTW</title>
26
27 <meta name="description" content="FFTW 3.3.8: Usage of Multi-threaded FFTW">
28 <meta name="keywords" content="FFTW 3.3.8: Usage of Multi-threaded FFTW">
29 <meta name="resource-type" content="document">
30 <meta name="distribution" content="global">
31 <meta name="Generator" content="makeinfo">
32 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
33 <link href="index.html#Top" rel="start" title="Top">
34 <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
35 <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
36 <link href="Multi_002dthreaded-FFTW.html#Multi_002dthreaded-FFTW" rel="up" title="Multi-threaded FFTW">
37 <link href="How-Many-Threads-to-Use_003f.html#How-Many-Threads-to-Use_003f" rel="next" title="How Many Threads to Use?">
38 <link href="Installation-and-Supported-Hardware_002fSoftware.html#Installation-and-Supported-Hardware_002fSoftware" rel="prev" title="Installation and Supported Hardware/Software">
39 <style type="text/css">
40 <!--
41 a.summary-letter {text-decoration: none}
42 blockquote.indentedblock {margin-right: 0em}
43 blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
44 blockquote.smallquotation {font-size: smaller}
45 div.display {margin-left: 3.2em}
46 div.example {margin-left: 3.2em}
47 div.lisp {margin-left: 3.2em}
48 div.smalldisplay {margin-left: 3.2em}
49 div.smallexample {margin-left: 3.2em}
50 div.smalllisp {margin-left: 3.2em}
51 kbd {font-style: oblique}
52 pre.display {font-family: inherit}
53 pre.format {font-family: inherit}
54 pre.menu-comment {font-family: serif}
55 pre.menu-preformatted {font-family: serif}
56 pre.smalldisplay {font-family: inherit; font-size: smaller}
57 pre.smallexample {font-size: smaller}
58 pre.smallformat {font-family: inherit; font-size: smaller}
59 pre.smalllisp {font-size: smaller}
60 span.nolinebreak {white-space: nowrap}
61 span.roman {font-family: initial; font-weight: normal}
62 span.sansserif {font-family: sans-serif; font-weight: normal}
63 ul.no-bullet {list-style: none}
64 -->
65 </style>
66
67
68 </head>
69
70 <body lang="en">
71 <a name="Usage-of-Multi_002dthreaded-FFTW"></a>
72 <div class="header">
73 <p>
74 Next: <a href="How-Many-Threads-to-Use_003f.html#How-Many-Threads-to-Use_003f" accesskey="n" rel="next">How Many Threads to Use?</a>, Previous: <a href="Installation-and-Supported-Hardware_002fSoftware.html#Installation-and-Supported-Hardware_002fSoftware" accesskey="p" rel="prev">Installation and Supported Hardware/Software</a>, Up: <a href="Multi_002dthreaded-FFTW.html#Multi_002dthreaded-FFTW" accesskey="u" rel="up">Multi-threaded FFTW</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
75 </div>
76 <hr>
77 <a name="Usage-of-Multi_002dthreaded-FFTW-1"></a>
78 <h3 class="section">5.2 Usage of Multi-threaded FFTW</h3>
79
80 <p>Here, it is assumed that the reader is already familiar with the usage
81 of the uniprocessor FFTW routines, described elsewhere in this manual.
82 We only describe what one has to change in order to use the
83 multi-threaded routines.
84 </p>
85 <a name="index-OpenMP-1"></a>
86 <p>First, programs using the parallel complex transforms should be linked
87 with <code>-lfftw3_threads -lfftw3 -lm</code> on Unix, or <code>-lfftw3_omp
88 -lfftw3 -lm</code> if you compiled with OpenMP. You will also need to link
89 with whatever library is responsible for threads on your system
90 (e.g. <code>-lpthread</code> on GNU/Linux) or include whatever compiler flag
91 enables OpenMP (e.g. <code>-fopenmp</code> with gcc).
92 <a name="index-linking-on-Unix"></a>
93 </p>
94
95 <p>Second, before calling <em>any</em> FFTW routines, you should call the
96 function:
97 </p>
98 <div class="example">
99 <pre class="example">int fftw_init_threads(void);
100 </pre></div>
101 <a name="index-fftw_005finit_005fthreads"></a>
102
103 <p>This function, which need only be called once, performs any one-time
104 initialization required to use threads on your system. It returns zero
105 if there was some error (which should not happen under normal
106 circumstances) and a non-zero value otherwise.
107 </p>
108 <p>Third, before creating a plan that you want to parallelize, you should
109 call:
110 </p>
111 <div class="example">
112 <pre class="example">void fftw_plan_with_nthreads(int nthreads);
113 </pre></div>
114 <a name="index-fftw_005fplan_005fwith_005fnthreads"></a>
115
116 <p>The <code>nthreads</code> argument indicates the number of threads you want
117 FFTW to use (or actually, the maximum number). All plans subsequently
118 created with any planner routine will use that many threads. You can
119 call <code>fftw_plan_with_nthreads</code>, create some plans, call
120 <code>fftw_plan_with_nthreads</code> again with a different argument, and
121 create some more plans for a new number of threads. Plans already created
122 before a call to <code>fftw_plan_with_nthreads</code> are unaffected. If you
123 pass an <code>nthreads</code> argument of <code>1</code> (the default), threads are
124 disabled for subsequent plans.
125 </p>
126 <a name="index-OpenMP-2"></a>
127 <p>With OpenMP, to configure FFTW to use all of the currently running
128 OpenMP threads (set by <code>omp_set_num_threads(nthreads)</code> or by the
129 <code>OMP_NUM_THREADS</code> environment variable), you can do:
130 <code>fftw_plan_with_nthreads(omp_get_max_threads())</code>. (The &lsquo;<samp>omp_</samp>&rsquo;
131 OpenMP functions are declared via <code>#include &lt;omp.h&gt;</code>.)
132 </p>
133 <a name="index-thread-safety"></a>
134 <p>Given a plan, you then execute it as usual with
135 <code>fftw_execute(plan)</code>, and the execution will use the number of
136 threads specified when the plan was created. When done, you destroy
137 it as usual with <code>fftw_destroy_plan</code>. As described in
138 <a href="Thread-safety.html#Thread-safety">Thread safety</a>, plan <em>execution</em> is thread-safe, but plan
139 creation and destruction are <em>not</em>: you should create/destroy
140 plans only from a single thread, but can safely execute multiple plans
141 in parallel.
142 </p>
143 <p>There is one additional routine: if you want to get rid of all memory
144 and other resources allocated internally by FFTW, you can call:
145 </p>
146 <div class="example">
147 <pre class="example">void fftw_cleanup_threads(void);
148 </pre></div>
149 <a name="index-fftw_005fcleanup_005fthreads"></a>
150
151 <p>which is much like the <code>fftw_cleanup()</code> function except that it
152 also gets rid of threads-related data. You must <em>not</em> execute any
153 previously created plans after calling this function.
154 </p>
155 <p>We should also mention one other restriction: if you save wisdom from a
156 program using the multi-threaded FFTW, that wisdom <em>cannot be used</em>
157 by a program using only the single-threaded FFTW (i.e. not calling
158 <code>fftw_init_threads</code>). See <a href="Words-of-Wisdom_002dSaving-Plans.html#Words-of-Wisdom_002dSaving-Plans">Words of Wisdom-Saving Plans</a>.
159 </p>
160 <hr>
161 <div class="header">
162 <p>
163 Next: <a href="How-Many-Threads-to-Use_003f.html#How-Many-Threads-to-Use_003f" accesskey="n" rel="next">How Many Threads to Use?</a>, Previous: <a href="Installation-and-Supported-Hardware_002fSoftware.html#Installation-and-Supported-Hardware_002fSoftware" accesskey="p" rel="prev">Installation and Supported Hardware/Software</a>, Up: <a href="Multi_002dthreaded-FFTW.html#Multi_002dthreaded-FFTW" accesskey="u" rel="up">Multi-threaded FFTW</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
164 </div>
165
166
167
168 </body>
169 </html>