很多时候查不到本机cpu的cache信息。而了解这些信息,对于调优很有帮助
查看1级缓存cache大小
cat /sys/devices/system/cpu/cpu0/cache/index1/size
查看能访问这个1级缓存的cpu编号
cat /sys/devices/system/cpu/cpu0/cache/index1/shared_cpu_list
查看1级缓存cache line的大小
cat /sys/devices/system/cpu/cpu0/cache/index1/coherency_line_size
查看1级缓存cache set的数目
cat /sys/devices/system/cpu/cpu0/cache/index1/number_of_sets
查看2级缓存大小
cat /sys/devices/system/cpu/cpu0/cache/index2/size
查看其他级别的缓存可以更改index后的数字
cache_size = number_of_sets * cache_line_size * line_per_set
会导致cache miss率提高的vector size
criticalStride = number_of_sets * cache_line_size
参考:
http://*.com/questions/11413855/why-is-transposing-a-matrix-of-512x512-much-slower-than-transposing-a-matrix-of
http://www.7-cpu.com/cpu/SandyBridge.html
http://www.7-cpu.com/cpu/Westmere.html