如何使用CUFFT的批处理模式?

Der*_*rek 4 c++ cuda fft fftw

我试图弄清楚如何使用 CUFFT 库中提供的批处理模式。

我基本上有一个宽 5300 像素、高 3500 像素的图像。目前,这意味着我正在使用 FFTW 对这 5300 个元素运行 3500 个 1D FFT。

这是以批处理模式运行 CUFFT 库的一个很好的候选问题吗?必须如何设置数据才能解决此问题?

谢谢

小智 5

是的,您可以使用批处理模式。

要使用批处理模式,需要连续存储5300个元素。

这意味着相邻批次之间的距离是 5300。你可以这样做:

..........
cufftComplex *host;
cufftComplex *device;
CudaMallocHost((void **)&host,sizeof(cufftComplex)*5300*3500);
CudaMalloc((void **)&devcie,sizeof(cufftComplex)*5300*3500);
//here add the elements,like this:
//host[0-5299] the first batch, host[5300-10599] the second batch ,and up to the 3500th batch.
CudaMemcpy(device,host,sizeof(cufftComplex)*5300*3500,......);
CufftPlan1d(&device,5300,type,3500);
CufftExecC2C(......);
......
Run Code Online (Sandbox Code Playgroud)

有关更多详细信息,请参阅 CUFFT 手册。