DTolm / VkFFT

Vulkan/CUDA/HIP/OpenCL/Level Zero/Metal Fast Fourier Transform library
MIT License
1.52k stars 91 forks source link

Zero padding in frequency domain for C2R transform broken ? #179

Closed nschaeff closed 3 months ago

nschaeff commented 3 months ago

Hello,

Zero padding in frequency domain does not seem to work for C2R

I'm doing:

onfig.FFTdim = 1;
config.size[0] = NFFT;
config.isInputFormatted = 1;            // out-of-place: separate buffer for input and output
config.inverseReturnToInputBuffer = 1;
config.inputBufferStride[0] = nfft;             // spatial data
config.bufferStride[0] = nfft/2 + 1;    // spectral data
config.performZeropadding[0] = 1;
config.frequencyZeroPadding = 1;
config.fft_zeropad_left[1] = Kmax+1;
config.fft_zeropad_right[1] = NFFT/2+1;   // Not sure what to put here?
config.numberBatches = howmany;    // an even number here
config.performR2C = 1;

Followed with VkFFTAppend(&shtns->vkfft_plan, 1, &launchParams);

If I do not set the frequencies between Kmax+1 and the end of the array to zero, I don't get the correct spatial data. Besides, the kernel takes exactly the same time with and without zero padding. Am I doing something wrong or is this not supported for C2R ?

By the way, I'm still using vkfft 1.2.33, I did not check if this is still true for the current version.

nschaeff commented 3 months ago

Arf, wrong index into the config.fft_zeropad* arrays... It works as expected. Sorry for the noise.