Lec 2
Lec 2
Lec 2
5th
Edition
The Hardware/Software Interface
Chapter 5
Large and Fast:
Exploiting Memory
Hierarchy
§5.1 Introduction
Principle of Locality
Programs access a small proportion of
their address space at any time
Temporal locality
Items accessed recently are likely to be
accessed again soon
e.g., instructions in a loop, induction variables
Spatial locality
Items near those accessed recently are likely
to be accessed soon
E.g., sequential instruction access, array data
Chapter 5 — Large and Fast: Exploiting Memory Hierarchy — 2
Taking Advantage of Locality
Memory hierarchy
Store everything on disk
Copy recently accessed (and nearby)
items from disk to smaller DRAM memory
Main memory
Copy more recently accessed (and
nearby) items from DRAM to smaller
SRAM memory
Cache memory attached to CPU
Byte Address
CDA3101
Tags and Valid Bits
How do we know which particular block is
stored in a cache location?
Store block address (ID) as well as the data
Actually, only need the high-order bits
Called the address tag
Matching tag to determine cache hit
What if there is no data in a location?
Valid bit: 1 = present, 0 = not present
Initially 0
tag index
FIGURE 5.11 Miss rate versus block size. Note that the miss rate actually goes up
if the block size is too large relative to the cache size. Each line represents a cache
of different size. (This figure is independent of associativity, discussed soon.)
Unfortunately, SPEC CPU2000 traces would take too long if block size were
included, so this data is based on SPEC92.
(4 bytes)