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