cufft : ERROR: CUFFT_INVALID_PLAN

I’m trying to use CUFFT library now.

however there are some internal errors

“cufft : ERROR: CUFFT_INVALID_PLAN”

Here is my source code…

Pliz help me…

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cufft.h>
#include <cutil.h>

#define NX 256
#define BATCH 10

typedef float2 Complex;

int main(int argc, char **argv){
short *h_a;
h_a = (short ) malloc(256sizeof(short));

FILE *fr;	
fr=fopen("002.raw","rb");
 fread(h_a,sizeof(short),256,fr);
fclose(fr);

size_t memSize = 256*sizeof(short);

cufftHandle plan;

cufftComplex *data;

cudaMalloc((void**)&data, sizeof(cufftComplex)*(NX/2+1)*BATCH);
cudaMemcpy(data,h_a,memSize,cudaMemcpyHostToDevice);
CUFFT_SAFE_CALL(cufftPlan1d(&plan, NX, CUFFT_R2C, 10)); 	

cufftDestroy(plan);
cudaFree(data);

}

Hi,

no sure why cufft returns INVALID PLAN, but I note that:

  1. You did not init your CUDA device (CUT_DEVICE_INIT() from cutils.h): so the program can’t inform you if something went wrong when looking for a CUDA device.

Are you sure you have a compatible CUDA device, and that this device is correctly recognized by CUDA?

Try the “deviceQuery” example in the SDK.

  1. You use “Complex” type and “cudafftComplex” at the same time: it’s not the same type.

Complex is a vector while cudafftComplex is a struct.

  1. You use short int as a host array, but cudafft works with single-precision floats.

It’s better not to mix types, so you may want to covert your file-loaded data from int to float

I suspect point 1) could help for your specific problem, but I’d suggest having a look at 2) and 3) too.

Fernando