Professional Documents
Culture Documents
1 M. Safayani
Locality y
Temporal l T l locality: if you used some d t recently, you lit d data tl will likely use it again
Spatial locality: if you used some data recently, you p y y y y will likely access its neighbors
2 M. Safayani
Memory Hierarchy y y
The faster Th f t memories are more expensive per bit th i i than the slower memories and thus smaller.
3 M. Safayani
Memory Hierarchy y y
A you go f th capacity and latency increase As further, it dl t i
4 M. Safayani
Cache
Wh d caches work? Why do h k? assume that there are two-level memory No hierarchy: average access time for data = 300 cycles 32KB 1-cycle L1 cache that has a hit rate of 95%: average access time = 0.95 x 1 + 0.05 x (301) = 16 cycles l
CPU Word access cache 512 x 8 Main Memory 32K x 8 Block transfer
5 M. Safayani
6 M. Safayani
00000
1220 2340 3450 4560 5670 6710 777 27 Cache 6710 Index 000 Tag 00 Data 1220
00777 01000
Main memory
7 M. Safayani
Example ( p (direct-mapped) pp )
22(10110) 26(11010) 22(10110) 26(11010) 16(10000) 3 (00011) 16(10000) 18(10010)
8 M. Safayani
Example ( p (direct-mapped) pp )
22(10110) 26(11010) 22(10110) 26(11010) 16(10000) 3 (00011) 16(10000) 18(10010)
9 M. Safayani
Direct-mapped pp
10 M. Safayani
Direct-mapped pp
11 M. Safayani
12 M. Safayani
Block address=
13 M. Safayani
Direct-mapped pp
14 M. Safayani
15 M. Safayani
Handling Write
1. Write-through g Example: 10% of the instructions are stores the CPI without cache misses was 1.0 100 extra cycles on every write CPI becomes: 1.0 + 100 * 10% = 11 Solution: write buffer 2. Write-back
16 M. Safayani