CS 152 Computer Architecture and Engineering. Lecture 7 - Memory Hierarchy-II

Similar documents
CS 152 Computer Architecture and Engineering. Lecture 7 - Memory Hierarchy-II

Lecture 7 - Memory Hierarchy-II

CS 152 Computer Architecture and Engineering. Lecture 7 - Memory Hierarchy-II

Page 1. Multilevel Memories (Improving performance using a little cash )

CS 152 Computer Architecture and Engineering. Lecture 8 - Memory Hierarchy-III

CS 152 Computer Architecture and Engineering. Lecture 8 - Memory Hierarchy-III

Multilevel Memories. Joel Emer Computer Science and Artificial Intelligence Laboratory Massachusetts Institute of Technology

Lecture 11 Cache. Peng Liu.

EE 660: Computer Architecture Advanced Caches

Memory Hierarchy. 2/18/2016 CS 152 Sec6on 5 Colin Schmidt

ECE 552 / CPS 550 Advanced Computer Architecture I. Lecture 13 Memory Part 2

ECE 252 / CPS 220 Advanced Computer Architecture I. Lecture 13 Memory Part 2

CS 152 Computer Architecture and Engineering. Lecture 8 - Memory Hierarchy-III

CS 152 Computer Architecture and Engineering. Lecture 6 - Memory

EC 513 Computer Architecture

CS 152 Computer Architecture and Engineering. Lecture 11 - Virtual Memory and Caches

Memory Hierarchy. Slides contents from:

Memory Hierarchy. Slides contents from:

EECS151/251A Spring 2018 Digital Design and Integrated Circuits. Instructors: John Wawrzynek and Nick Weaver. Lecture 19: Caches EE141

Advanced Computer Architecture

Agenda. EE 260: Introduction to Digital Design Memory. Naive Register File. Agenda. Memory Arrays: SRAM. Memory Arrays: Register File

Improving Cache Performance and Memory Management: From Absolute Addresses to Demand Paging. Highly-Associative Caches

CS 152 Computer Architecture and Engineering CS252 Graduate Computer Architecture. Lecture 7 Memory III

Cache Memory COE 403. Computer Architecture Prof. Muhamed Mudawar. Computer Engineering Department King Fahd University of Petroleum and Minerals

Lecture 6 - Memory. Dr. George Michelogiannakis EECS, University of California at Berkeley CRD, Lawrence Berkeley National Laboratory

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Caches Part 3

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Caches Part 3

Lecture 11 Cache and Virtual Memory

CS 152 Computer Architecture and Engineering. Lecture 9 - Address Translation

CSE 431 Computer Architecture Fall Chapter 5A: Exploiting the Memory Hierarchy, Part 1

Advanced Memory Organizations

CS 152 Computer Architecture and Engineering. Lecture 8 - Address Translation

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Caches Part 3

CS 152 Computer Architecture and Engineering. Lecture 8 - Address Translation

CS 152 Computer Architecture and Engineering. Lecture 9 - Address Translation

The Memory Hierarchy & Cache Review of Memory Hierarchy & Cache Basics (from 350):

Memory hier ar hier ch ar y ch rev re i v e i w e ECE 154B Dmitri Struko Struk v o

Chapter 5A. Large and Fast: Exploiting Memory Hierarchy

CACHE MEMORIES ADVANCED COMPUTER ARCHITECTURES. Slides by: Pedro Tomás

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

The Memory Hierarchy. Cache, Main Memory, and Virtual Memory (Part 2)

Mo Money, No Problems: Caches #2...

registers data 1 registers MEMORY ADDRESS on-chip cache off-chip cache main memory: real address space part of virtual addr. sp.

CENG 3420 Computer Organization and Design. Lecture 08: Memory - I. Bei Yu

CSF Cache Introduction. [Adapted from Computer Organization and Design, Patterson & Hennessy, 2005]

Memory Hierarchy. ENG3380 Computer Organization and Architecture Cache Memory Part II. Topics. References. Memory Hierarchy

CS 152 Computer Architecture and Engineering. Lecture 9 - Virtual Memory

CS3350B Computer Architecture

Chapter Seven. Memories: Review. Exploiting Memory Hierarchy CACHE MEMORY AND VIRTUAL MEMORY

10/19/17. You Are Here! Review: Direct-Mapped Cache. Typical Memory Hierarchy

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. 5 th. Edition. Chapter 5. Large and Fast: Exploiting Memory Hierarchy

14:332:331. Week 13 Basics of Cache

ECE 4750 Computer Architecture, Fall 2014 T05 FSM and Pipelined Cache Memories

