ECE 445 – Computer Organization

Slides:



Advertisements
Similar presentations
Lecture 12 Reduce Miss Penalty and Hit Time
Advertisements

Cache Performance 1 Computer Organization II © CS:APP & McQuain Cache Memory and Performance Many of the following slides are taken with.
Performance of Cache Memory
The Memory Hierarchy (Lectures #24) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer Organization.
1  1998 Morgan Kaufmann Publishers Chapter Seven Large and Fast: Exploiting Memory Hierarchy.
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
1 COMP 206: Computer Architecture and Implementation Montek Singh Wed, Nov 9, 2005 Topic: Caches (contd.)
331 Lec20.1Spring :332:331 Computer Architecture and Assembly Language Spring 2005 Week 13 Basics of Cache [Adapted from Dave Patterson’s UCB CS152.
Pipelined Datapath and Control (Lecture #15) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer.
Lecture 32: Chapter 5 Today’s topic –Cache performance assessment –Associative caches Reminder –HW8 due next Friday 11/21/2014 –HW9 due Wednesday 12/03/2014.
Memory: PerformanceCSCE430/830 Memory Hierarchy: Performance CSCE430/830 Computer Architecture Lecturer: Prof. Hong Jiang Courtesy of Yifeng Zhu (U. Maine)
Lecture 31: Chapter 5 Today’s topic –Direct mapped cache Reminder –HW8 due 11/21/
Memory Hierarchy and Cache Design The following sources are used for preparing these slides: Lecture 14 from the course Computer architecture ECE 201 by.
 Higher associativity means more complex hardware  But a highly-associative cache will also exhibit a lower miss rate —Each set has more blocks, so there’s.
CMPE 421 Parallel Computer Architecture
Chapter 5 Large and Fast: Exploiting Memory Hierarchy CprE 381 Computer Organization and Assembly Level Programming, Fall 2013 Zhao Zhang Iowa State University.
The Memory Hierarchy 21/05/2009Lecture 32_CA&O_Engr Umbreen Sabir.
CSIE30300 Computer Architecture Unit 08: Cache Hsin-Chou Chi [Adapted from material by and
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell CS352H: Computer Systems Architecture Topic 11: Memory Hierarchy.
Caches Where is a block placed in a cache? –Three possible answers  three different types AnywhereFully associativeOnly into one block Direct mappedInto.
Lecture Objectives: 1)Explain the relationship between miss rate and block size in a cache. 2)Construct a flowchart explaining how a cache miss is handled.
1 Chapter Seven. 2 Users want large and fast memories! SRAM access times are ns at cost of $100 to $250 per Mbyte. DRAM access times are ns.
DECStation 3100 Block Instruction Data Effective Program Size Miss Rate Miss Rate Miss Rate 1 6.1% 2.1% 5.4% 4 2.0% 1.7% 1.9% 1 1.2% 1.3% 1.2% 4 0.3%
CS.305 Computer Architecture Memory: Caches Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, and from slides kindly made available.
CPE232 Cache Introduction1 CPE 232 Computer Organization Spring 2006 Cache Introduction Dr. Gheith Abandah [Adapted from the slides of Professor Mary Irwin.
Computer Organization CS224 Fall 2012 Lessons 41 & 42.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 5:
1 Chapter Seven. 2 Users want large and fast memories! SRAM access times are ns at cost of $100 to $250 per Mbyte. DRAM access times are ns.
Memory Hierarchy and Caches. Who Cares about Memory Hierarchy? Processor Only Thus Far in Course CPU-DRAM Gap 1980: no cache in µproc; level cache,
Computer Organization CS224 Fall 2012 Lessons 39 & 40.
Caches 1 Computer Organization II © McQuain Memory Technology Static RAM (SRAM) – 0.5ns – 2.5ns, $2000 – $5000 per GB Dynamic RAM (DRAM)
The Memory Hierarchy (Lectures #17 - #20) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer.
Chapter 5 Large and Fast: Exploiting Memory Hierarchy.
Computer Organization CS224 Fall 2012 Lessons 37 & 38.
Memory Hierarchy— Five Ways to Reduce Miss Penalty.
Cache Issues Computer Organization II 1 Main Memory Supporting Caches Use DRAMs for main memory – Fixed width (e.g., 1 word) – Connected by fixed-width.
CMSC 611: Advanced Computer Architecture
Cache Writing & Performance
Address – 32 bits WRITE Write Cache Write Main Byte Offset Tag Index Valid Tag Data 16K entries 16.
COSC3330 Computer Architecture
Cache Memory and Performance
Morgan Kaufmann Publishers Large and Fast: Exploiting Memory Hierarchy
Morgan Kaufmann Publishers Large and Fast: Exploiting Memory Hierarchy
Morgan Kaufmann Publishers Large and Fast: Exploiting Memory Hierarchy
Morgan Kaufmann Publishers Large and Fast: Exploiting Memory Hierarchy
Improving Memory Access 1/3 The Cache and Virtual Memory
Cache Memory Presentation I
Morgan Kaufmann Publishers Memory & Cache
Morgan Kaufmann Publishers Large and Fast: Exploiting Memory Hierarchy
Memory Hierarchy Lecture notes from MKP, H. H. Lee and S. Yalamanchili.
Morgan Kaufmann Publishers
Morgan Kaufmann Publishers
Morgan Kaufmann Publishers Large and Fast: Exploiting Memory Hierarchy
Morgan Kaufmann Publishers Large and Fast: Exploiting Memory Hierarchy
Morgan Kaufmann Publishers Large and Fast: Exploiting Memory Hierarchy
Integration of cache System into MIPS Pipeline
Morgan Kaufmann Publishers Large and Fast: Exploiting Memory Hierarchy
Systems Architecture II
ECE 445 – Computer Organization
Morgan Kaufmann Publishers Large and Fast: Exploiting Memory Hierarchy
Morgan Kaufmann Publishers
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
Morgan Kaufmann Publishers Memory Hierarchy: Cache Basics
CS 3410, Spring 2014 Computer Science Cornell University
Morgan Kaufmann Publishers Large and Fast: Exploiting Memory Hierarchy
Chapter Five Large and Fast: Exploiting Memory Hierarchy
Cache - Optimization.
Memory Hierarchy Lecture notes from MKP, H. H. Lee and S. Yalamanchili.
Cache Writing & Performance
Memory & Cache.
Presentation transcript:

ECE 445 – Computer Organization The Memory Hierarchy (Lectures #22) The slides included herein were taken from the materials accompanying Computer Organization and Design, 4th Edition, by Patterson and Hennessey, and were used with permission from Morgan Kaufmann Publishers.

ECE 445 - Computer Organization Material to be covered ... Chapter 5: Sections 1 – 5, 11 – 12 Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Address Subdivision Fall 2010 ECE 445 - Computer Organization

Example: Larger Block Size 64 blocks, 16 bytes/block (i.e. 4 words/block) To what block number does address 1200 map? What about address 1212? (Memory) Block address = 1200/16 = 75 (Cache) Block number = 75 modulo 64 = 11 Tag Index Offset 3 4 9 10 31 4 bits 6 bits 22 bits Fall 2010 ECE 445 - Computer Organization

Block Size Considerations Larger blocks should reduce miss rate Due to spatial locality But in a fixed-sized cache Larger blocks  fewer of them More competition  increased miss rate Larger blocks  pollution Larger miss penalty Can override benefit of reduced miss rate Early restart and critical-word-first can help Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Cache Misses On cache hit, CPU proceeds normally On cache miss Stall the CPU pipeline Fetch block from next level of memory hierarchy Instruction cache miss Restart instruction fetch Data cache miss Complete data access Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Write-Through On data-write hit, could just update the block in cache But then cache and memory would be inconsistent Write-through: also update main memory But makes writes take longer e.g., if base CPI = 1, 10% of instructions are stores, write to memory takes 100 cycles Effective CPI = 1 + 0.1×100 = 11 Solution: write buffer Holds data waiting to be written to memory CPU continues immediately Only stalls on write if write buffer is already full Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Write-Back Alternative to Write-Through On data-write hit, just update the block in cache Keep track of whether each block is dirty When a dirty block is replaced Write it back to memory Can use a write buffer to allow replacing block to be read first Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Write Allocation What should happen on a write miss? Alternatives for write-through Allocate on miss: fetch the block Write around: don’t fetch the block For write-back Usually fetch the block Fall 2010 ECE 445 - Computer Organization

Example: Intrinsity FastMATH Embedded MIPS processor 12-stage pipeline Instruction and data access on each cycle Split cache: separate I-cache and D-cache Each 16KB: 256 blocks × 16 words/block D-cache: write-through or write-back (configurable) SPEC2000 miss rates I-cache: 0.4% D-cache: 11.4% Weighted average: 3.2% Fall 2010 ECE 445 - Computer Organization

Example: Intrinsity FastMATH Fall 2010 ECE 445 - Computer Organization

Main Memory Supporting Caches Use DRAMs for main memory Fixed width (e.g., 1 word) Connected by fixed-width clocked bus Bus clock is typically slower than CPU clock Example: cache block read from main memory 1 bus cycle for address transfer (to main memory) 15 bus cycles per DRAM access 1 bus cycle per data transfer (from main memory) For 4-word block, 1-word-wide DRAM Miss penalty = 1 + 4×15 + 4×1 = 65 bus cycles Bandwidth = 16 bytes / 65 cycles = 0.25 B/cycle Fall 2010 ECE 445 - Computer Organization

Increasing Memory Bandwidth 4-word wide memory Miss penalty = 1 + 15 + 1 = 17 bus cycles Bandwidth = 16 bytes / 17 cycles = 0.94 B/cycle 4-bank interleaved memory Miss penalty = 1 + 15 + 4×1 = 20 bus cycles Bandwidth = 16 bytes / 20 cycles = 0.8 B/cycle Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Cache Performance Fall 2010 ECE 445 - Computer Organization

Measuring Cache Performance Components of CPU time Program execution cycles Includes cache hit time Memory stall cycles Mainly from cache misses With simplifying assumptions: Fall 2010 ECE 445 - Computer Organization

Cache Performance Example Given I-cache miss rate = 2% D-cache miss rate = 4% Miss penalty = 100 cycles Base CPI (ideal cache) = 2 Load & stores are 36% of instructions Miss cycles per instruction I-cache: 0.02 × 100 = 2 D-cache: 0.36 × 0.04 × 100 = 1.44 Actual CPI = 2 + 2 + 1.44 = 5.44 Ideal CPU is 5.44/2 =2.72 times faster Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Average Access Time Hit time is also important for performance Average memory access time (AMAT) AMAT = Hit time + Miss rate × Miss penalty Example CPU with 1ns clock, hit time = 1 cycle, miss penalty = 20 cycles, I-cache miss rate = 5% AMAT = 1 + 0.05 × 20 = 2ns 2 cycles per instruction Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Performance Summary When CPU performance increased Miss penalty becomes more significant Decreasing base CPI Greater proportion of time spent on memory stalls Increasing clock rate Memory stalls account for more CPU cycles Can’t neglect cache behavior when evaluating system performance Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Associative Caches Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Associative Caches Fully associative Allow a given block to go in any cache entry Requires all entries to be searched at once Comparator per entry (expensive) n-way set associative Each set contains n entries Block number determines which set (Block number) modulo (#Sets in cache) Search all entries in a given set at once n comparators (less expensive) Fall 2010 ECE 445 - Computer Organization

Associative Cache Example Memory address being accessed is in Block #12 in Main memory. Fall 2010 ECE 445 - Computer Organization

Spectrum of Associativity For a cache with 8 entries Fall 2010 ECE 445 - Computer Organization

Associativity Example Compare 4-block caches Direct mapped (aka. 1-way set associative) 2-way set associative Fully associative Block access sequence: 0, 8, 0, 6, 8 Fall 2010 ECE 445 - Computer Organization

Associativity Example Direct mapped # of Cache Blocks = 4 Block address Cache index Hit/miss Cache content after access 1 2 3 miss Mem[0] 8 Mem[8] 6 Mem[6] Cache index = (Block Address) modulo (# of Cache Blocks) Fall 2010 ECE 445 - Computer Organization

Associativity Example 2-way set associative # of Cache Sets = 2 # of Entries per Set = 2 Block address Cache index Hit/miss Cache content after access Set 0 Set 1 miss Mem[0] 8 Mem[8] hit 6 Mem[6] Cache index = (Block Address) modulo (# of Sets in Cache) Fall 2010 ECE 445 - Computer Organization

Associativity Example Fully associative # of Cache Sets = 1 # of Entries per Set = 4 Block address Hit/miss Cache content after access miss Mem[0] 8 Mem[8] hit 6 Mem[6] Any memory address can be located in any entry of the cache. Fall 2010 ECE 445 - Computer Organization

How Much Associativity Increased associativity decreases miss rate But with diminishing returns Simulation of a system with 64KB D-cache, 16-word blocks; using SPEC2000 benchmark 1-way: 10.3% 2-way: 8.6% 4-way: 8.3% 8-way: 8.1% Fall 2010 ECE 445 - Computer Organization

Set Associative Cache Organization 4-way Set Associative Cache Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Questions? Fall 2010 ECE 445 - Computer Organization