From: gl8f@fermi.clas.Virginia.EDU (Greg Lindahl)
Subject: Re: Cache, performance, and data structures used by simulations
Date: Fri, 3 Mar 1995 16:52:18 GMT [thread overview]
Message-ID: <D4vIv6.4r7@murdoch.acc.Virginia.EDU> (raw)
In-Reply-To: 3j54js$79i@peavax.eng.pko.dec.com
In article <3j54js$79i@peavax.eng.pko.dec.com>,
John L. Henning <henning@i4get.enet.dec.com> wrote:
>Therefore, when you mention structures versus arrays I am reminded that I
>recently heard this very recommendation from a compiler developer who
>specializes in Alpha performance. His point was that almost all cache-based
>systems (not just Alpha) will tend to benefit from structures instead of
>arrays because you are more likely to use a full cache line when it is brought
>in.
As usual, any generalization of this sort is suspect. IF your program
happens to use all the information in the structure at once, then
locality could be improved relative to several arrays. IF your program
instead uses one element from each structure in an array of
structures, locality could be worse than having several arrays.
Instead of making up rules of thumb that can be wrong, it's better to
teach programmers about the real issues.
>The other point about multiple arrays is that they can cause cache thrashing.
>RISC systems have many fewer cache locations than main memory
>locations,
The same is true about non-RISC systems as well. Smart programmers
avoid power-of-two array sizes; smart compilers and linkers can do
much of the work as well, although putting arrays in malloc()ed
storage often leads to problems because malloc() likes to align things
on pages.
prev parent reply other threads:[~1995-03-03 16:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
1995-03-01 2:19 Cache, performance, and data structures used by simulations Peter Mardahl
1995-03-01 23:30 ` Vivek Sadananda Pai
1995-03-02 23:05 ` Nick Maclaren
1995-03-04 19:01 ` John L. Henning
1995-03-06 20:08 ` Vivek Sadananda Pai
1995-03-13 18:10 ` Paul Repacholi
1995-03-02 18:03 ` John L. Henning
1995-03-03 16:52 ` Greg Lindahl [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox