Getting Started
This lab is a pair-programming project. The code you write must run
on wilkes.cs.hmc.edu, a 64-bit x86_64 architecture machine. You
can work elsewhere, but you will need to ensure that your code runs
on wilkes and that it passes all tests there.
Create Working Directory and Unpack Starter Code
We provide starter code in the form of a tar archive called
cachelab-handout.tar, which you can get from the usual places.
Create a directory to do your work in and make sure that the
directory's permissions are set so no one else can see your work.
For example, assuming your already have a cs105 directory, you
might run
cd ~/cs105
mkdir lab07
chmod 700 lab07
The chmod command changes modes; in this case making it so
that only you (the logged-in user) will be able to read or write
files in the lab07 directory.
cd into your working directory, and run
tar xvf cachelab-handout.tar
to unpack the tar archive into a directory called
cachelab-handout.
Familiarize Yourself with the Starter Code
For this lab you will be modifying two files, csim.c (for the
cache-simulator part and trans.c (for the
matrix-optimization part.
The included Makefile builds both files for you when you run make.
README- An overview of the contents of the
tararchive. tracesdirectory- Contains a collection of memory trace files you'll use with your cache simulator.
cachelab.candcachelab.h- Required helper functions and header file.
csim-ref- A reference implementation of the cache simulator.
test-csim- A testing program for your cache simulator.
driver.py- The driver program that runs
test-csim test-trans.c- A testing program for your matrix transposition.
driver.py- A testing program for both parts of the assignment (it runs
test-csimandtest-trans).
(There are a few other helper files as well, e.g., a Makefile. See the
README for more.)
Reference Trace Files
To test and debug the cache simulator you will build, you can run it
using the reference trace files in the traces directory. These
files will also be used to evaluate the correctness of your
simulator.
Each trace file describes the memory references made when a program was run. They were generated by the memory-debugging program Valgrind, which you may have used in CS 70.
Valgrind memory traces have the following form:
I 0400d7d4,8
M 0421c7f0,4
L 04f6b868,8
S 7ff0005c8,8
Each line denotes one or two memory accesses. The format of each line is
operation address ,size
The field denotes the type of memory access.
I |
instruction load |
L |
data load |
S |
data store |
M |
data modify (data load, then data store) |
Notice that while there is no space character () at the start of
instruction-load (I) lines, the other operations always have a
space character at the start of the line.
The field specifies a 64-bit hexadecimal memory
address.
The field specifies the number of bytes accessed by the
operation.
Generating Trace Files
Trace files are created with a set of special arguments to
valgrind; in particular, using its lackey tool to trace memory
and log it to stdout.
As an example, running
valgrind --log-fd=1 --tool=lackey -v --trace-mem=yes ls -l
causes Valgrind to run lackey in verbose mode and set to trace
memory; execute the program ls with its -l flag; captures a
trace of each of its memory accesses in the order they occur; and
prints each trace to stdout.
Adding > tracefile.txt would put the output into the file
tracefile.txt, and you could then use it with your cache
simulator.
(When logged in, completion status appears here.)