CUFFT how use it?


i have some problems to understand how correctly use the cufft library.

i must calculate the fourier transform of an array of 512 elements (floats).

this my code:

#define DIM 512


	float f[DIM];

	FILE *img = fopen("Image0.bin","r");



	cufftComplex f2[DIM];

	int i;

	for(i = 0; i < DIM; i++)

		f2[i].x = f[i];

		 cufftComplex *df;



	cufftHandle plan;

	cufftPlan1d(&plan, DIM, CUFFT_C2C, 1);

	cufftExecC2C(plan, df, df,CUFFT_FORWARD);


the problem is that this code do nothing in sense that f and f2 are equal.

Reading the cufft manual in the examples i noted that it uses ‘BATCH’…what is the utility of batch?

why it is == 10 in the examples and not == 2 or == 100?

thanks a lot

Are you performing any error checking?

BATCH is for doing many FFTs of the same length in parallel. If you aren’t using this, you probably don’t want to use CUDA. In the example, they are performing 10 FFTs, not 2 nor 100 (the could be, but they chose 10).


ok suppose that i have 900 array of 512 elements…to calculate the DFT of everyone i can





 cufftPlan1d(&plan, 512, CUFFT_C2C, 900);

 cufftExecC2C(plan, df, df,CUFFT_FORWARD);


thank you!

Yep, that code should do the trick. I urge you to look into adding some error handling though ;)