Cuda fft vs. Matlab fft fft

Hello! I have a problem porting an algorithm from Matlab to C++. That algorithm do some fft’s over big matrices (128x128, 128x192, 256x256 images). Well, when I do a fft2 over an image/texture, the results are similar in Matlab and CUDA/C++, but when I use a noise image (generated randomly), the results in CUDA/C++ and the results in Matlab are very different!! It makes sense?

Can you further explain what you mean by very different? The CUDA results do not exactly match the Matlab ones but the error should only be visible way behind the comma. Actually your matrix size isnt really big. You also said you do “some” FFTs. How many are you running exactly and do they each use the results of previously performed FFTs? This could be a reason for decreasing accuracy over a couple of FFTs if this is what you mean.

Try giving Jacket, http://www.accelereyes.com , a spin with your FFT code. We did a lot of work to make CUFFT sync properly and efficiently with all the various ways you can call MATLAB FFT functions, like FFT2:

http://wiki.accelereyes.com/wiki/index.php/FFT2

Hope it helps!

-John

Solved. Im idiot!

I use NxM matrices (N!=M), and I switched the width and height of the matrix (matlab is column mayor, that’s confused me).

Solved. Im idiot!

I use NxM matrices (N!=M), and I switched the width and height of the matrix (matlab is column mayor, that’s confused me).