Chapter 5B. Large and Fast: Exploiting Memory Hierarchy

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

CS 152 Computer Architecture and Engineering. Lecture 19: Directory-Based Cache Protocols

Lecture 9 - Virtual Memory

registers data 1 registers MEMORY ADDRESS on-chip cache off-chip cache main memory: real address space part of virtual addr. sp.

Memory Technology. Chapter 5. Principle of Locality. Chapter 5 Large and Fast: Exploiting Memory Hierarchy 1

14:332:331. Week 13 Basics of Cache

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

Computer Architecture Computer Science & Engineering. Chapter 5. Memory Hierachy BK TP.HCM

CS 152 Computer Architecture and Engineering. Lecture 19: Directory-Based Cache Protocols

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Caches Part 3

1/19/2009. Data Locality. Exploiting Locality: Caches

Memory hierarchy review. ECE 154B Dmitri Strukov

Memory Hierarchy and Caches

Memory Hierarchy Computing Systems & Performance MSc Informatics Eng. Memory Hierarchy (most slides are borrowed)

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Caches Part 2

Show Me the $... Performance And Caches

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Caches Part 1

CS 152 Computer Architecture and Engineering. Lecture 12 - Advanced Out-of-Order Superscalars

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Caches Part 2

10/16/17. Outline. Outline. Typical Memory Hierarchy. Adding Cache to Computer. Key Cache Concepts

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

EE 4683/5683: COMPUTER ARCHITECTURE

Lecture 14: Cache Innovations and DRAM. Today: cache access basics and innovations, DRAM (Sections )

Computer Architecture ELEC3441

COMPUTER ORGANIZATION AND DESIGN

Computer Architecture. Memory Hierarchy. Lynn Choi Korea University

Page 1. Memory Hierarchies (Part 2)

Improving Cache Performance

Memory Hierarchy Computing Systems & Performance MSc Informatics Eng. Memory Hierarchy (most slides are borrowed)

Advanced Caching Techniques (2) Department of Electrical Engineering Stanford University

Memory Hierarchy. Maurizio Palesi. Maurizio Palesi 1

CSF Improving Cache Performance. [Adapted from Computer Organization and Design, Patterson & Hennessy, 2005]

Spring 2016 :: CSE 502 Computer Architecture. Caches. Nima Honarmand

CSC 631: High-Performance Computer Architecture

ELEC 5200/6200 Computer Architecture and Design Spring 2017 Lecture 7: Memory Organization Part II

Chapter 5 Memory Hierarchy Design. In-Cheol Park Dept. of EE, KAIST

Memory. Lecture 22 CS301

Course Administration

CS356: Discussion #9 Memory Hierarchy and Caches. Marco Paolieri Illustrations from CS:APP3e textbook

Chapter 2: Memory Hierarchy Design Part 2

Topics. Digital Systems Architecture EECE EECE Need More Cache?

Memory Technology. Caches 1. Static RAM (SRAM) Dynamic RAM (DRAM) Magnetic disk. Ideal memory. 0.5ns 2.5ns, $2000 $5000 per GB

Memory latency: Affects cache miss penalty. Measured by:

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

Donn Morrison Department of Computer Science. TDT4255 Memory hierarchies

EN1640: Design of Computing Systems Topic 06: Memory System

Transcription:

CS 152 Computer Architecture and Engineering Lecture 7 - Memory Hierarchy-II Krste Asanovic Electrical Engineering and Computer Sciences University of California at Berkeley http://www.eecs.berkeley.edu/~krste http://inst.eecs.berkeley.edu/~cs152 Last time in Lecture 6 Dynamic RAM (DRAM) is main form of main memory storage in use today Holds values on small capacitors, need refreshing (hence dynamic) Slow multi-step access: precharge, read row, read column Static RAM (SRAM) is faster but more expensive Used to build on-chip memory for caches s exploit two forms of predictability in memory reference streams Temporal locality, same location likely to be accessed again soon Spatial locality, neighboring location likely to be accessed soon holds small set of values in fast memory (SRAM) close to processor Need to develop search scheme to find values in cache, and replacement policy to make space for newly accessed locations 2/14/2008 CS152-Spring!08 2

Relative Memory Cell Sizes On-Chip SRAM in logic chip DRAM on memory chip [ Foss, Implementing Application-Specific Memory, ISSCC 1996 ] 2/14/2008 CS152-Spring!08 3 Placement Policy Block Number 0 1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 Memory Set Number 0 1 2 3 0 1 2 3 4 5 6 7 block 12 can be placed Fully (2-way) Set Direct Associative Associative Mapped anywhere anywhere in only into set 0 block 4 (12 mod 4) (12 mod 8) 2/14/2008 CS152-Spring!08 4

