フィルターのクリア

GPU and CPU computing results different

1 回表示 (過去 30 日間)
peter
peter 2011 年 7 月 13 日
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.
  1 件のコメント
John Melonakos
John Melonakos 2011 年 7 月 24 日
Well put!

サインインしてコメントする。


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 Center および File ExchangeGPU Computing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by