Lab 9: C Code and Cache Performance

Lab sessions Mon Mar 13 to Thu Mar 16

Lab written by Julie Zelenski

Learning goals

After this lab, you will have

  1. Experimented with the cache simulator features of the callgrind tool
  2. Practiced exam-like problems on the topic of cache design

Share a computer with somebody new. Tell each other how you will spend all that free time you'll have after you're finished with CS107.

Lab exercises

Get started

Clone the lab starter project using the command

hg clone /afs/ir/class/cs107/repos/lab9/shared lab9

This creates the lab9 directory which contains various Python source files and data files.

Pull up the online lab checkoff and have it open in a browser so you'll be able to jot down things as you go. At the end of the lab period, you will submit that sheet and have the TA check off your work.

1. Callgrind

The callgrind tool (part of the valgrind suite) is a code profiler that provides statistics about instruction counts and cache efficiency. If you haven't already, see our guide to callgrind for a quick introduction on how to run callgrind and use the annotator on the callgrind.out file to prepare the profiling report. Here are two experiments to run:

Read the cache miss counts from the report. What is the difference in the number of data cache (D1) misses when traversing by rows versus columns?

2. Exam practice problems

There are several extra problems in Monday's lecture slides that you can do for practic of cache problems for the final exam. The slides are here, start on slide number 39. The answers are in the slides (usually on the slide(s) following the question). You can also try out the practice exam on the exams page.

Check off with TA

Before you leave, be sure to submit your checkoff sheet (in the browser) and have lab TA come by and confirm so you will be properly credited for labIf you don't finish everything before lab is over, we strongly encourage you to finish the remainder on your own. Double-check your progress with self check.

Contents