Path: news.mathworks.com!newsfeed-00.mathworks.com!kanaga.switch.ch!switch.ch!newsfeed00.sul.t-online.de!t-online.de!news.nask.pl!news.nask.org.pl!newsfeed.pionier.net.pl!news.dialog.net.pl!not-for-mail
From: "uC" <bla.bla@uc.uc>
Newsgroups: comp.soft-sys.matlab
Subject: FOR loops performance - 32bit vs 64 bit Matlab
Date: Sat, 2 Aug 2008 10:58:54 +0200
Organization: Dialog Net
Lines: 37
Message-ID: <g717k3$kb3$1@news.dialog.net.pl>
NNTP-Posting-Host: dynamic-78-8-129-31.ssp.dialog.net.pl
Mime-Version: 1.0
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
X-Trace: news.dialog.net.pl 1217667523 20835 78.8.129.31 (2 Aug 2008 08:58:43 GMT)
X-Complaints-To: abuse@dialog.net.pl
NNTP-Posting-Date: Sat, 2 Aug 2008 08:58:43 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512
Xref: news.mathworks.com comp.soft-sys.matlab:483262



Hi all,

Yesterday I have written tha post entitled "density matrix conversion - 
vectorization" where I needed some help regarding vectorization to improve 
the speed. It turned out that in fact I don't need to vectorize it and 
performance problem is somewhere else.

There are three loops:

for n=1:col_no
        for m=1:row_no
            for k=1:D(m, n)
                [SOME SIMPLE ARITHMETIC OPERATIONS]
            end
            if rand() < D(m, n)-floor(D(m, n))
               [SOME SIMPLE ARITHMETIC OPERATIONS]
            end
        end
    end
end

On 32 bit system (XP Pro) and Matlab (2006a) it takes ~17 seconds to finish 
these operations but on 64 bit (Win 2003 Serv. End. Ed.) and 64 bit Matlab 
(2007b) it takes 370 secons!!!

Now the most interesting... when I substitute exact numbers for "col_no" and 
"row_no" (6700 and 7100 in tested case) 64 bit Matlab needs only 8 seconds 
to finish, when on 32 bit one timings remains almost untouched!

32 bit machine is dual core Athlon64x2 2GHz with 2 GB RAM
64 bit machine is dual socket dual core Opteron 2218 2.6 GHz with 8 GB RAM

Does anyone have an idea if it is a Matlab bug or anything else?

Best wishes,
uC