Transcript pptx/plain

The Lord of the Cache
Project 3
Caches
•Three common cache designs:
• Direct-Mapped
• store in exactly one cache line
•Fully Associative
• store in any cache line
•Set Associative
• store in a small set of cache
lines
Direct-mapped Cache
Tag
Index
V
Byte offset
Offset
Tag
Block
=
word select
hit?
data
32bits
Fully Associative Cache
Tag
V Tag
=
Offset
Block
=
=
line select
64bytes
word select
32bits
hit?
data
=
2-way Set Associative Cache
Tag
Index Offset
=
=
line select
64bytes
word select
hit?
data
32bits
3-way Set Associative Cache
Tag
Index Offset
=
=
=
line select
64bytes
hit?
word select
data 32bits
Cache Misses
• Cold (aka Compulsory) Miss
• Line is being referenced for the first time
• Avoid by prefetching
• Conflict Miss
• Line was in the cache, but has been evicted because
of another access with the same index
• Avoid by increasing cache associativity
• Capacity Miss
• line was in the cache, but has been evicted because
the cache is too small
• Avoid by increasing cache size
Cache Write Policies
• Write-Through
• Updates to a block in cache are immediately
written through to memory
• Write-Back
• Updates to a block in cache are only written
back to memory when that block is evicted