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 > >
I get weird results. I'm running Ubuntu 9.10. $ gcc -std=c99 -O3 cache.c -o cache cache.c: In function ‘main’: cache.c:76: warning: format ‘%5d’ expects type ‘int’, but argument 2 has type ‘long long unsigned int’ cache.c:87: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long long unsigned int’ $ ./cache 8 0.000 -0.000 16 -8398463032953819536247336566031312991144079686051738304471966669039044131696226829379239029189847822086924494434323213752880341006350643627443839933893593534174306352771682597911067433298676376261656732063193520999181558401504619215338835013847309758315074656817756377927909581189663689154228128221440770048.000 -0.000 32 673471.000 -3546708087032368915955808166786170270153026440174447921259530679463188870447462099420451834016308396836126150224828394415502900934890561646473632855796733445481167402961993728.000 64 -0.000 -0.000 128 4386232069291721889735509541787637405807919755643134523327764910072414863665047313350542797343329420530563038576640.000 -131931357829183911968937855162012273802567551268602401425480743944102328226184323665656750385578041448613881286965296761573714968002627576812191582953966300077162000745070667267722237290924429795183392756633890191020165687148544.000 256 2503611569399713855148608481271822535763266252234012757033381013768554066869594219726533588919968767093313447505134978978474018959540909750304742356025344.000 0.000 512 -93513432565550484438510715236443564573168515160919337181144690754754409573595642526779416692371271480790466936380617521548537175041417200460428583068428213762462397618732109092377183716006779661881573872191010623315024635533857877198920472330240.000 109512008301100481456024620353895874896748658409297314738534991754995542402778231387856941088234651429430984684839286860351126468724493479007598054415069698184269625285111917788286141298270190614651643613592088146877404825369138327564677283840.000 1024 191923198570832563990049271932142779609268025218941094751283485868219108703821277327345056713150758453463655966104481796286077182297588162420153411825539126913530793619420610560.000 -0.000 2048 -162819309274730042766000184290649529434208323906712420196011285131981290758643043996799018046221916953409758232126514849898367534701337185894069848408317327483176591020179941839072175320626228084914781022751672579028102891120970858350694388577584807936.000 0.000 4096 6061668001092683411032294693775044937673929957504593420229948438731788660315972745407394440239201644116169112554099867054939524888927116741546820718534066176.000 0.000 8192 0.000 21970836088519600003755032265160876833646536789476184571945655609415528972935079381217218300374409983567265039541677716406272.000 16384 -0.000 -0.000 32768 -10221624189657929071353503775365828355510148917915204126905015284741814585821516455281469397846102653544498988652817857816999026388231538822876858028074801569503027819935375026494300405462700053083024835388132270839469977292882849872393028896278572915908385742096618389241856.000 -0.000 65536 -0.000 0.000 8 512 $ cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 15 model : 2 model name : Intel(R) Pentium(R) 4 CPU 3.20GHz stepping : 9 cpu MHz : 3192.654 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 mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe pebs bts cid xtpr bogomips : 6385.30 clflush size : 64 power management: processor : 1 vendor_id : GenuineIntel cpu family : 15 model : 2 model name : Intel(R) Pentium(R) 4 CPU 3.20GHz stepping : 9 cpu MHz : 3192.654 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 mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe pebs bts cid xtpr bogomips : 6384.74 clflush size : 64 power management: $ gcc -v Using built-in specs. Target: i486-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.1-4ubuntu8' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu Thread model: posix gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu8) $ uname -a Linux littleone 2.6.31-14-generic #48-Ubuntu SMP Fri Oct 16 14:04:26 UTC 2009 i686 GNU/Linux -- Jason Grout --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---