William Stallings Computer Organization and Architecture 8th Edition Cache Memory
William Stallings Computer Organization and Architecture 8th Edition Cache Memory
Computer Organization
and Architecture
8th Edition
Chapter 4
Cache Memory
Characteristics
Location
Capacity
Unit of transfer
Access method
Performance
Physical type
Physical characteristics
Organisation
Location
CPU
Internal
External
Capacity
Word size
The natural unit of organisation
Number of words
or Bytes
Unit of Transfer
Internal
Usually governed by data bus width
External
Usually a block which is much larger than a
word
Addressable unit
Smallest location which can be uniquely
addressed
Word internally
Cluster on M$ disks
Direct
Individual blocks have unique address
Access is by jumping to vicinity plus sequential
search
Access time depends on location and previous
location
e.g. disk
Associative
Data is located by a comparison with contents
of a portion of the store
Access time is independent of location or
previous access
e.g. cache
Memory Hierarchy
Registers
In CPU
External memory
Backing store
Performance
Access time
Time between presenting the address and
getting the valid data
Transfer Rate
Rate at which data can be moved
Physical Types
Semiconductor
RAM
Magnetic
Disk & Tape
Optical
CD & DVD
Others
Bubble
Hologram
Physical Characteristics
Decay
Volatility
Erasable
Power consumption
Organisation
Physical arrangement of bits into words
Not always obvious
e.g. interleaved
How fast?
Time is money
How expensive?
Hierarchy List
Registers
L1 Cache
L2 Cache
Main memory
Disk cache
Disk
Optical
Tape
Locality of Reference
During the course of the execution of a
program, memory references tend to
cluster
e.g. loops
Cache
Small amount of fast memory
Sits between normal main memory and
CPU
May be located on CPU chip or module
Cache Design
Addressing
Size
Mapping Function
Replacement Algorithm
Write Policy
Block Size
Number of Caches
Cache Addressing
Where does cache sit?
Between processor and virtual memory management
unit
Between MMU and main memory
Speed
More cache is faster (up to a point)
Checking cache for data takes time
L2cache
L3cache
Mainframe
Yearof
Introduction
1968
16to32KB
PDP11/70
Minicomputer
1975
1KB
VAX11/780
Minicomputer
1978
16KB
IBM3033
Mainframe
1978
64KB
IBM3090
Mainframe
1985
128to256KB
Intel80486
PC
1989
8KB
Pentium
PC
1993
8KB/8KB
256to512KB
PowerPC601
PC
1993
32KB
PowerPC620
PC
1996
32KB/32KB
PowerPCG4
PC/server
1999
32KB/32KB
256KBto1MB
2MB
IBMS/390G4
Mainframe
1997
32KB
256KB
2MB
IBMS/390G6
Mainframe
1999
256KB
8MB
Pentium4
2000
8KB/8KB
256KB
2000
64KB/32KB
8MB
CRAYMTAb
PC/server
Highendserver/
supercomputer
Supercomputer
2000
8KB
2MB
Itanium
PC/server
2001
16KB/16KB
96KB
4MB
SGIOrigin2001
Highendserver
2001
32KB/32KB
4MB
Itanium2
PC/server
2002
32KB
256KB
6MB
IBMPOWER5
Highendserver
2003
64KB
1.9MB
36MB
CRAYXD1
Supercomputer
2004
64KB/64KB
1MB
Processor
Type
IBM360/85
IBMSP
Mapping Function
Cache of 64kByte
Cache block of 4 bytes
i.e. cache is 16k (214) lines of 4 bytes
Direct Mapping
Each block of main memory maps to only
one cache line
i.e. if a block is in cache, it must be in one
specific place
Direct Mapping
Address Structure
Tag s-r
8
Line or Slot r
Word w
14
24 bit address
2 bit word identifier (4 byte block)
22 bit block identifier
8 bit tag (=22-14)
14 bit slot or line
No two blocks in the same line have the same Tag field
Check contents of cache by finding line and checking Tag
Direct Mapping
Cache Line Table
Cache line
0, m, 2m, 3m2s-m
1,m+1, 2m+12s-m+1
m-1
m-1, 2m-1,3m-12s-1
Direct
Mapping
Example
Victim Cache
Lower miss penalty
Remember what was discarded
Already fetched
Use again with little penalty
Fully associative
4 to 16 cache lines
Between direct mapped L1 cache and next
memory level
Associative Mapping
A main memory block can load into any
line of cache
Memory address is interpreted as tag and
word
Tag uniquely identifies block of memory
Every lines tag is examined for a match
Cache searching gets expensive
Associative
Mapping
Example
Associative Mapping
Address Structure
Word
2 bit
Tag 22 bit
Tag
Data
FFFFFC24682468
Cache line
3FFF
Word
2 bit
Set 13 bit
Tag
1FF
001
Data
12345678 1FFF
11223344 1FFF
Set
Figure 4.16
Varying Associativity over Cache Size
Random
Write Policy
Must not overwrite a cache block unless
main memory is up to date
Multiple CPUs may have individual caches
I/O may address main memory directly
Write through
All writes go to main memory as well as
cache
Multiple CPUs can monitor main memory
traffic to keep local (to CPU) cache up to
date
Lots of traffic
Slows down writes
Remember bogus write through caches!
Write back
Updates initially made in cache only
Update bit for cache slot is set when
update occurs
If block is to be replaced, write to main
memory only if update bit is set
Other caches get out of sync
I/O must access main memory through
cache
N.B. 15% of memory references are
writes
Line Size
Retrieve not only desired word but a number of
adjacent words as well
Increased block size will increase hit ratio at first
the principle of locality
Larger blocks
Multilevel Caches
High logic density enables caches on chip
Faster than bus access
Frees bus for other transfers
Pentium 4 Cache
80386 no on chip cache
80486 8k using 16 byte lines and four way set
associative organization
Pentium (all versions) two on chip L1 caches
Data & instructions
L2 cache
L3 cache on chip
Solution
Processoronwhichfeature
firstappears
Externalmemoryslowerthanthesystembus.
Addexternalcacheusingfaster
memorytechnology.
386
Increasedprocessorspeedresultsinexternalbusbecominga
bottleneckforcacheaccess.
Moveexternalcacheonchip,
operatingatthesamespeedasthe
processor.
486
Internalcacheisrathersmall,duetolimitedspaceonchip
AddexternalL2cacheusingfaster
technologythanmainmemory
486
Createseparatedataandinstruction
caches.
Pentium
Createseparatebacksidebusthat
runsathigherspeedthanthemain
(frontside)externalbus.TheBSBis
dedicatedtotheL2cache.
PentiumPro
ContentionoccurswhenboththeInstructionPrefetcherand
theExecutionUnitsimultaneouslyrequireaccesstothe
cache.Inthatcase,thePrefetcherisstalledwhilethe
ExecutionUnitsdataaccesstakesplace.
Increasedprocessorspeedresultsinexternalbusbecominga
bottleneckforL2cacheaccess.
Someapplicationsdealwithmassivedatabasesandmust
haverapidaccesstolargeamountsofdata.Theonchip
cachesaretoosmall.
MoveL2cacheontotheprocessor
chip.
PentiumII
AddexternalL3cache.
PentiumIII
MoveL3cacheonchip.
Pentium4
Execution units
Execute micro-ops
Data from L1 cache
Results in registers
Memory subsystem
L2 cache and systems bus
Cache
Type
CacheSize(kB)
CacheLineSize
(words)
Associativity
Location
WriteBuffer
Size(words)
ARM720T
Unified
4way
Logical
ARM920T
Split
16/16D/I
64way
Logical
16
ARM926EJS
Split
4128/4128D/I
4way
Logical
16
ARM1022E
Split
16/16D/I
64way
Logical
16
ARM1026EJS
Split
4128/4128D/I
4way
Logical
IntelStrongARM
Split
16/16D/I
32way
Logical
32
IntelXscale
Split
32/32D/I
32way
Logical
32
ARM1136JFS
Split
464/464D/I
4way
Physical
32
Internet Sources
Manufacturer sites
Intel
ARM
Search on cache