Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: FFTW 3.3.8: SIMD alignment and fftw_malloc Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82:
Chris@82:

Chris@82: Next: , Previous: , Up: Other Important Topics   [Contents][Index]

Chris@82:
Chris@82:
Chris@82: Chris@82:

3.1 SIMD alignment and fftw_malloc

Chris@82: Chris@82:

SIMD, which stands for “Single Instruction Multiple Data,” is a set of Chris@82: special operations supported by some processors to perform a single Chris@82: operation on several numbers (usually 2 or 4) simultaneously. SIMD Chris@82: floating-point instructions are available on several popular CPUs: Chris@82: SSE/SSE2/AVX/AVX2/AVX512/KCVI on some x86/x86-64 processors, AltiVec and Chris@82: VSX on some POWER/PowerPCs, NEON on some ARM models. FFTW can be Chris@82: compiled to support the SIMD instructions on any of these systems. Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: Chris@82:

Chris@82: Chris@82:

A program linking to an FFTW library compiled with SIMD support can Chris@82: obtain a nonnegligible speedup for most complex and r2c/c2r Chris@82: transforms. In order to obtain this speedup, however, the arrays of Chris@82: complex (or real) data passed to FFTW must be specially aligned in Chris@82: memory (typically 16-byte aligned), and often this alignment is more Chris@82: stringent than that provided by the usual malloc (etc.) Chris@82: allocation routines. Chris@82:

Chris@82: Chris@82:

In order to guarantee proper alignment for SIMD, therefore, in case Chris@82: your program is ever linked against a SIMD-using FFTW, we recommend Chris@82: allocating your transform data with fftw_malloc and Chris@82: de-allocating it with fftw_free. Chris@82: Chris@82: Chris@82: These have exactly the same interface and behavior as Chris@82: malloc/free, except that for a SIMD FFTW they ensure Chris@82: that the returned pointer has the necessary alignment (by calling Chris@82: memalign or its equivalent on your OS). Chris@82:

Chris@82:

You are not required to use fftw_malloc. You can Chris@82: allocate your data in any way that you like, from malloc to Chris@82: new (in C++) to a fixed-size array declaration. If the array Chris@82: happens not to be properly aligned, FFTW will not use the SIMD Chris@82: extensions. Chris@82: Chris@82:

Chris@82: Chris@82: Chris@82:

Since fftw_malloc only ever needs to be used for real and Chris@82: complex arrays, we provide two convenient wrapper routines Chris@82: fftw_alloc_real(N) and fftw_alloc_complex(N) that are Chris@82: equivalent to (double*)fftw_malloc(sizeof(double) * N) and Chris@82: (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * N), Chris@82: respectively (or their equivalents in other precisions). Chris@82:

Chris@82:
Chris@82:
Chris@82:

Chris@82: Next: , Previous: , Up: Other Important Topics   [Contents][Index]

Chris@82:
Chris@82: Chris@82: Chris@82: Chris@82: Chris@82: