Caches
Samira Khan March 23, 2017
Caches Samira Khan March 23, 2017 Agenda Review from last lecture - - PowerPoint PPT Presentation
Caches Samira Khan March 23, 2017 Agenda Review from last lecture Data flow model Memory hierarchy More Caches The Dataflow Model (of a Computer) Von Neumann model: An instruction is fetched and executed in control flow
Samira Khan March 23, 2017
executed in control flow order
in data flow order
3
semantics?)
4
graph of a piece of the program
instructions
5
6
OUT
parallel)
8
technology
9
the levels are farther from the processor) and ensure most of the data the processor needs is kept in the fast(er) level(s)
10
11
fast small big but slow move what you use here backup everything here With good locality of reference, memory appears as fast as and as large as
faster per byte cheaper per byte
many times and all within a small window of time
time
12
perceived access time Ti is longer than ti
Ti = hi·ti + mi·(ti + Ti+1) Ti = ti + mi ·Ti+1
13
Ti = ti + mi ·Ti+1
need, prefetching::anticipate what you will need)
14
if m1=0.1, m2=0.1 T1=7.6, T2=36 if m1=0.01, m2=0.01 T1=4.2, T2=19.8 if m1=0.05, m2=0.01 T1=5.00, T2=19.8 if m1=0.01, m2=0.50 T1=5.08, T2=108
the cache
16
= ( hit-rate * hit-latency ) + ( miss-rate * miss-latency )
17
Address Tag Store (is the address in the cache? + bookkeeping) Data Store (stores memory blocks) Hit/miss? Data
better
18
the address
the tag of the block
19
8-bit address
tag index byte in block 3 bits 2 bits 3 bits
blocks à 32 blocks
20
00 | 000 | 000 - 00 | 000 | 111 Memory 01 | 000 | 000 - 01 | 000 | 111 10 | 000 | 000 - 10 | 000 | 111 11 | 000 | 000 - 11 | 000 | 111 11 | 111 | 000 - 11 | 111 | 111
blocks à 32 blocks
21
Tag store Data store
Address tag index byte in block 3 bits 3 bits 2b
V tag
=?
MUX
byte in block
Hit? Data 00 | 000 | 000 - 00 | 000 | 111 Memory 01 | 000 | 000 - 01 | 000 | 111 10 | 000 | 000 - 10 | 000 | 111 11 | 000 | 000 - 11 | 000 | 111 11 | 111 | 000 - 11 | 111 | 111
blocks à 32 blocks
22
Tag store Data store
Address tag index byte in block 3 bits 3 bits 2b
V tag
=?
MUX
byte in block
Hit? Data 00 | 000 | 000 - 00 | 000 | 111 Memory 01 | 000 | 000 - 01 | 000 | 111 10 | 000 | 000 - 10 | 000 | 111 11 | 000 | 000 - 11 | 000 | 111 11 | 111 | 000 - 11 | 111 | 111
same index in the cache cannot be present in the cache at the same time
interleaved manner map to the same index
bits
23
24
Tag store Data store
V tag
=?
V tag
=?
Logic
MUX MUX
byte in block
Key idea: Associative memory within the set + Accommodates conflicts better (fewer conflict misses)
SET Hit?
8-bit address
tag index byte in block 2 bits 3 bits 3 bits
+ Likelihood of conflict misses even lower
25
Tag store Data store
=? =? =? =?
MUX MUX
byte in block
Logic
Hit?
8-bit address
tag index byte in block 1 bits 4 bits 3 bits
26
Tag store Data store
=? =? =? =? =? =? =? =?
MUX MUX
byte in block
Logic
Hit?
8-bit address
tag index byte in block 0 bit 5 bits 3 bits
8-bit address
tag index byte in block ? bits ? bits 4 bits
8-bit address Direct mapped
tag index byte in block 3 bits 1 bits 4 bits
set)?
++ Higher hit rate
associativity
29
associativity hit rate
cache miss?
30
31
32
A B C D Tag store Data store
=? =? =? =?
Logic
Hit? Set 0 MRU MRU -2 MRU -1 LRU
33
E B C D Tag store Data store
=? =? =? =?
Logic
Hit? Set 0 MRU MRU -2 MRU -1 LRU
34
E B C D Tag store Data store
=? =? =? =?
Logic
Hit? Set 0 MRU MRU -2 MRU -1 MRU
35
E B C D Tag store Data store
=? =? =? =?
Logic
Hit? Set 0 MRU -1 MRU -2 MRU -1 MRU
36
E B C D Tag store Data store
=? =? =? =?
Logic
Hit? Set 0 MRU -1 MRU -2 MRU -2 MRU
37
E B C D Tag store Data store
=? =? =? =?
Logic
Hit? Set 0 MRU -1 LRU MRU -2 MRU
38
E B C D Tag store Data store
=? =? =? =?
Logic
Hit? Set 0 MRU -1 LRU MRU MRU
39
E B C D Tag store Data store
=? =? =? =?
Logic
Hit? Set 0 MRU -1 LRU MRU MRU -1
40
E B C D Tag store Data store
=? =? =? =?
Logic
Hit? Set 0 MRU -2 LRU MRU MRU -1
41