concept FFT in category opencl

appears as: FFT, The FFT, n FFT
OpenCL in Action: How to Accelerate Graphics and Computation

This is an excerpt from Manning's book OpenCL in Action: How to Accelerate Graphics and Computation.

It’s important to understand that the discrete Fourier transform (DFT) and the fast Fourier transform (FFT) both accomplish the same operation. They both convert time-domain sequences, such as the one depicted on the right-hand side of figure 14.1, into frequency-domain sequences, such as that shown on the right-hand side of figure 14.2. The FFT is faster but the DFT is easier to understand, so we’ll start with this first. This section will present the mathematical theory behind the DFT, work through an example of its computation, and then show how it can be implemented in OpenCL.

The dir variable controls whether the FFT is forward (time-domain to frequency-domain) or backward (frequency-domain to time-domain). If dir is set to 1, the DFT equation will be used and the imaginary sine terms will be negative. If dir is set to –1, the IDFT equation will be used and imaginary sine terms will be positive.

Part 3: performing final stages of the FFT

After the work-items complete their individual FFTs, they work together to compute larger FFTs for the entire work-group. This continues until all of the available local memory is used. For example, if a local memory block contains LOCAL_MEM_SIZE bytes and each complex value occupies 2*sizeof(float) = 8 bytes, each work-group will ultimately perform an FFT whose size is LOCAL_MEM_SIZE/8. That’s shown in the following listing.

Listing 14.4. The fast Fourier transform, part 3: fft.cl

This code resembles the code in listing 14.3, but there are a number of important differences. First, each work-item is given a position within a larger FFT, and each processes a subset of the FFT’s elements. This position is assigned with the following line of code: