GPU and CPU computing results different

1 次查看(过去 30 天)
Hi, I have tested FFT2 function for both workspace and GPU data. The difference in result is very small but still disturbs me. Does anyone have why that is and any suggested solutions?
Thanks,
im = phantom(512);
k = fft2(im);
kim = fft2(gpuArray(complex(im)));
OK = isequal(k,kim);

回答(2 个)

Ben Tordoff
Ben Tordoff 2011-7-13
if you look at the magnitude of the difference compared to the magnitude of the values, it is pretty small:
>> max(max(gather(abs(k-kim)))) / max(max(abs(k)))
ans = 1.0144e-016
Infact, it is similar to the limit of accuracy for any calculation on the input:
>> eps(max(max(abs(im))))
ans = 2.2204e-016
(the two are not measuring the same thing, but hopefully you get the idea).
The CPU and GPU implementations of FFT/FFT2 are necessarily quite different in order to take best advantage of the hardware. The GPU version needs to be massively parallel. I believe that the difference you are seeing is well within what one should expect from any two different implementations of FFT/FFT2.
Whilst we can aspire to identical results from the CPU and GPU versions, sometimes it simply isn't possible without massive compromises on speed.

Daniel Shub
Daniel Shub 2011-7-13
When you say very small, do you mean 1e-16 small? If so, that is close to the precision of double precision numbers. Check out:

类别

Help CenterFile Exchange 中查找有关 GPU Computing 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by