Author: Andreas Guettinger
Date: 04:22:30 01/02/03
Go up one level in this thread
On January 01, 2003 at 21:55:10, Russell Reagan wrote:
>On January 01, 2003 at 19:13:20, Uri Blass wrote:
>
>>1)why it should not matter even with no optimization?
>>
>>Correct me if I am wrong but it seems that with the fastest way you need more
>>memory because you need to remember also x so theoretically it is possible that
>>the computer will crush because of memory problem in the first case when it does
>>not crash in the second case.
>
>It will be in a register if it's a double word sized value. If not it will be in
>the cache. Memory has nothing to do with this problem.
>
>>2)Suppose that you try optimization for minimize size and not maximal speed
>>Am I correct to assume that the compiler will not define the varaible x?
>
>If the data is used often, then it will be in the cache and there will be no
>memory accessed at all. If it is not used often, then it is not a critical part
>of the program most likely (in terms of speed). Besides, the cpu doesn't think
>in terms of "variables". The compiler won't have anything to do with whether or
>not this value is in the cache. That's a hardware thing, not a software thing.
Ok, thanks.
So for another example, when I refer to a integer in a struct several times,
i.e.
if (movelist.move[i].flag == 3)
say A) 1-5 times, B) 5-10 times, C) >10 times (i.e. in a loop)
then should I put it in a local variable first (for cases A, B, C), so the
compiler keeps it in the cash, or will the compiler keep it in the cash anyway?
(register) int loflag = movelist.move[i].flag
(do { )
if (loflag == 3)
....
(while()} )
regards Andy
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.