Direct-Mapped Index Block Offset t V k b Block 2 k lines = t HIT Word or Byte 2/14/2008 CS152-Spring!08 2-Way Set-Associative Index Block Offset b t V k Block V Block t = = Word or Byte HIT 2/14/2008 CS152-Spring!08

Fully Associative V Block = t Block Offset b t = = Word or Byte HIT 2/14/2008 CS152-Spring!08 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 First In, First Out (FIFO) a.k.a. Round-Robin used in highly associative caches Not Least Recently Used (NLRU) FIFO with exception for most recently used block or blocks This is a second-order effect. Why? Replacement only happens on misses 2/14/2008 CS152-Spring!08 8

Block Size and Spatial Locality Block is unit of transfer between the cache and memory Word0 Word1 Word2 Word3 4 word block, b=2 Split CPU address block address offset b 32-b bits b bits 2 b = block size a.k.a line size (in bytes) Larger block size has distinct hardware advantages less tag overhead exploit fast burst transfers from DRAM exploit fast burst transfers over wide busses What are the disadvantages of increasing block size? 2/14/2008 CS152-Spring!08 9 CPU- Interaction (5-stage pipeline) PCen PC 0x4 Add addr nop inst hit? Primary Instruction IR D Decode, Register Fetch E A B MD1 ALU M Y MD2 we addr Primary rdata hit? wdata R Stall entire CPU on data cache miss To Memory Control What about Instruction miss or writes to i-stream? Refill from Lower Levels of Memory Hierarchy 2/14/2008 CS152-Spring!08 10

Improving Performance Average memory access time = Hit time + Miss rate x Miss penalty To improve performance: reduce the hit time reduce the miss rate reduce the miss penalty What is the simplest design strategy? 2/14/2008 CS152-Spring!08 11 Causes for Misses Compulsory: first-reference to a block a.k.a. cold start misses - misses that would occur even with infinite cache Capacity: cache is too small to hold all data needed by the program - misses that would occur even under perfect replacement policy Conflict: misses that occur because of collisions due to block-placement strategy - misses that would not occur with full associativity 2/14/2008 CS152-Spring!08 12

Effect of Parameters on Performance Larger cache size Higher associativity Larger block size 2/14/2008 CS152-Spring!08 13 Write Policy Choices hit: write through: write both cache & memory» generally higher traffic but simplifies cache coherence write back: write cache only (memory is written only when the entry is evicted)» a dirty bit per block can further reduce the traffic miss: no write allocate: only write to main memory write allocate (aka fetch on write): fetch into cache Common combinations: write through and no write allocate write back with write allocate 2/14/2008 CS152-Spring!08 14

Write Performance t V Index k Block Offset b 2 k lines = t WE HIT Word or Byte 2/14/2008 CS152-Spring!08 15 Reducing Write Hit Time Problem: Writes take two cycles in memory stage, one cycle for tag check plus one cycle for data write if hit Solutions: Design data RAM that can perform read and write in one cycle, restore old value after tag miss Fully-associative (CAM ) caches: Word line only enabled if hit Pipelined writes: Hold write data for store in single buffer ahead of cache, write cache data during next store s tag check 2/14/2008 CS152-Spring!08 16

Pipelining Writes Address and Store From CPU Index Store s Delayed Write Addr. =? Load/Store S L Delayed Write =? 1 0 Load to CPU Hit? from a store hit written into data portion of cache during tag access of subsequent store 2/14/2008 CS152-Spring!08 17 CS152 Administrivia Krste, no office hours, Monday 2/18 (President s Day Holiday) email for alternate time Henry office hours, 511 Soda None on Monday due to holiday 2:00-3:00PM Fridays In-class quiz dates Q1: Tuesday February 19 (ISAs, microcode, simple pipelining)» Material covered, Lectures 1-5, PS1, Lab 1 We re stuck in this room for semester (nothing else open) 2/14/2008 CS152-Spring!08 18

Write Buffer to Reduce Read Miss Penalty CPU RF Write buffer Unified L2 Evicted dirty lines for writeback cache OR All writes in writethru cache Processor is not stalled on writes, and read misses can go ahead of write to main memory Problem: Write buffer may hold updated value of location needed by a read miss Simple scheme: on a read miss, wait for the write buffer to go empty Faster scheme: Check write buffer addresses against read miss addresses, if no match, allow read miss to go ahead of writes, else, return value in write buffer 2/14/2008 CS152-Spring!08 19 Serial-versus-Parallel and Memory access! is HIT RATIO: Fraction of references in cache 1 -! is MISS RATIO: Remaining references Processor Addr CACHE Average access time for serial search: Addr Main Memory t cache + (1 -!) t mem Processor Addr CACHE Main Memory Average access time for parallel search:! t cache + (1 -!) t mem Savings are usually small, t mem >> t cache, hit ratio! high High bandwidth required for memory path Complexity of handling parallel paths can slow t cache 2/14/2008 CS152-Spring!08

