






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







Chien CSE141 1 November 19, 2002
Chien CSE141 2 November 19, 2002
Computer
Memory
Datapath
Control
Output
Input
Chien CSE141 3 November 19, 2002
Processor Speeds
Memory Speeds
How can we span this “access time” gap?
Chien CSE141 4 November 19, 2002
Processor
For some period, most of the references are in the shaded regions
Chien CSE141 7 November 19, 2002
Program Reference Stream (instruction and data) 110 264 111 112 272 113
110 264 111 112 292 113
reuse t
Sources of temporal locality
Instruction fetch (loops)
Locals (loops, repeated invocations)
Data Structures
xxx Instruction fetches (IF) xxx Data Memory Access
Chien CSE141 8 November 19, 2002
Sources of spatial
locality
xxx Instruction fetch xxx Data memory access
Chien CSE141 9 November 19, 2002
Why does locality matter?
Processor
Memory
What does locality buy us?
Chien CSE141 10 November 19, 2002
Memory hierarchies take advantage of memory
locality.
Memory locality is the principle that future memory
accesses are near past accesses.
Memories take advantage of two types of locality
Chien CSE141 13 November 19, 2002
Registers
Caches; what we’ll talk about.
Q: How do we use a memory hierarchy to exploit locality?
P Fast Mem Slow Mem
put things likely to use here
remainder of things here How do we decide?
**- explicit control
Chien CSE141 14 November 19, 2002
Processor accesses “Memory hierarchy”
Accesses first check small, fast “cache”
If “miss” in cache, retrieve data from main memory
Cache exploits locality to provide high performance
P (^) Cache
Main Memory
Chien CSE141 15 November 19, 2002
lw $s1, F0($s0) sw $s2, 6F($s3)
interface view
physical org.
Chien CSE141 16 November 19, 2002
Measure set of access costs
Weight by frequency
P Fast Mem
Slow Mem
Latency 1 cycle 10 cycles
Assumptions:
= (frac. of fast mem refs) * (fast mem access cost) + (frac. of slow mem refs) * (slow mem access cost)
Chien CSE141 19 November 19, 2002
Data is copied into the cache.
Where to put the data? (which location)
Which data to replace? (later)
Main Memory
Cache
Chien CSE141 20 November 19, 2002
Map each region of address space to a single
cache location
Main Memory Cache
Chien CSE141 21 November 19, 2002
For fast access, must be able to find data quickly
Lookup: discard a few address bits, access the fast
memory
Tags indicate the data that’s really there
Why does this work?
Access + Lookup:
Memory Address
Cache Index
Cache Tag
Cache
Data Tags
Chien CSE141 22 November 19, 2002
Part of Memory Address applied to cache
Tags checked against remaining address bits
If match -> Hit!, use data
No match -> Miss, retrieve data from memory
This works pretty well... but there are some
complications...
Data Tags
Memory address lines
= Hit?