A simple 1D FFT

Let's start by looking at how we can use cuBLAS to compute a simple 1D FFT. First, we will briefly discuss the cuFFT interface in Scikit-CUDA.

There are two submodules here that we can access the cuFFT library with, cufft and fft. cufft consists of a collection of low-level wrappers for the cuFFT library, while fft provides a more user-friendly interface; we will be working solely with fft in this chapter.

Let's start with the appropriate imports, remembering to include the Scikit-CUDA fft submodule:

import pycuda.autoinitfrom pycuda import gpuarrayimport numpy as npfrom skcuda import fft

We now will set up some random array and copy it to the GPU. We will also set up an empty GPU array that will be used to store the FFT ...

Get Hands-On GPU Programming with Python and CUDA now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.