I am executing the following program and the program compiles and links correctly. But on execution I get the following error. I believe I have used the signal size as the argument in cufftExecC2C and not the data size. Any help is much appreciated.
#include <stdio.h>
#include <assert.h>
#include <cuda.h>
#include <cufft.h>
#define NX 256
#define BATCH 10
int main(void)
{
cufftComplex *h_data, *data;
int i;
cufftHandle plan;
h_data=(cufftComplex ) malloc(NXBATCH*sizeof(cufftComplex));
cudaMalloc((void**)&data, sizeof(cufftComplex)NXBATCH);
cufftPlan1d (&plan, NX, CUFFT_C2C, BATCH);
//data=(cufftComplex *) data;
for(i=0;i<NX*BATCH;i++)
(h_data+i)->x=1.0f;
cudaMemcpy(data, h_data, NXBATCHsizeof(cufftComplex),cudaMemcpyHostToDevice);
cufftExecC2C(plan, data, data, CUFFT_FORWARD);
cudaMemcpy(h_data, data, NXBATCHsizeof(cufftComplex), cudaMemcpyDeviceToHost);
printf(“After Transform:\n”);
for (i=0;i<NX*BATCH;i+=NX)
printf("Real=%lf Complex=%lf\n", (h_data+i)->x, (h_data+i+1)->y);
cufftExecC2C(plan, data, data, CUFFT_INVERSE);
printf(“After Inverse Transform:\n”);
for (i=0;i<NX*BATCH;i+=NX)
printf("Real=%lf Complex=%lf\n", (h_data+i)->x, (h_data+i+1)->y);
}
I am sure I am missing out something but after trying for a very long time I am not able to spot my mistake.
Thanks,
Guru