GPU and CPU computing results different
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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);
0 commentaires
Réponses (2)
Ben Tordoff
le 13 Juil 2011
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
le 13 Juil 2011
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:
0 commentaires
Voir également
Catégories
En savoir plus sur GPU Computing dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!