GTC2013

Fast Fourier Transforms (FFT) on the GPU Part II: C++ AMP FFT Test Application

| 18 November, 2011

This is the second part of Fast Fourier Transforms (FFT) on the GPU tutorial written by Yossi Levanoni of Microsoft. In previous part we have introduced the Fast Fourier Transform (FFT) on the GPU and shared a C++ AMP FTT Library. This post further demonstrates how to use multi-dimensional transformations, and inverse transformations.

Please follow these instructions to build and execute the test application.

  1. Download and expand the attached zip archive.
  2. Open the Visual C++ project in the Visual Studio Developer Preview environment and build it.
  3. Open a Visual Studio command prompt and go to the output directory.
  4. In the output directory, run the generated program amp_fft_sample.exe, specifying as a parameter the number of dimensions you wish to use in the transformation (1, 2 or 3).
  5. After amp_fft_sample executes, the data is written out in textual delimited form into a file named data.txt.
  6. From the same directory, launch the spreadsheet amp_fft.xlsm (the spreadsheet is copied to the output directory using a build rule). You may need to instruct Excel to allow macro execution and you may also need to manually click on the “Update Data” button at the top of the page to populate the charts, after enabling macro execution.
  7. The spreadsheet will now present charts depicting the input data, transformed data and reverse transformed data.

The test is a command line program that receives a single parameter, which tells it what rank of transformation to test. That can be either “1” for 1d, “2” for 2d or “3” for 3d. In any case, the program generates an input vector with 10,000 float elements, according to an arbitrary (but visually appealing when rendered in Excel!) mathematical formula that you can change as you see fit. After the input vector is generated, a 1d, 2d or 3d array is populated using it, and is transformed. The transformed array is then inverse-transformed. Had the FFT transform been a loss-less transformation, the final result would have been identical to the original input. However, an FFT is always a lossy transformation, so the final input will inevitably contain some differences compared to the original input. In fact, since a 2d transformation of a 100×100 array is essentially comprised of many smaller 100-elements-at-a-time FFTs, and since an FFT on a smaller input involves more transformation-related data loss, the 2d transformation result will be much less faithful to the original than a 1d transformation, and a 3d transformation will be the one involving the most data loss of the three.

Here is a snapshot of the Excel charts after applying a 1d transform:

And here are the (much noisier) results of the 2d transformation for the same input data:

This concludes our discussion of FFTs for the time being. Please free to ask questions and provide feedback on Microsoft C++ AMP support forum.

[Written by Yossi Levanoni, Microsoft]

Tags: , , , ,

Category: Code Examples, Training & Events

Comments are closed.