Path: news.mathworks.com!not-for-mail
From: "Bobby Cheng" <bcheng@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Is it a bug or what is it?
Date: Tue, 29 Sep 2009 00:18:59 -0400
Organization: The MathWorks, Inc.
Lines: 86
Message-ID: <h9s1rg$j23$1@fred.mathworks.com>
References: <h9f9u0$elc$1@fred.mathworks.com> <h9hrk6$plp$1@fred.mathworks.com> <h9hs6v$46e$1@fred.mathworks.com> <h9iaad$p3i$1@fred.mathworks.com> <h9ic4f$ng6$1@fred.mathworks.com> <h9icla$aa$1@fred.mathworks.com> <h9ijb2$7dp$1@fred.mathworks.com> <h9in8n$198$1@fred.mathworks.com> <h9iocc$ge4$1@fred.mathworks.com> <h9is4a$r9p$1@fred.mathworks.com> <h9j0dl$enm$1@fred.mathworks.com> <h9p9a4$8gr$1@fred.mathworks.com> <h9q9m3$fe5$1@fred.mathworks.com>
Reply-To: "Bobby Cheng" <bcheng@mathworks.com>
NNTP-Posting-Host: vpn-client-228-53.mathworks.com
X-Trace: fred.mathworks.com 1254197936 19523 172.30.228.53 (29 Sep 2009 04:18:56 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 29 Sep 2009 04:18:56 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5843
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
Xref: news.mathworks.com comp.soft-sys.matlab:573543

Victor,

It would be helpful if you can show us what

cat /proc/cpuinfo

tells you about your processors.

It does seem like a bug. But until we have a way to reproduce it, it is hard 
to nail it down.

Thanks,
---Bob.

"Victor kasaksha" <viphe@mail.ru> wrote in message 
news:h9q9m3$fe5$1@fred.mathworks.com...
> Hello all, I apologize for the late answer:
>
> first:
> ----------------------------------------------------------------------------------------
> which mtimes
> built-in (/usr/local/matlab09b/toolbox/matlab/ops/@double/mtimes)  % 
> double method
>
> which rand
> built-in (/usr/local/matlab09b/toolbox/matlab/randfun/rand)
> -----------------------------------------------------------------------------------------
>
> second:
> -----------------------------------------------------------------------------------------
> consider/execute following code:
>
> n = 2000;
>
> a = 1e8; b = 2e8;
>
> A = a + (b - a).*rand(n,'single');
> B = a + (b - a).*rand(n,'single');
> A = mod(A,10);
> B = mod(B,10);
>
> maxnumcompthreads(1);
> Cs1 = A*B;
> Cd1 = double(A)*double(B);
>
> maxnumcompthreads(2);
> Cs2 = A*B;
> Cd2 = double(A)*double(B);
>
> Aint = uint32(A);
> Bint = uint32(B);
> Cint = uint32(zeros(n));
> i = 1;
> for j = 1:n
>    for k = 1:n
>        Cint(i,j) = Cint(i,j) + Aint(i,k)*Bint(k,j);
>    end
> end
>
> isequal(Cs1,Cs2)
> isequal(Cd1,Cd2)
>
> Cd1(1,100)
> Cd2(1,100)
> Cint(1,100)
>
> ans =
>     1 %-> single is O.K.
> ans =
>     0 %-> double is not O.K.
> ans =
>       32288 % one thread is wrong
> ans =
>       31504 % 2 threads and
> ans =
>       31504 % my own integer computation are equal,
>                   % so I think single thread product  is wrong
>
> ---------------------------------------------------------------------------
> third: code from above produces:
>
> md= 0/1999
> OK
>