CS 105

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 may work elsewhere, but you will need to ensure that your code runs on wilkes and that it passes all tests there.

Getting the Starter Code

The starter code for this lab is already available on the server in the directory /cs/cs105/labs/lab7-cachelab. The first step is to get your own copy of the code to work on.

Run

mkdir -p ~/cs105

to create a cs105 directory to work in (skip if you already have one).

Then run

cd ~/cs105
cp -ai /cs/cs105/labs/lab7-cachelab .
cd lab7-cachelab

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 tar archive.
traces/ (directory)
Contains a collection of memory trace files you'll use with your cache simulator.
cachelab.c and cachelab.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-csim and test-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 operation 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 address field specifies a 64-bit hexadecimal memory address.

The size 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.

To Complete This Part of the Assignment

You'll know you're done with this part of the assignment when you've done all of the following:

(When logged in, completion status appears here.)