Beruflich Dokumente
Kultur Dokumente
Fully
associative
Allow
a given block to go in any cache entry Requires all entries to be searched at once Comparator per entry (expensive)
n-way
set associative
Each
CS-281 Page 1
CS-281 Page 2
Spectrum of Associativity
For
CS-281 Page 3
Associativity Example
Compare
Direct
4-block caches
mapped
Block address 0 8 0 6 8
Cache index 0 0 0 2 0
Hit/miss miss miss miss miss miss 0 Mem[0] Mem[8] Mem[0] Mem[0] Mem[8]
Mem[6] Mem[6]
CS-281 Page 4
Associativity Example
2-way
set associative
Cache index 0 0 0 0 0 Hit/miss miss miss hit miss miss Cache content after access Set 0 Set 1 Mem[0] Mem[0] Mem[8] Mem[0] Mem[8] Mem[0] Mem[6] Mem[8] Mem[6]
Block address 0 8 0 6 8
Fully associative
Block address 0 8 0 6 8 Hit/miss miss miss hit miss hit Mem[0] Mem[0] Mem[0] Mem[0] Mem[0] Cache content after access Mem[8] Mem[8] Mem[8] Mem[8]
Mem[6] Mem[6]
CS-281 Page 5
Simulation
1-way:
CS-281 Page 6
CS-281 Page 7
Replacement Policy
Direct
non-valid entry, if there is one Otherwise, choose among entries in the set
Least-recently
Choose
used (LRU)
- Simple for 2-way, manageable for 4-way, too hard beyond that
Random
Gives
CS-281 Page 8
Multilevel Caches
Primary Level-2 Main
Small,
Larger,
memory services L-2 cache misses Some high-end systems include L-3 cache
CS-281 Page 9
base CPI = 1, clock rate = 4GHz Miss rate/instruction = 2% Main memory access time = 100ns
With
Miss
CS-281 Page 10
Example (cont.)
Now
Access
Penalty
CPI
CS-281 Page 11
cache
on minimal hit time
L-2
cache
Focus
on low miss rate to avoid main memory access Hit time has less overall impact
Results
L-1
cache usually smaller than a single cache L-1 block size smaller than L-2 block size
CS-281 Page 12
behavior
CS-281 Page 13