Cachetool Plugin for Valgrind

   by Vince Weaver  and I-Chun Li
      vince _at_ deater.net  , yohowo _at_ gmail.com
      

Background
~~~~~~~~~~

This plugin was designed to interface with a tool that was to aid
in investigating Cache Conscious Data Placement. 
The eventual goal was to gather memory traces from real programs,
and then test various re-arrangements of memory layouts on the fly to see if
we could improve cache behavior.

CCDP is a very hard problem, and for now we've moved on to other work. I've
had some inquiries about the valgrind tool developed for this, so I am
posting this here now for that reason.

The tool was originally designed to get its input from FIT, the flexible
instrumentation toolkit. FIT is an open-source ATOM-like static
instrumentation package, which sadly is not maintained anymore.

We instrumented binaries to report all memory reads and writes (for data
cache), all Basic Blocks (for instruction cache) and all memory
allocations/frees (because we were sorting memory accesses to see if they
were heap, data or stack). These values were put out to a named pipe from
the instrumented program, and then read in by the cachetool in a separate
process.

Due to the memory overhead of fit, we decided to move to valgrind. So with
the help of MEng student I-Chun Li we worked on taking the fit interface and
making a valgrind plugin that would generate the same output.

Format of the trace file
~~~~~~~~~~~~~~~~~~~~~~~~
  I-Chun's MEng thesis describes this in great depth, I'll try
  to get a copy available.  For now the "trace_format.h" file
  is unfortunately your best bet at understanding it.

Accuracy
~~~~~~~~

  It turns out we are only instrumenting the Superblock, not the
  individual basic blocks, so the instruction cache data generated
  is probably wrong.  This can be fixed, I just haven't had time
  recently.


How to Use
~~~~~~~~~~

  After installing (see below) run
  
  valgrind --tool=cachetool --tracefile=out.trace /bin/ls
  
  where /bin/ls is the program you want to trace
  and out.trace is the tracefile to generate.
  
  WARNING!  The trace file can rapidly become gigabytes in size!
  
  We recommend you write to a named pipe (created with mkfifo) and
  have your cache simulator/etc run at the same time, reading in from
  the fifo.  The sample script "run_valgrind.sh" included gives
  an example of how you can do this.



Compiling
~~~~~~~~~

First download the newest version of valgrind from www.valgrind.org.
   Version 3.2.0 is the newest version tested
   
Unpack, and configure with:
    ./configure --prefix=/fusion/scratch2/vince/valgrind/
That installs it in your own subdirectory, as not to interfere with the
system-wide valgrind install.

Compile with:
    make
   
and then 
    make install
    
Copy this cachetool directory into place.

* Edit the file "configure".  Search for the string none/docs/Makefile
    and immediately after it put: cachetool/Makefile

* go into the cachetool director and run make; make install

# leftover.. what was this for?
# cd .. && /bin/sh ./config.status cachetool/Makefile depfiles
