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);
댓글 수: 0
답변 (2개)
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
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:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 GPU Computing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!