From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f57db,df5754e791c11702 X-Google-Attributes: gidf57db,public X-Google-Thread: 1164f8,df5754e791c11702 X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1995-03-03 16:49:48 PST Newsgroups: comp.benchmarks,comp.sys.dec Path: bga.com!news.sprintlink.net!howland.reston.ans.net!vixen.cso.uiuc.edu!uwm.edu!caen!hearst.acc.Virginia.EDU!murdoch!fermi.clas.Virginia.EDU!gl8f From: gl8f@fermi.clas.Virginia.EDU (Greg Lindahl) Subject: Re: Cache, performance, and data structures used by simulations X-Nntp-Posting-Host: fermi.clas.virginia.edu Message-ID: Sender: usenet@murdoch.acc.Virginia.EDU Organization: Department of Astronomy, University of Virginia References: <3j0ljg$in7@agate.berkeley.edu> <3j54js$79i@peavax.eng.pko.dec.com> Date: Fri, 3 Mar 1995 16:52:18 GMT Xref: bga.com comp.benchmarks:2854 comp.sys.dec:9629 In article <3j54js$79i@peavax.eng.pko.dec.com>, John L. Henning 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.