Hello, i am working in a project in a code with CUFFT but i don’t really know what it does. I have tried to transform a dirac delta function but i don´t get a constant as an output. Is this correct? or am i using it wrongly? What should I expect to be the output of this function???
In case you need it, this is part of my code in CUDA C:
int main()
{
cufftComplex *y,*h;
cufftComplex *h_d;
int size = NX* BATCH * sizeof(cufftComplex);
h = (cufftComplex*) malloc (size);
y = (cufftComplex*) malloc (size);
for (int m = 0; m < NX*BATCH; m++)
{
h [m].x = (float) 0;
h [m].y = (float) 0;
}
h[20].x=(float)1;
cufftHandle plan;
cudaMalloc((void**)&h_d, size);
cudaMemcpy (h_d, h, size, cudaMemcpyHostToDevice);
//Create a 1D FFT plan.
cufftPlan1d(&plan, NX, CUFFT_C2C, BATCH);
//Use the CUFFT plan to transform the signal in place.
cufftExecC2C(plan, h_d, h_d, CUFFT_FORWARD);
cudaMemcpy (y, h_d, size, cudaMemcpyDeviceToHost);
// Destroy the CUFFT plan.
cufftDestroy(plan);
cudaFree(h_d);
for (int n = 0; n <NX*BATCH; n++)
{
printf("h_d[%i] = %f\n",n, y[n].y);
}
free (y);
free (h);
return(0);
Hello, i am working in a project in a code with CUFFT but i don’t really know what it does. I have tried to transform a dirac delta function but i don´t get a constant as an output. Is this correct? or am i using it wrongly? What should I expect to be the output of this function???
In case you need it, this is part of my code in CUDA C:
int main()
{
cufftComplex *y,*h;
cufftComplex *h_d;
int size = NX* BATCH * sizeof(cufftComplex);
h = (cufftComplex*) malloc (size);
y = (cufftComplex*) malloc (size);
for (int m = 0; m < NX*BATCH; m++)
{
h [m].x = (float) 0;
h [m].y = (float) 0;
}
h[20].x=(float)1;
cufftHandle plan;
cudaMalloc((void**)&h_d, size);
cudaMemcpy (h_d, h, size, cudaMemcpyHostToDevice);
//Create a 1D FFT plan.
cufftPlan1d(&plan, NX, CUFFT_C2C, BATCH);
//Use the CUFFT plan to transform the signal in place.
cufftExecC2C(plan, h_d, h_d, CUFFT_FORWARD);
cudaMemcpy (y, h_d, size, cudaMemcpyDeviceToHost);
// Destroy the CUFFT plan.
cufftDestroy(plan);
cudaFree(h_d);
for (int n = 0; n <NX*BATCH; n++)
{
printf("h_d[%i] = %f\n",n, y[n].y);
}
free (y);
free (h);
return(0);