From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8c8550b9f2cf7d40 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-10 12:23:20 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!uninett.no!newsfeed1.e.nsc.no!nsc.no!nextra.com!news4.e.nsc.no.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Is ther any sense in *= and matrices? References: <7visre2rwv.fsf@vlinux.voxelvision.no> From: Ole Kristensen Message-ID: Organization: Linux Private Site User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 148.122.14.228 X-Complaints-To: news-abuse@telenor.net NNTP-Posting-Date: Tue, 10 Jun 2003 21:23:20 MEST X-Trace: news4.ulv.nextra.no 1055273000 148.122.14.228 Date: 10 Jun 2003 21:24:30 +0200 Xref: archiver1.google.com comp.lang.ada:38928 Date: 2003-06-10T21:24:30+02:00 List-Id: Wesley Groleau writes: > > Yes, on modern hardware, having a pointer for each row of the matrix > > usually leads to slower code. The reason is that the indexing > > operation by multilply/add is actually faster than fetching a pointer > > from an array and then adding, thereby incurring an extra memory fetch > > and cache pollution. The above holds for large matrices, I haven't > > So Java's handling of arrays is inefficient > for matrices, even if bypassing the JVM by > compiling to native code? Can't speak for Java, but when I tried a 128**3 matrix in Ada and C++, the plain indexing scheme beat the clever pointer array by a significant amount. This was on a 1.8GHz Pentium 4. I cannot say anything definite about other systems, but in general, it pays to think a lot about memory access patterns on fast CPU's.