By Darryl Gove-Oracle on Feb 03, 2012
If you are on a SPARC system you can get cache size information using the command
fpversion, which is provided with Studio:
$ fpversion A SPARC-based CPU is available. Kernel says main memory's clock rate is 1012.0 MHz. Sun-4 floating-point controller version 0 found. An UltraSPARC chip is available. Use "-xtarget=sparc64vii -xcache=64/64/2:5120/256/10" code-generation option.
The cache parameters are output exactly as you would want to pass them into the compiler - for each cache it describes the size in KB, the line size in bytes, and the associativity.
fpversion doesn't exist on x86 systems. The next best thing is to use prtpicl to output system configuration information, and inspect that output for cache size. Here's the cache output for the same SPARC system using
$ prtpicl -v |grep cache :l1-icache-size 0x10000 :l1-icache-line-size 0x40 :l1-icache-associativity 0x2 :l1-dcache-size 0x10000 :l1-dcache-line-size 0x40 :l1-dcache-associativity 0x2 :l2-cache-size 0x500000 :l2-cache-line-size 0x100 :l2-cache-associativity 0xa