Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: cache optimization

Author: Robert Hyatt

Date: 08:38:48 06/09/01

Go up one level in this thread


On June 09, 2001 at 04:30:54, Johan Melin wrote:

>On June 08, 2001 at 12:52:55, martin fierz wrote:
>
>>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
>
>Call me lazy, but unless there is something nasty going on, I assume that the
>busy end of the stack is already in the cache.
>
>/Johan Melin


All depends on the program.  And the architecture (how many registers, etc.)




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.