Determing cache sizes -- request for testing

Don nospam at nospam.com.au
Wed Sep 10 05:20:10 PDT 2008


bearophile wrote:
> Don:
>> To implement efficient memory-intensive operations (memcpy, array 
>> operations, matrix multiplication, etc), you really need to know the 
>> sizes of the data caches.
> 
> Your code is surely useful, but take a look at "cache oblivious data structures":
> http://en.wikipedia.org/wiki/Cache-oblivious_algorithm

Yes, it's a good approach, but it doesn't help for something like memcpy.

> I presume your code doesn't work at compile time,

Correct.

> so I presume you have to run your code once, save the results on disk, and then re-start the compilation to use those values to compute the tuning compile-time constants of the data structures :-)

No. That wouldn't be much use.
The cache size is simply used as a parameter at run-time. It's only the 
linesize which has a major impact on optimal code -- but it's 32 or 64 
bytes on every system which I know of. So it's possible to deal with it 
at compile time, too.

You can, in fact, just plug the L1 cache size into your cache-oblivious 
algorithm as the cut-off level, significantly improving performance.

> On this Intel the data looks almost correct (I have used the second version of your code), but there isn't level 3 cache, and the RAM size is 2 GB.

The value shown for L3 should be greater than the memory size, if there 
is no L2 cache. (you never fall out of the L3 cache). So it's correct.



More information about the Digitalmars-d mailing list