lecture11_memory2.PPT
Download
Report
Transcript lecture11_memory2.PPT
Chapter 5
Memory II
CSE 820
Equations
CPU execution time =
(CPU cycles + Memory-stall cycles) x clockCycleTime
Memory stall cycles = misses x penalty
= IC x miss/Inst x penalty
= IC x memAccess/Inst x missRate x penalty
Michigan State University
Computer Science and Engineering
Hierarchy Questions
1. Block Placement
Where can a block be placed?
2. Block Identification
How is a block found?
3. Block Replacement
Which block should be replaced on a miss?
4. Write Strategy
What happens on a write?
Michigan State University
Computer Science and Engineering
Cache Q1: Where to place?
Michigan State University
Computer Science and Engineering
Cache Q2: How to find it?
block address
block offset
tag
•
•
•
•
index
Index selects the set
Tag checks all in the set
Offset selects within the block
Valid bit
Michigan State University
Computer Science and Engineering
Cache Q3: Replacement?
• Random
– Simplest
• FIFO
• LRU
– Approximation
– Outperforms others for large caches
Michigan State University
Computer Science and Engineering
Cache Q4: write?
• Reads are most common and easiest
• Writes
– Write through
– Write back
• On replacement
• Dirty bit
• Allocate?
– Write allocate
– No-write allocate
Michigan State University
Computer Science and Engineering
Alpha 21264 Cache: Go through it on your own
Michigan State University
Computer Science and Engineering
Equations
• Fig 5.9 has
12 memory performance equations
• Most are variations on
CPU = IC x CPI x cycles
AvgMemAccess = Hit + MissRate x MissPenalty
Michigan State University
Computer Science and Engineering
AvgMemAccess = Hit + MissRate x MissPenalty
17 Cache Optimizations
• Reduce miss penalty
Multilevel, critical first, read-before-write, merging
writes, victim cache
• Reduce miss rate
Larger blocks and caches, higher associativity,
way prediction, compiler optimizations
• Reduce miss rate & penalty with parallelism
Non-blocking, hardware and software prefetch
• Reduce hit time
Size, translation, pipelined, trace
Michigan State University
Computer Science and Engineering
Reducing Cache Miss Penalty
Michigan State University
Computer Science and Engineering
Questions
• Why is a small cache fast?
• Why will a designer put L1 and L2
cache on a processor chip rather than
simply having a large L1 cache?
• Why is L1 direct mapped?
Michigan State University
Computer Science and Engineering
Reducing Miss Penalty:
Multilevel Caches
• How does an L2 cache
reduce the miss penalty?
Michigan State University
Computer Science and Engineering
Multilevel Cache
AvgMemAccessTime =
HitTimeL1 + MissRateL1 X MissPenaltyL1
where
MissPenaltyL1 =
HitTimeL2 + MissRateL2X MissPenaltyL2
Michigan State University
Computer Science and Engineering
Terms
• Global miss rate = misses/CPUaccesses
– e.g. for L2 = MissRateL1 X MissRateL2
• Local miss rate = misses/CacheAccesses
– e.g. MissRateL2
measured on the leftovers from L1
Michigan State University
Computer Science and Engineering
L1 vs L2 with 32K L1: small L2 is poor
What is good about this graph?
Hit time is good and so is avg memory latency.
Michigan State University
Computer Science and Engineering
Inclusive vs Exclusive
• Inclusion: L1 is subset of L2
pro: consistency between I/O and cache (or
among multiprocessor caches) is easy—simply
check L2
e.g. P4
• Exclusive: L1 and L2 are disjoint
pro: useful when L2 is only slightly larger than L1
e.g. AMD Athlon
Michigan State University
Computer Science and Engineering
Miss Penalty Reduction:
Critical Word First & Early Restart
• Critical word first: In multiword block,
bring in the desired word first.
• Early Restart: restart CPU when desired
word is received
Michigan State University
Computer Science and Engineering
Miss Penalty Reduction:
Priority to Read
• Reads first
if no conflict with writes in write buffer
• Why?
Michigan State University
Computer Science and Engineering
Miss Penalty Reduction:
Merging Write Buffer
• Within write buffer
merge words into blocks before writing
Michigan State University
Computer Science and Engineering
Miss Penalty Reduction:
Victim Cache
• Remember last block discarded
• Algorithm:
on miss, if block is in victim cache, swap.
• Performance:
a 4-entry victim cache
can resolve ¼ of misses
• e.g. AMD Athlon (8 entries)
Michigan State University
Computer Science and Engineering
Victim Cache
Michigan State University
Computer Science and Engineering
Reducing Cache Miss Rate
Michigan State University
Computer Science and Engineering
Miss Classification
• Compulsory:
first access cannot be in cache
• Capacity:
if cache cannot contain all blocks,
some accesses must miss
• Conflict: others
e.g. two blocks conflict by mapping to
same slot
(fully associative has no conflict)
Michigan State University
Computer Science and Engineering
compulsory
Capacity = fullyMichigan
associative
(decreases with size)
State University
Conflict
decreases
with
set size.
Computer
Science and
Engineering
Miss category as a percentage.
Michigan State University
Computer Science and Engineering