CS 152 Computer Architecture and Engineering Lecture 6 - Memory
CS 152 Computer Architecture and Engineering Lecture 6 - Memory
CS 152 Computer Architecture and Engineering Lecture 6 - Memory
Krste Asanovic
Electrical Engineering and Computer Sciences University of California at Berkeley http://www.eecs.berkeley.edu/~krste http://inst.eecs.berkeley.edu/~cs152
CPU-Memory Bottleneck
CPU Memory
Performance of high-speed computers is usually limited by memory bandwidth & latency Latency (time for a single access)
Memory access time >> Processor cycle time
Core Memory
Core memory was first large scale reliable main memory
invented by Forrester in late 40s/early 50s at MIT for Whirlwind project
Bits stored as magnetization polarity on small ferrite cores threaded onto 2 dimensional grid of wires Coincident current pulses on X and Y wires would write cell and also sense original state (destructive reads)
Robust, non-volatile storage Used on space shuttle computers until recently Cores threaded onto wires by hand (25 billion a year at peak production) Core access time ~ 1 s
DEC PDP-8/E Board, 4K words x 12 bits, (1968)
2/10/2009 CS152-Spring09 4
2/10/2009
CS152-Spring09
2/10/2009
DRAM Architecture
Col. 1 N bit lines Col. 2M word lines Row 1
N+M
Bits stored in 2-dimensional arrays on chip Modern chips have around 4 logical banks on each chip
each logical bank physically implemented as many smaller arrays
2/10/2009 CS152-Spring09 7
DRAM Packaging
Clock and control signals
~7
DRAM chip
DIMM (Dual Inline Memory Module) contains multiple chips with clock/control/address signals connected in parallel (sometimes need buffers to drive signals to all chips) Data pins work together to return wide word (e.g., 64-bit data bus using 16x4-bit parts)
2/10/2009
CS152-Spring09
DRAM Operation
Three steps in read/write access to a given bank Row access (RAS)
decode row address, enable addressed row (often multiple Kb in row) bitlines share charge with storage cell small change in voltage detected by sense amplifiers which latch whole row of bits sense amplifiers drive bitlines full rail to recharge storage cells decode column address to select small number of sense amplifier latches (4, 8, 16, or 32 bits depending on DRAM package) on read, send latched bits out to chip pins on write, change sense amplifier latches which then charge storage cells to required value can perform multiple column accesses on same row without another row access (burst mode) charges bit lines to known value, required before next row access
Precharge
Each step has a latency of around 15-20ns in modern DRAMs Various DRAM standards (DDR, RDRAM) have different ways of encoding the signals for transmission to the DRAM, but all share same core architecture
2/10/2009 CS152-Spring09 9
Row
Column
Precharge
Row
Data
[ Micron, 256Mb DDR2 SDRAM datasheet ]
2/10/2009 CS152-Spring09
Performance
Moores Law
100 10
DRAM
DRAM
7%/year
1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 1982 1983 1984 1985 1986 1987 1980 1981
Time
Four-issue 2GHz superscalar accessing 100ns DRAM could execute 800 instructions during time for one memory access!
2/10/2009 CS152-Spring09 11
n loop iterations
Stack accesses
Data accesses
to ec v
scalar accesses
Time
2/10/2009
CS152-Spring09
2/10/2009
CS152-Spring09
Temporal Locality
Spatial Locality
Donald J. Hatfield, Jeanette Gerald: Program Restructuring for Virtual Memory. IBM Systems Journal 10(3): 168-192 (1971)
Time
Multilevel Memory
Strategy: Reduce average latency using small, fast memories called caches. Caches are a mechanism to reduce memory latency based on the empirical observation that the patterns of memory references made by a processor are often highly predictable:
loop: ADD r2, r1, r1 SUBI r3, r3, #1 BNEZ r3, loop PC 96 100 104 108 112
2/10/2009
CS152-Spring09
Memory Hierarchy
A CPU Small, Fast Memory (RF, SRAM) B Big, Slow Memory (DRAM)
capacity: Register << SRAM << DRAM latency: Register << SRAM << DRAM bandwidth: on-chip >> off-chip On a data access:
hit (data fast memory) low latency access miss (data fast memory) long latency access (DRAM)
2/10/2009
CS152-Spring09
16
QuickTime and a TIFF (Uncompressed) decompressor are needed to see this picture.
QuickTime and a TIFF (Uncompressed) decompressor are needed to see this picture.
2/10/2009
CS152-Spring09
17
2/10/2009
CS152-Spring09
18
CS152 Administrivia
Quiz 1 Thursday in class (306 Soda)
Lectures 1-5, closed book, no calculators or computers
Krste, special office hours, Wednesday 2/11, 2-3pm, 579 Soda Hall (Par Lab) Scott special office hours, Wednesday 2/11, 4-5pm, 711 Soda Hall Next week lecture 2/17 back in 320 Soda
2/10/2009
CS152-Spring09
19
Caches
Caches exploit both types of predictability: Exploit temporal locality by remembering the contents of recently accessed locations. Exploit spatial locality by fetching blocks of data around recently accessed locations.
2/10/2009
CS152-Spring09
Inside a Cache
Address Address
Processor
Data
CACHE
Data
Main Memory
Line
Address Tag
6848 416
Data Block
2/10/2009 CS152-Spring09
Read block of data from Main Memory Wait Return data to processor and update cache Q: Which line do we replace?
2/10/2009
CS152-Spring09
Placement Policy
Block Number
1111111111 2222222222 33 0123456789 0123456789 0123456789 01
Memory
Set Number
01234567
Cache
Fully Associative anywhere (2-way) Set Associative anywhere in set 0 (12 mod 4) Direct Mapped only into block 4 (12 mod 8)
23
CS152-Spring09
Direct-Mapped Cache
Tag t V Tag Index k
Block Offset
Data Block
2k lines t =
HIT
2/10/2009 CS152-Spring09
k V Tag
t Data Block
2k lines t =
HIT
2/10/2009 CS152-Spring09
Tag
= HIT
Block Offset
b
2/10/2009
Replacement Policy
In an associative cache, which block from a set should be evicted when the set becomes full? Random
Least Recently Used (LRU)
LRU cache state must be updated on every access true implementation only feasible for small sets (2-way) pseudo-LRU binary tree often used for 4-8 way used in highly associative caches
Acknowledgements
These slides contain material developed and copyright by:
Arvind (MIT) Krste Asanovic (MIT/UCB) Joel Emer (Intel/MIT) James Hoe (CMU) John Kubiatowicz (UCB) David Patterson (UCB)
MIT material derived from course 6.823 UCB material derived from course CS252
2/10/2009
CS152-Spring09
29