Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: cache optimization

Author: martin fierz

Date: 09:52:55 06/08/01

Go up one level in this thread


hi bob,

>>Small, local variables in a function do not have cache problems.
>>The problem is when you have large tables with data. Then you need to worry
>>about how the data is organized.
>>
>>/Johan Melin
>
>But they _do_.  If you put 8 "small local variables" together in memory,
>whenever one is referenced the other 7 will be brought into cache at the same
>time.  When you use them, you use a cache cycle rather than a memory cycle.
>That basically means that the first variable costs you a memory cycle, the
>other 7 cost you nothing whatsoever to use.
>
>Small savings add up over millions of repetitions...

if i give you some sample code:

int somefunction(int p1)
 {
 int x1,x2,x3...x20;

 x1=something;
 /* can i assume that now x2..x8 are in my cache?*/
 x5=something;
 /* and now still x1..x8 because probably x5 was in cache?*/
 x12=something else;
 /* and now x12..x19 are in cache?*/
 }

are these comments reasonable? i know you wrote that there is no guarantee
that the variables will be allocated this way, but probably this is the best
guess i have!?

cheers
  martin






This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.