More Pipelining Topics!: Notes Originally by Matt Johnson
More Pipelining Topics!: Notes Originally by Matt Johnson
More Pipelining Topics!: Notes Originally by Matt Johnson
Caches!
Conceptual Questions: Why do we cache? What is the end result of our
caching, in terms of capability?
What are temporal and spatial locality? Give high level examples in software of
when these occur.
Break up an address:
Tag
Index
Offset
Offset: “column index” (O bits)
Index: “row index” (i bits)
Tag: “cache number” that the block/row* came from. (T bits) [*difference?]
Segmenting the address into TIO implies a geometrical structure (and size)
on our cache. Draw memory with that same geometry!
Cache
Memory
2O
columns
Tag
=
0
i
2
Tag,
2i+O
Bytes
of
Valid,
&
rows
2T
Cache
Data!
Dirty
bits
Tag
=
1
Images
Tag
=
2
CS 61C Spring 2010 TA: Michael Greenbaum
Section 114/118 Week 13 – Caches cs61c-tf@inst.berkeley.edu
notes
originally
by
Matt
Johnson
Cache Vocab:
Cache hit – found the right thing in the cache! Booyah!
Cache miss – Nothing in the cache block we checked, so read from
memory and write to cache!
Cache miss, block replacement – We found a block, but it had the wrong
tag!
Cache Exercises!
C1: Fill this one in… Everything here is Direct-Mapped!
Address Cache Block Tag Bits Index Offset Bits per
Bits Size Size Bits Bits Row
16 4KB 4B
16 16KB 8B
32 8KB 8B
32 32KB 16B
32 64KB 16 12 4 146
32 512KB 5
64 64B 14
64 2048KB 1069
You know you have 1 MiB of memory (maxed out for processor address size)
and a 16 KiB cache (data size only, not counting extra bits) with 1 KiB blocks.
a) What is the T:I:O breakup for the cache (assuming byte addressing)?
b) Calculate the hit percentage for the cache for the line marked “Line 1”.
c) Calculate the hit percentage for the cache for the line marked “Line 2”.
Now a completely different setup… Your cache now has 8-byte blocks and 128
rows, and memory has 22 bit addresses. The ARRAY_SIZE is 4 MiB and A starts at
a block boundary.
a) What is the T:I:O breakup for the cache (assuming byte addressing)?
b) What is the cache size (data only, no tag and extra bits) in bytes?
d) Given the STRETCH size from (c), what is the # of cache misses?
e) Given the STRETCH size from (c), if A does not start at a block boundary,
roughly what is the # of cache misses for this case to the number you
calculated in question (d) above? (e.g., 8x, 1/16th)