Author: David Blackman
Date: 04:43:57 04/11/99
Go up one level in this thread
On April 10, 1999 at 14:51:58, Peter Fendrich wrote: >I haven't bothered too much about the performance effect of cashing, except some >basic rules I follow without knowing why... > >1) What happens if I access memory like this: > for (; *p; --p, --q) *q = *p; > will it be worse than this? > for (; *p; ++p, ++q) *q = *p It depends on your memory systems. On some there's no difference, on others the second is faster because the system predicts you will access forwards and preloads. >2) Are there any cashing differences by accessing with pointers vs arrays? Not much. >3) Does register declaration affect cashing in any way? Not much. Especially as most modern compilers ignore your register declarations anyway. >4) What are the overall performance win in doing the cashing right? For a small enough program, none. For a large program with "normal" characteristics, not a lot. But a worst case large program, can be around 30 times slower than one that uses the cache well, purely because of caching effects. First level cache around 6ns and main memory around 200ns for random access is reasonably common. To be sure in most cases you will just have to try several approaches, and choose the one that is fastest. If your program is supposed to work on other people's computers, try testing it on a few different models, because cache design varies quite a lot from machine to machine (sometimes even between supposedly identical boxes sold by the same dealer). >Thanks! > >//Peter
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.