Hi, I’m new in CUDA, and I’m trying to use cufft on image filtering.
I made the program which performs fft just R2C and C2R(forward and inverse).
But, result is weird and values are very large (e.g. 169622.67, 249807.91, 487279.47…)
What is wrong with this?
Below is the code: (textureData is just RGB image, float-scaled)
cufftHandle plan_fwd, plan_inv;
cufftReal *dev_real;
CUDA_HANDLE(cudaMalloc((void **)&dev_real, sizeof(cufftReal) * textureData.size()));
CUDA_HANDLE(cudaMemcpy(dev_real, &textureData.front(), sizeof(cufftReal) * textureData.size(), cudaMemcpyHostToDevice));
cufftComplex *dev_complex;
CUDA_HANDLE(cudaMalloc((void **)&dev_complex, sizeof(cufftComplex) * width * height * (3 / 2 + 1)));
CUDA_HANDLE(cufftPlan3d(&plan_fwd, height, width, 3, CUFFT_R2C));
CUDA_HANDLE(cufftExecR2C(plan_fwd, dev_real, dev_complex));
CUDA_HANDLE(cufftDestroy(plan_fwd));
CUDA_HANDLE(cufftPlan3d(&plan_inv, height, width, 3, CUFFT_C2R));
CUDA_HANDLE(cufftExecC2R(plan_inv, dev_complex, dev_real));
CUDA_HANDLE(cufftDestroy(plan_inv));
CUDA_HANDLE(cudaMemcpy(&textureData.front(), dev_real, sizeof(GLfloat) * textureData.size(), cudaMemcpyDeviceToHost));
CUDA_HANDLE(cudaFree(dev_real));
CUDA_HANDLE(cudaFree(dev_complex));
CUDA_HANDLE(cudaThreadSynchronize());