Martin Albrecht wrote: > Hi there, > > in the thread > > http://is.gd/4EMT8 > > David and I agreed that M4RI should have a better, more robust and cross- > platform mechanism to check for cache sizes. > > Thus I wrote a little C program to check for the cache size using timings of > random-ish memory access. > > The program is available at: > > http://sage.math.washington.edu/home/malb/cache.c > > On my Core 2 Duo and on my Opteron (both running Linux 64-bit) it does report > correct sizes. So far so good. On sage.math it reports L3 cache size instead > of L2 but I guess that this is probably what we want anyway (well, L2 is 3MB > which I don't check explicitly since I only check powers of two) > > I'd appreciate if those people on this list who have different hardware or > software (OSX, Solaris, PPC, Sparc) could compile the program and report back > whether the program reports correct sizes for them. To compile and run: > > gcc -std=c99 -O3 cache.c -o cache > ./cache > > Cheers, > Martin
Here's a few machines - two SPARC and a Xeon, all running Solaris or OpenSolaris. The numbers do not appear to bear a lot of relation to the cache size. I'd say whatever is quickest is what matters, even if the best results are not obtained with code supposidly optimised for the cache size of the processor. I suspect with modern processors, things may not be as simple as one might like. I'll post some data for another 4 or so machines tomorrow. 1) Hardware: Sun Ultra 27 CPU: Intel Xeon Processor W3580 (Quad-Core 3.33 GHz, 6.4 GT/sec QuickPath Interconnect, 1333 MHz DDR3 Memory Controller, 8 MB L3 Cache) http://ark.intel.com/Product.aspx?id=39723 Operating system. OpenSolaris 06/2009. drkir...@hawk:~$ gcc -std=c99 -O3 cache.c drkir...@hawk:~$ ./a.out 8 0.009 2.924 16 0.017 1.970 32 0.035 2.021 64 0.078 2.229 128 0.206 2.632 256 0.453 2.195 512 1.012 2.234 1024 5.923 5.856 2048 14.780 2.495 4096 29.285 1.981 8192 72.979 2.492 16384 281.320 3.855 32768 934.170 3.321 65536 2074.713 2.221 512 16384 2) Sun Blade 2000 2 x 1200 MHz UltraSPARC III+ processors, each with 8 MB cache Operating system Solaris 10 update 7. drkir...@swan:[~] $ ./a.out 8 0.044 1.985 16 0.216 4.870 32 0.433 2.001 64 0.868 2.006 128 2.893 3.334 256 7.491 2.590 512 15.674 2.092 1024 31.898 2.035 2048 66.548 2.086 4096 139.087 2.090 8192 289.162 2.079 16384 1224.286 4.234 32768 7428.131 6.067 65536 15028.110 2.023 8 64 16384 3) Sun T5240 (t2.math), with a pair of Sun T2+ processors, 8 cores per processor. 4 MB Integrated L2 cache per processor. 8 0.082 1.994 16 0.386 4.728 32 1.206 3.127 64 2.411 2.000 128 4.823 2.000 256 9.643 2.000 512 19.278 1.999 1024 38.572 2.001 2048 77.181 2.001 4096 163.015 2.112 8192 764.029 4.687 16384 3025.689 3.960 32768 6819.197 2.254 65536 13775.278 2.020 8 8192 --~--~---------~--~----~------------~-------~--~----~ To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---