[Gllug] code optimisations

Richard Jones rich at annexia.org
Wed Mar 23 13:42:05 UTC 2005


On Tue, Mar 22, 2005 at 10:42:12AM +0000, Nix wrote:
> On Mon, 21 Mar 2005, Pete Ryland uttered the following:
> > And by Cache efficiency, I mean things like organising memory usage to be
> > more sequencial if possible, e.g.:
> > 
> > for (i=0; i<1000000; i++)
> >   for (j=1; j<10000000; j++)
> >     a[i][j]++;
> > 
> > is *significantly* faster than:
> > 
> > for (j=1; j<10000000; j++)
> >   for (i=0; i<1000000; i++)
> >     a[i][j]++;
> > 
> > I don't think a compiler would optimise that type of thing.
> 
> Optimizations that can do that sort of code motion in some cases are on
> the cards for GCC-4.1. :)

Really?  I did my MSc thesis on this very subject :-)

We probably probably had a different approach to detecting the loops
though - we ran the program and examined a trace of memory access,
then used image recognition technology to "see" bad "patterns" of
memory access ...  It was interesting stuff, but not too practical.

Rich.

-- 
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Team Notepad - intranets and extranets for business - http://team-notepad.com
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list