Purpose:
By analyzing data gathered from real machines, you will learn the
details on the behaviors for their caches. This week's lab has no
real coding. You will NOT have to modify the given file cache.c.
This lab is due on Thursday 11/9 or Friday 11/10 by your discussion
session.
Task1:
Copy ~cs61c/lab8/cache.c into your lab
directory. The program cache.c accesses increasingly large arrays and
times how long these accesses take to determine characteristics of the
memory hierarchy for the machine it runs on. Skim the code in
cache.c. and answer the questions of the prelab.
It should help you understand the big picture. The following is a breakdown
of the code:
-
The first part is a procedure that uses a standard UNIX utility to get
an accurate measure of the user CPU time; this procedure may need to
vary depending on the machine you are running on.
-
The second part is a nested loop to read and write memory at different
strides and array sizes. To get accurate timing, this code is repeated
many times.
-
The third part times the nested loop overhead only so that it can be
subtracted from the overall measured times to see how long the
accesses were.
-
The last part prints the time per accesses as the size and stride
varies.
The output for this program is information for three topics of
interest: Size, Stride, and read+write. Size refers to the size of the
array (in bytes) you are testing with, NOT the size of the
cache. You'll have to figure out the cache size for yourself. Stride
refers to the how many bytes you are skipping for each access. For
example, if the stride is 4, you will access bytes 0, 4, 8, 12, and so
on from the array; skipping bytes 1, 2, 3, 5, 6, 7, 9, 10, 11, and so
on. read+write
refers to the amount of time needed to make the access to memory, in
ns. You'll have to figure out for yourself whether these times denote
hits or misses.
Task2:
Now, pick a machine. Run cache.c on the machine.
Plot the experimental results( on separate sheet) with the elapsed
time on the y-axis( round to nearest 100ns) and the memeory stride
( in bytes) on the x-axis. Label each line according to the size of
the array accessed. ( you don't need to turn this in, but plot the
graph and use it to answer questions )
Answer the following questions for each set of data:
- What is the name of the machine you are measuring?
- Approximately how fast is a cache hit?
- Approximately how fast is a cache miss?
- What is the SIZE in bytes of the FIRST LEVEL CACHE? Why?
- What is the BLOCK SIZE in bytes of the first level cache? Why?
- What is the set associativity on the cache for the machine?
- Does the machine have more than one level of cache? Why or why not?
Final Task:
Write up all your answers in a file called lab11.txt
Submit the file electronically by the time of your discussion session.
(only submit lab questions, prelab questions are to be done on paper and turned in during lab).
Last updated: 11/2 by Lan