Determing cache sizes -- request for testing

Manuel König manuelk89 at gmx.net
Wed Sep 10 03:15:11 PDT 2008


Am Wed, 10 Sep 2008 11:41:40 +0200
schrieb Don <nospam at nospam.com.au>:

> To implement efficient memory-intensive operations (memcpy, array 
> operations, matrix multiplication, etc), you really need to know the 
> sizes of the data caches.
> Although most modern CPUs provide methods to determine the sizes of 
> their built-in caches, it's a complete pigs breakfast. There are 
> multiple complicated methods, and documentation is scant.
> I've written some code to make this mess usable, and provide what you 
> really want. For each level of cache, the code provides size in KB,
> ways of associativity, and the cache line size.
> 
> The attached code should eventually become part of std.cpuid, and an 
> equivalent module in Tango. But, it needs significant further testing.
> 
> Please compile and run the code, and report the results. Any results 
> would be useful, but particularly valuable would be:
> (1) Multicore AMD machines;
> (2) Early AMD machines (K6 or earlier).
> (3) Early Intel machines;
> (4) anything from another manufacturer.
> (5) any crashes or obvious bugs.
> 
> Public domain.
> 

Should the Pentium4 HyperThreading Technology count as two cores?
$ ./cache
Vendor string:    GenuineIntel
Processor string: Intel(R) Pentium(R) 4 CPU 3.00GHz
Signature:        Family=15 Model=2 Stepping=9
Features:         MMX FXSR SSE SSE2 HTT
Multithreading:   1 threads / 1 cores

Family=F Model=2 Stepping=9
Data caches:
Level 1 size=8K, ways=2 linesize=32
Level 2 size=512K, ways=8 linesize=64
Level 3 size=4194303K, ways=1 linesize=64

$  cat /proc/cpuinfo 
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 15
model           : 2
model name      : Intel(R) Pentium(R) 4 CPU 3.00GHz
stepping        : 9
cpu MHz         : 2992.567
cache size      : 512 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 1
apicid          : 0
initial apicid  : 0
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 2
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe pebs
bts cid xtpr 
bogomips        : 5990.83 clflush size    : 64
power management:

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 15
model           : 2
model name      : Intel(R) Pentium(R) 4 CPU 3.00GHz
stepping        : 9
cpu MHz         : 2992.567
cache size      : 512 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 1
apicid          : 1
initial apicid  : 1
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 2
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe pebs
bts cid xtpr 
bogomips        : 5986.89 clflush size    : 64
power management:



More information about the Digitalmars-d mailing list