News for hackers. Stuff that matters.
Re:Cache Rules Everything Around Me by joelthelion on Thursday January 31, 2013 @05:49AM (#5144386)
How do you reliably assess the cache behavior of your software? Thinking in terms of cache behavior is certainly very useful for making software that runs fast, but if you have no reliable to check what is actually happening, you're pretty much walking in the dark.
Re:Cache Rules Everything Around Me by cwzwarich on Thursday January 31, 2013 @06:00AM (#5144407)
Most CPUs have performance counters that let you determine when performance impacting events occur (e.g. pipeline flushes, reduced dispatch width, cache misses, etc.). In their simplest form they are a simple count, but there is usually some way to trigger an interrupt every N events rather than simply incrementing a counter, so that you can store the offending program counter somewhere for later aggregation. This functionality isn't always exposed very well by the OS, though. If you're using Linux then perf and oprofile are the standard ways to access performance counters.

Alternatively you can execute your code in a simulator with a cache model. Of course, this model won't actually match your hardware (unless you're using a serious cycle-accurate simulator), but it might be more insightful than performance counters alone. I don't know if any of the standard x86 emulators include a good cache model.

Re:Cache Rules Everything Around Me by zokier on Thursday January 31, 2013 @07:55AM (#5144713)
AMD has CodeAnalyst software which helps you analyze many aspects of your software performance, including cache behavior.

http://developer.amd.com/tools/heterogeneous-computing/amd-c...

Just from the front page I see a presentation "Cache Line Utilization with AMD CodeAnalyst Software" which touches the subject

http://developer.amd.com/wordpress/media/2012/10/2011_12_14_...

Re:Cache Rules Everything Around Me by forrestthewoods on Thursday January 31, 2013 @06:54AM (#5144544)
Intel VTune would be one option. Not a cheap but very high quality results.

http://software.intel.com/en-us/intel-vtune-amplifier-xe

Re:Cache Rules Everything Around Me by npsimons on Thursday January 31, 2013 @12:10PM (#5145964)
Cachegrind (part of Valgrind) will do this for you: http://valgrind.org/docs/manual/cg-manual.html
Re:Cache Rules Everything Around Me by ajuc on Thursday January 31, 2013 @06:53AM (#5144542)
kcachegrind on linux is great for that. It shows you your code annotated with number of cache misses per line of code, it also can show you callgraph with aggregated running time, etc. Internaly it uses callgrind.

Great tool for optimizing C/C++ code.

Re:Cache Rules Everything Around Me by mkilling on Thursday January 31, 2013 @05:55AM (#5144393)
Check out PAPI[1], it lets you examine CPU performance counters such as data- and instruction cache misses.

[1] http://icl.cs.utk.edu/projects/papi/wiki/Main_Page

Re:Cache Rules Everything Around Me by moconnor on Thursday January 31, 2013 @09:08AM (#5145006)
If you've got C/C++ (or Fortran!) code it's pretty straightforward - I work on a profiling tool that tracks things like CPU utilization and memory contention for HPC codes (http://www.allinea.com/products/map/). For single-machine programs you could just hack something together with the perf counters fairly easily.
Re:Cache Rules Everything Around Me by vonmoltke on Thursday January 31, 2013 @10:04AM (#5145255)
A clustered signal processing application I previously worked on used custom middleware with perfmon2[1] built into it for collecting performance counter data across all MPI nodes the application was running on. The framework for multiple nodes is not all that difficult.

[1] http://perfmon2.sourceforge.net/

Re:Cache Rules Everything Around Me by scaramanga on Thursday January 31, 2013 @05:59AM (#5144405)
indeed, or perf record -e cache-misses using the hardware performance counters
Re:Cache Rules Everything Around Me by duaneb on Thursday January 31, 2013 @06:04AM (#5144415)
There are a bunch of existing tools that use the underlying architecture's performance measuring capabilities to give you things like cache hits/misses and branch prediction performance; I really like oprofile (but it only runs on linux).

If you're using multiple threads, then you might have issues with false sharing, which is a bitch. Valgrind can help you there.