Beruflich Dokumente
Kultur Dokumente
Temporal Locality
Spatial Locality
(block address) % (size of cache in blocks) block address = (word address) DIV (block size)
Memory address (32 bits) => Word address (30 bits) Tag Index Block offset
Cache
00001
00101
01001
11001
11101
Memory
Have 16 bytes per block: 1200/16 = 75 (block address) Now, to what cache slot does this block address map? 75 % 64 = 11
4K entries
16
32
32
32
32
Mux 32
Miss rate
cache size
The drawback of larger blocks: Miss Penalty gets larger too. Miss Penalty is determined by memory latency and transfer rate.
Data
Data
Data
Tag Search
1 2
Tag Search
1 2
Tag Search
1 2
12 % 8
12 % 4 (*)
Fully Associative
Write Back: If the write is going to a block that is in the cache, I write it to the cache. If the write is going to a block that is not in the cache, first I generate a cache miss, bringing a copy of the block to the cache, and then write on the copy.
Advantage: write access time is a lot shorter. Disadvantage: extra bits to mark dirty entries, more complex control.
10
Data
Data
Data
Tag Search
1 2
Tag Search
1 2
Tag Search
1 2
12 % 8
12 % 4 (*)
11
12
12%
9%
Miss rate
6% 3% 0% One-way Two-way Associativity Four-way 1 KB 2 KB 4 KB 8 KB Eight-way 16 KB 32 KB 64 KB 128 KB
13
Direct-mapped cache
Block address 0 8 0 6 8 H/M Miss Miss Miss Miss Miss Block 0 Mem[0] Mem[8] Mem[0] Mem[0] Mem[8] Mem[6] Mem[6] Block 1 Block 2 Block 3
Number of misses = 5
14
Replacement is LRU.
Number of misses = 4
15
Replacement is LRU.
Number of misses = 3
16
17
Tag
Data
Tag
Data
Tag
Data
Tag
Data
22
32
Set size = 4 (elements p/set) Number of sets = 256 Block size = 1 word Cache size = 2^(10) words
4-to-1 multiplexor
Hit
Data
18
Question: what is happening with the number of bits I need to Store tags as we increase set associativity?
19
Replacement Policies
LRU: most commonly used. Question: What do you need to have in order to be able to figure out what item in a set was the least recently used?
20