Effacer les filtres
Effacer les filtres

different result between gpuArray / matrix

4 vues (au cours des 30 derniers jours)
emar
emar le 2 Mai 2017
Commenté : Joss Knight le 13 Mai 2017
Hello, I tried to compare the result between two codes two inputs with the same function:
function local_sum_A = local_sum(A,m,n)
B = padarray(A,[m n]);
s = cumsum(B,1);
c = s(1+m:end-1,:)-s(1:end-m-1,:);
s = cumsum(c,2);
local_sum_A = s(:,1+n:end-1)-s(:,1:end-n-1)
It's a function that i found on Matlab. When i compile :
A=rand(20);
s=local_sum(A,21,22);
gpuDevice;
A2=gpuArray(A);
s2=local_sum(A2,21,22);
I have two different results ( difference by a factor 1e-13), but I do a lot of calculations after, so the difference become important (1e-02).
Could you tell me why there is such difference ?
Thank you in advance
  2 commentaires
Adam
Adam le 2 Mai 2017
gpu does calculations differently to the cpu so there will be different levels of accuracy. 1e-13 is insignificant, but the more calculations you do certainly the more the error will inevitably accumulate.
Joss Knight
Joss Knight le 13 Mai 2017
To be clear, the error here is between the computed result and the theoretically correct result, not between the CPU result and the GPU result. The CPU result is no more correct than the GPU one. All floating point computation has error, and this error always accumulates the more operations you do.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur GPU Computing in MATLAB dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by