cannam@95
|
1 <html lang="en">
|
cannam@95
|
2 <head>
|
cannam@95
|
3 <title>SIMD alignment and fftw_malloc - 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="Other-Important-Topics.html#Other-Important-Topics" title="Other Important Topics">
|
cannam@95
|
9 <link rel="prev" href="Other-Important-Topics.html#Other-Important-Topics" title="Other Important Topics">
|
cannam@95
|
10 <link rel="next" href="Multi_002ddimensional-Array-Format.html#Multi_002ddimensional-Array-Format" title="Multi-dimensional Array Format">
|
cannam@95
|
11 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
|
cannam@95
|
12 <!--
|
cannam@95
|
13 This manual is for FFTW
|
cannam@95
|
14 (version 3.3.3, 25 November 2012).
|
cannam@95
|
15
|
cannam@95
|
16 Copyright (C) 2003 Matteo Frigo.
|
cannam@95
|
17
|
cannam@95
|
18 Copyright (C) 2003 Massachusetts Institute of Technology.
|
cannam@95
|
19
|
cannam@95
|
20 Permission is granted to make and distribute verbatim copies of
|
cannam@95
|
21 this manual provided the copyright notice and this permission
|
cannam@95
|
22 notice are preserved on all copies.
|
cannam@95
|
23
|
cannam@95
|
24 Permission is granted to copy and distribute modified versions of
|
cannam@95
|
25 this manual under the conditions for verbatim copying, provided
|
cannam@95
|
26 that the entire resulting derived work is distributed under the
|
cannam@95
|
27 terms of a permission notice identical to this one.
|
cannam@95
|
28
|
cannam@95
|
29 Permission is granted to copy and distribute translations of this
|
cannam@95
|
30 manual into another language, under the above conditions for
|
cannam@95
|
31 modified versions, except that this permission notice may be
|
cannam@95
|
32 stated in a translation approved by the Free Software Foundation.
|
cannam@95
|
33 -->
|
cannam@95
|
34 <meta http-equiv="Content-Style-Type" content="text/css">
|
cannam@95
|
35 <style type="text/css"><!--
|
cannam@95
|
36 pre.display { font-family:inherit }
|
cannam@95
|
37 pre.format { font-family:inherit }
|
cannam@95
|
38 pre.smalldisplay { font-family:inherit; font-size:smaller }
|
cannam@95
|
39 pre.smallformat { font-family:inherit; font-size:smaller }
|
cannam@95
|
40 pre.smallexample { font-size:smaller }
|
cannam@95
|
41 pre.smalllisp { font-size:smaller }
|
cannam@95
|
42 span.sc { font-variant:small-caps }
|
cannam@95
|
43 span.roman { font-family:serif; font-weight:normal; }
|
cannam@95
|
44 span.sansserif { font-family:sans-serif; font-weight:normal; }
|
cannam@95
|
45 --></style>
|
cannam@95
|
46 </head>
|
cannam@95
|
47 <body>
|
cannam@95
|
48 <div class="node">
|
cannam@95
|
49 <a name="SIMD-alignment-and-fftw_malloc"></a>
|
cannam@95
|
50 <a name="SIMD-alignment-and-fftw_005fmalloc"></a>
|
cannam@95
|
51 <p>
|
cannam@95
|
52 Next: <a rel="next" accesskey="n" href="Multi_002ddimensional-Array-Format.html#Multi_002ddimensional-Array-Format">Multi-dimensional Array Format</a>,
|
cannam@95
|
53 Previous: <a rel="previous" accesskey="p" href="Other-Important-Topics.html#Other-Important-Topics">Other Important Topics</a>,
|
cannam@95
|
54 Up: <a rel="up" accesskey="u" href="Other-Important-Topics.html#Other-Important-Topics">Other Important Topics</a>
|
cannam@95
|
55 <hr>
|
cannam@95
|
56 </div>
|
cannam@95
|
57
|
cannam@95
|
58 <h3 class="section">3.1 SIMD alignment and fftw_malloc</h3>
|
cannam@95
|
59
|
cannam@95
|
60 <p>SIMD, which stands for “Single Instruction Multiple Data,” is a set of
|
cannam@95
|
61 special operations supported by some processors to perform a single
|
cannam@95
|
62 operation on several numbers (usually 2 or 4) simultaneously. SIMD
|
cannam@95
|
63 floating-point instructions are available on several popular CPUs:
|
cannam@95
|
64 SSE/SSE2/AVX on recent x86/x86-64 processors, AltiVec (single precision)
|
cannam@95
|
65 on some PowerPCs (Apple G4 and higher), NEON on some ARM models, and MIPS Paired Single
|
cannam@95
|
66 (currently only in FFTW 3.2.x). FFTW can be compiled to support the
|
cannam@95
|
67 SIMD instructions on any of these systems.
|
cannam@95
|
68 <a name="index-SIMD-102"></a><a name="index-SSE-103"></a><a name="index-SSE2-104"></a><a name="index-AVX-105"></a><a name="index-AltiVec-106"></a><a name="index-MIPS-PS-107"></a><a name="index-precision-108"></a>
|
cannam@95
|
69
|
cannam@95
|
70 <p>A program linking to an FFTW library compiled with SIMD support can
|
cannam@95
|
71 obtain a nonnegligible speedup for most complex and r2c/c2r
|
cannam@95
|
72 transforms. In order to obtain this speedup, however, the arrays of
|
cannam@95
|
73 complex (or real) data passed to FFTW must be specially aligned in
|
cannam@95
|
74 memory (typically 16-byte aligned), and often this alignment is more
|
cannam@95
|
75 stringent than that provided by the usual <code>malloc</code> (etc.)
|
cannam@95
|
76 allocation routines.
|
cannam@95
|
77
|
cannam@95
|
78 <p><a name="index-portability-109"></a>In order to guarantee proper alignment for SIMD, therefore, in case
|
cannam@95
|
79 your program is ever linked against a SIMD-using FFTW, we recommend
|
cannam@95
|
80 allocating your transform data with <code>fftw_malloc</code> and
|
cannam@95
|
81 de-allocating it with <code>fftw_free</code>.
|
cannam@95
|
82 <a name="index-fftw_005fmalloc-110"></a><a name="index-fftw_005ffree-111"></a>These have exactly the same interface and behavior as
|
cannam@95
|
83 <code>malloc</code>/<code>free</code>, except that for a SIMD FFTW they ensure
|
cannam@95
|
84 that the returned pointer has the necessary alignment (by calling
|
cannam@95
|
85 <code>memalign</code> or its equivalent on your OS).
|
cannam@95
|
86
|
cannam@95
|
87 <p>You are not <em>required</em> to use <code>fftw_malloc</code>. You can
|
cannam@95
|
88 allocate your data in any way that you like, from <code>malloc</code> to
|
cannam@95
|
89 <code>new</code> (in C++) to a fixed-size array declaration. If the array
|
cannam@95
|
90 happens not to be properly aligned, FFTW will not use the SIMD
|
cannam@95
|
91 extensions.
|
cannam@95
|
92 <a name="index-C_002b_002b-112"></a>
|
cannam@95
|
93 <a name="index-fftw_005falloc_005freal-113"></a><a name="index-fftw_005falloc_005fcomplex-114"></a>Since <code>fftw_malloc</code> only ever needs to be used for real and
|
cannam@95
|
94 complex arrays, we provide two convenient wrapper routines
|
cannam@95
|
95 <code>fftw_alloc_real(N)</code> and <code>fftw_alloc_complex(N)</code> that are
|
cannam@95
|
96 equivalent to <code>(double*)fftw_malloc(sizeof(double) * N)</code> and
|
cannam@95
|
97 <code>(fftw_complex*)fftw_malloc(sizeof(fftw_complex) * N)</code>,
|
cannam@95
|
98 respectively (or their equivalents in other precisions).
|
cannam@95
|
99
|
cannam@95
|
100 <!-- -->
|
cannam@95
|
101 </body></html>
|
cannam@95
|
102
|