Block-level Optimizations s are too large, i.e., too much overhead Simple solution: Larger blocks, but miss penalty could be large. Sub-block placement (aka sector cache) A valid bit added to units smaller than full block, called sub-blocks Only read a sub-block on a miss If a tag matches, is the word in the cache? 100 300 204 1 1 1 1 1 1 0 0 0 1 0 1 2/14/2008 CS152-Spring!08 21 Set-Associative RAM- Status Status =? =? Not energy-efficient A tag and data word is read from every way Two-phase approach First read tags, then just read data from selected way More energy-efficient Doubles latency in L1 OK, for L2 and above, why? Index Offset 2/14/2008 CS152-Spring!08 22

Highly-Associative CAM- s For high associativity (e.g., 32-way), use content-addressable memory (CAM) for tags (ARM, Intel XScale) Overhead: +comparator bit 2-4x area of plain RAM-tag bit tag set index offset Set i Set 1 =? Block Set 0 =? =? Block =? Block Block =? Block =? Block =? Block =? Block =? Block Hit? Only one set enabled Only hit data accessed saves energy 2/14/2008 CS152-Spring!08 23 Victim s (HP 7200) CPU RF L1 Unified L2 Hit data from VC (miss in L1) Victim FA 4 blocks Evicted data from L1 where? Evicted data From VC Victim cache is a small associative back up cache, added to a direct mapped cache, which holds recently evicted lines First look up in direct mapped cache If miss, look in victim cache If hit in victim cache, swap hit line with line now evicted from L1 If miss in victim cache, L1 victim -> VC, VC victim->? Fast hit time of direct mapped but with reduced conflict misses 2/14/2008 CS152-Spring!08 24

Way Predicting s (MIPS R10000 L2 cache) Use processor address to index into way prediction table Look in predicted way at given index, then: HIT MISS Return copy of data from cache Look in other way SLOW HIT (change entry in prediction table) MISS Read block of data from next level of cache 2/14/2008 CS152-Spring!08 25 Multilevel s A memory cannot be large and fast Increasing sizes of cache at each level CPU L1 L2 DRAM Local miss rate = misses in cache / accesses to cache Global miss rate = misses in cache / CPU memory accesses Misses per instruction = misses in cache / number of instructions 2/14/2008 CS152-Spring!08 26

Inclusion Policy Inclusive multilevel cache: Inner cache holds copies of data in outer cache External access need only check outer cache Most common case Exclusive multilevel caches: Inner cache may hold data not in outer cache Swap lines between inner/outer caches on miss Used in AMD Athlon with 64KB primary and 256KB secondary cache Why choose one type or the other? 2/14/2008 CS152-Spring!08 27 A Typical Memory Hierarchy c.2008 Split instruction & data primary caches (on-chip SRAM) Multiple interleaved memory banks (off-chip DRAM) CPU RF L1 Instruction L1 Unified L2 Memory Memory Memory Memory Multiported register file (part of CPU) Large unified secondary cache (on-chip SRAM) 2/14/2008 CS152-Spring!08 28

Itanium-2 On-Chip s (Intel/HP, 2002) Level 1, 16KB, 4-way s.a., 64B line, quad-port (2 load+2 store), single cycle latency Level 2, 256KB, 4-way s.a, 128B line, quad-port (4 load or 4 store), five cycle latency Level 3, 3MB, 12-way s.a., 128B line, single 32B port, twelve cycle latency 2/14/2008 CS152-Spring!08 29 Workstation Memory System (Apple PowerMac G5, 2003) Dual 2GHz processors, each has: 64KB I-cache, direct mapped 32KB D-cache, 2-way 512KB L2 unified cache, 8-way All 128B lines AGP Graphics Card, 533MHz, 32-bit bus, 2.1GB/s PCI-X Expansion, 133MHz, 64-bit bus, 1 GB/s North Bridge Chip 1GHz, 2x32-bit bus, 16GB/s Up to 8GB DDR SDRAM, 400MHz, 128-bit bus, 6.4GB/s 2/14/2008 CS152-Spring!08 30

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/14/2008 CS152-Spring!08 31