Caches 3/23/17. Agenda. The Dataflow Model (of a Computer)

Similar documents
Caches. Samira Khan March 23, 2017

Computer Architecture

Computer Architecture Lecture 19: Memory Hierarchy and Caches. Prof. Onur Mutlu Carnegie Mellon University Spring 2013, 3/19/2014

18-447: Computer Architecture Lecture 17: Memory Hierarchy and Caches. Prof. Onur Mutlu Carnegie Mellon University Spring 2012, 3/26/2012

18-447: Computer Architecture Lecture 22: Memory Hierarchy and Caches. Prof. Onur Mutlu Carnegie Mellon University Spring 2013, 3/27/2013

Caches. Samira Khan March 21, 2017

Memory Hierarchy: Caches, Virtual Memory

EE 4683/5683: COMPUTER ARCHITECTURE

Donn Morrison Department of Computer Science. TDT4255 Memory hierarchies

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

CS152 Computer Architecture and Engineering Lecture 17: Cache System

Question?! Processor comparison!

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

Lecture-14 (Memory Hierarchy) CS422-Spring

Lecture 12. Memory Design & Caches, part 2. Christos Kozyrakis Stanford University

LECTURE 11. Memory Hierarchy

EEC 483 Computer Organization

Lecture 14: Memory Hierarchy. James C. Hoe Department of ECE Carnegie Mellon University

Lecture 2: Memory Systems

CSE502: Computer Architecture CSE 502: Computer Architecture

Course Administration

Spring 2018 :: CSE 502. Cache Design Basics. Nima Honarmand

Key Point. What are Cache lines

Let!s go back to a course goal... Let!s go back to a course goal... Question? Lecture 22 Introduction to Memory Hierarchies

ECE ECE4680

CMPSC 311- Introduction to Systems Programming Module: Caching

Lecture 17 Introduction to Memory Hierarchies" Why it s important " Fundamental lesson(s)" Suggested reading:" (HP Chapter

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Chapter 5A. Large and Fast: Exploiting Memory Hierarchy

Advanced Computer Architecture

Binghamton University. CS-220 Spring Cached Memory. Computer Systems Chapter

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

MIPS) ( MUX

A Cache Hierarchy in a Computer System

Why memory hierarchy? Memory hierarchy. Memory hierarchy goals. CS2410: Computer Architecture. L1 cache design. Sangyeun Cho

Memory Hierarchy. Maurizio Palesi. Maurizio Palesi 1

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

Precise Exceptions and Out-of-Order Execution. Samira Khan

COSC 6385 Computer Architecture - Memory Hierarchies (I)

CS3350B Computer Architecture

Pick a time window size w. In time span w, are there, Multiple References, to nearby addresses: Spatial Locality

Memory Hierarchy. Maurizio Palesi. Maurizio Palesi 1

CMPSC 311- Introduction to Systems Programming Module: Caching

CPU issues address (and data for write) Memory returns data (or acknowledgment for write)

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

EN1640: Design of Computing Systems Topic 06: Memory System

Memory. Lecture 22 CS301

Assignment 1 due Mon (Feb 4pm

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

Levels in memory hierarchy

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

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

CS 61C: Great Ideas in Computer Architecture. The Memory Hierarchy, Fully Associative Caches

CPS101 Computer Organization and Programming Lecture 13: The Memory System. Outline of Today s Lecture. The Big Picture: Where are We Now?

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

Caches (Writing) P & H Chapter 5.2 3, 5.5. Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University

LECTURE 10: Improving Memory Access: Direct and Spatial caches

Memory Hierarchies. Instructor: Dmitri A. Gusev. Fall Lecture 10, October 8, CS 502: Computers and Communications Technology

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

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

Computer Architecture A Quantitative Approach, Fifth Edition. Chapter 2. Memory Hierarchy Design. Copyright 2012, Elsevier Inc. All rights reserved.

ECE232: Hardware Organization and Design

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

Page 1. Memory Hierarchies (Part 2)

Lecture 17: Memory Hierarchy: Cache Design

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

Caches. Han Wang CS 3410, Spring 2012 Computer Science Cornell University. See P&H 5.1, 5.2 (except writes)

Memory Hierarchy. Caching Chapter 7. Locality. Program Characteristics. What does that mean?!? Exploiting Spatial & Temporal Locality

Textbook: Burdea and Coiffet, Virtual Reality Technology, 2 nd Edition, Wiley, Textbook web site:

Memory Hierarchy. Goal: Fast, unlimited storage at a reasonable cost per bit.

Caches Concepts Review

ECE 485/585 Microprocessor System Design

Chapter 6 Caches. Computer System. Alpha Chip Photo. Topics. Memory Hierarchy Locality of Reference SRAM Caches Direct Mapped Associative

CSC D70: Compiler Optimization Memory Optimizations

Lecture 12: Memory hierarchy & caches

Chapter Seven. Large & Fast: Exploring Memory Hierarchy

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

Computer Architecture Memory hierarchies and caches

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

The Memory Hierarchy & Cache

Reducing Hit Times. Critical Influence on cycle-time or CPI. small is always faster and can be put on chip

Copyright 2012, Elsevier Inc. All rights reserved.

Memory hierarchy review. ECE 154B Dmitri Strukov

Topics. Computer Organization CS Improving Performance. Opportunity for (Easy) Points. Three Generic Data Hazards

Locality. Cache. Direct Mapped Cache. Direct Mapped Cache

EITF20: Computer Architecture Part4.1.1: Cache - 2

Chapter 7 Large and Fast: Exploiting Memory Hierarchy. Memory Hierarchy. Locality. Memories: Review

LECTURE 4: LARGE AND FAST: EXPLOITING MEMORY HIERARCHY

EECS 470 Lecture 13. Basic Caches. Fall 2018 Jon Beaumont

CS252 S05. Main memory management. Memory hardware. The scale of things. Memory hardware (cont.) Bottleneck

LECTURE 5: MEMORY HIERARCHY DESIGN

10/16/2017. Miss Rate: ABC. Classifying Misses: 3C Model (Hill) Reducing Conflict Misses: Victim Buffer. Overlapping Misses: Lockup Free Cache

Memory. From Chapter 3 of High Performance Computing. c R. Leduc

Slide Set 9. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng

Sarah L. Harris and David Money Harris. Digital Design and Computer Architecture: ARM Edition Chapter 8 <1>

CS161 Design and Architecture of Computer Systems. Cache $$$$$

CHAPTER 6 Memory. CMPS375 Class Notes (Chap06) Page 1 / 20 Dr. Kuo-pao Yang

EEC 170 Computer Architecture Fall Cache Introduction Review. Review: The Memory Hierarchy. The Memory Hierarchy: Why Does it Work?

Modern Computer Architecture


Transcription:

Agenda Caches Samira Khan March 23, 2017 Review from last lecture Data flow model Memory hierarchy More Caches The Dataflow Model (of a Computer) Von Neumann model: An instruction is fetched and executed in control flow order As specified by the instruction pointer Sequential unless explicit control flow instruction Dataflow model: An instruction is fetched and executed in data flow order i.e., when its operands are ready i.e., there is no instruction pointer Instruction ordering specified by data flow dependence Each instruction specifies who should receive the result An instruction can fire whenever all operands are received Potentially many instructions can execute at the same time Inherently more parallel Data Flow Advantages/Disadvantages Advantages Very good at exploiting irregular parallelism Only real dependencies constrain processing Disadvantages Debugging difficult (no precise state) Interrupt/exception handling is difficult (what is precise state semantics?) Too much parallelism? (Parallelism control needed) High bookkeeping overhead (tag matching, data storage) Memory locality is not exploited 3 4 1

OOO EXECUTION: RESTRICTED DATAFLOW An out-of-order engine dynamically builds the dataflow graph of a piece of the program which piece? An Example The dataflow graph is limited to the instruction window Instruction window: all decoded but not yet retired instructions Can we do it for the whole program? OUT 5 6 The Memory Hierarchy Ideal Memory Zero access time (latency) Infinite capacity Zero cost Infinite bandwidth (to support multiple accesses in parallel) 8 2

The Problem Ideal memory s requirements oppose each other Bigger is slower Bigger à Takes longer to determine the location Faster is more expensive Memory technology: SRAM vs. DRAM vs. Disk vs. Tape Why Memory Hierarchy? We want both fast and large But we cannot achieve both with a single level of memory Idea: Have multiple levels of storage (progressively bigger and slower as the levels are farther from the processor) and ensure most of the data the processor needs is kept in the fast(er) level(s) Higher bandwidth is more expensive Need more banks, more ports, higher frequency, or faster technology 9 10 The Memory Hierarchy move what you use here With good locality of reference, memory appears as fast as and as large as backup everything here big but slow 11 fast small faster per byte cheaper per byte Memory Locality A typical program has a lot of locality in memory references typical programs are composed of loops Temporal: A program tends to reference the same memory location many times and all within a small window of time Spatial: A program tends to reference a cluster of memory locations at a time most notable examples: instruction memory references array/data structure references 12 3

Hierarchical Latency Analysis For a given memory hierarchy level i it has a technology-intrinsic access time of t i, The perceived access time T i is longer than t i Except for the outer-most hierarchy, when looking for a given address there is a chance (hit-rate hi) you hit and access time is ti a chance (miss-rate mi) you miss and access time ti +Ti+1 hi + mi = 1 Thus T i = h i t i + m i (t i + T i+1 ) T i = t i + m i T i+1 Miss-rate of just the references that missed at L i-1 13 Hierarchy Design Considerations Recursive latency equation T i = t i + m i T i+1 The goal: achieve desired T 1 within allowed cost T i» t i is desirable Keep m i low increasing capacity Ci lowers mi, but beware of increasing ti lower mi by smarter management (replacement::anticipate what you don t need, prefetching::anticipate what you will need) Keep T i+1 low faster lower hierarchies, but beware of increasing cost introduce intermediate hierarchies as a compromise 14 Intel Pentium 4 Example 90nm P4, 3.6 GHz if m1=0.1, m2=0.1 L1 D-cache C1 = 16K t1 = 4 cyc int / 9 cycle fp L2 D-cache C2 =1024 KB t2 = 18 cyc int / 18 cyc fp Main memory t3 = ~ 50ns or 180 cyc Notice best case latency is not 1 worst case access latencies are into 500+ cycles T1=7.6, T2=36 if m1=0.01, m2=0.01 T1=4.2, T2=19.8 if m1=0.05, m2=0.01 T1=5.00, T2=19.8 if m1=0.01, m2=0.50 T1=5.08, T2=108 Caching Basics Block (line): Unit of storage in the cache Memory is logically divided into cache blocks that map to locations in the cache When data referenced HIT: If in cache, use cached data instead of accessing memory MISS: If not in cache, bring block into cache Maybe have to kick something else out to do it Some important cache design decisions Placement: where and how to place/find a block in cache? Replacement: what data to remove to make room in cache? Granularity of management: large, small, uniform blocks? Write policy: what do we do about writes? Instructions/data: Do we treat them separately? 16 4

Cache Abstraction and Metrics A Basic Hardware Cache Design We will start with a basic hardware cache design Address Tag Store (is the address in the cache? + bookkeeping) Data Store (stores memory blocks) Then, we will examine a multitude of ideas to make it better Hit/miss? Cache hit rate = (# hits) / (# hits + # misses) = (# hits) / (# accesses) Average memory access time (AMAT) = ( hit-rate * hit-latency ) + ( miss-rate * miss-latency ) Aside: Can reducing AMAT reduce performance? Data 17 18 Blocks and Addressing the Cache Memory is logically divided into fixed-size blocks Each block maps to a location in the cache, determined by the index bits in the address used to index into the tag and data stores 2 bits 3 bits 3 bits Cache access: 1) index into the tag and data stores with index bits in address 2) check valid bit in tag store 3) compare tag bits in address with the stored tag in tag store 00 000 000-00 000 111 01 000 000-01 000 111 10 000 000-10 000 111 Direct-Mapped Cache: Placement and Access Assume byte-addressable memory: 256 bytes, 8-byte blocks à 32 blocks If a block is in the cache (cache hit), the stored tag should be valid and match the tag of the block 19 11 000 000-11 000 111 11 111 000-11 111 111 Memory 20 5

00 000 000-00 000 111 01 000 000-01 000 111 Direct-Mapped Cache: Placement and Access Assume byte-addressable memory: 256 bytes, 8-byte blocks à 32 blocks Assume cache: 64 bytes, 8 blocks Direct-mapped: A block can go to only one location 00 000 000-00 000 111 01 000 000-01 000 111 Direct-Mapped Cache: Placement and Access Assume byte-addressable memory: 256 bytes, 8-byte blocks à 32 blocks Assume cache: 64 bytes, 8 blocks Direct-mapped: A block can go to only one location 2b 3 bits 3 bits 2b 3 bits 3 bits 10 000 000-10 000 111 Address 10 000 000-10 000 111 Address V tag V tag 11 000 000-11 000 111 byte in block 11 000 000-11 000 111 byte in block 11 111 000-11 111 111 Memory 21 Data 11 111 000-11 111 111 Memory Data Addresses with same index contend for the same location Cause conflict misses 22 Direct-Mapped Caches Direct-mapped cache: Two blocks in memory that map to the same index in the cache cannot be present in the cache at the same time One index à one entry Can lead to 0% hit rate if more than one block accessed in an interleaved manner map to the same index Assume addresses A and B have the same index bits but different tag bits A, B, A, B, A, B, A, B, à conflict in the cache index All accesses are conflict misses 23 Set Associativity Addresses 0 and 8 always conflict in direct mapped cache Instead of having one column of 8, have 2 columns of 4 blocks SET V tag 3 bits 2 bits 3 bits V tag byte in block Key idea: Associative memory within the set + Accommodates conflicts better (fewer conflict misses) -- More complex, slower access, larger tag store 24 6

Higher Associativity Full Associativity Fully associative cache A block can be placed in any cache location 5 bits 0 bit 3 bits 4 bits 1 bits 3 bits byte in block + Likelihood of conflict misses even lower -- More tag comparators and wider data mux; larger tags byte in block 25 26 Exercise on Cache Indexing Tag-Index-Offset We assumed 8 byte blocks What happens if we have 16 byte blocks? Cache is 128B, 8 blocks Direct mapped 2-way?? 8-way?? bits? bits 4 bits 1 bits 3 bits 4 bits Direct mapped m memory address bits S = 2 s number of sets s (set) index bits B = 2 b block size b (block) offset bits t = m (s + b) tag bits C = B * S cache size (if direct-mapped) 7

Associativity (and Tradeoffs) Degree of associativity: How many blocks can map to the same index (or set)? Higher associativity ++ Higher hit rate -- Slower cache access time (hit latency and data access latency) -- More expensive hardware (more comparators) Diminishing returns from higher associativity 29 hit rate associativity Issues in Set-Associative Caches Think of each block in a set having a priority Indicating how important it is to keep the block in the cache Key issue: How do you determine/adjust block priorities? There are three key decisions in a set: Insertion, promotion, eviction (replacement) Insertion: What happens to priorities on a cache fill? Where to insert the incoming block, whether or not to insert the block Promotion: What happens to priorities on a cache hit? Whether and how to change block priority Eviction/replacement: What happens to priorities on a cache miss? Which block to evict and how to adjust priorities 30 Eviction/Replacement Policy Which block in the set to replace on a cache miss? Any invalid block first If all are valid, consult the replacement policy Random FIFO Least recently used (how to implement?) Not most recently used Least frequently used Hybrid replacement policies Optimal replacement policy? A B C D -2 31 ACCESS PATTERN: ACBD 32 8

-2-2 ACCESS PATTERN: ACBDE 33 ACCESS PATTERN: ACBDE 34-2 -2-2 ACCESS PATTERN: ACBDE 35 ACCESS PATTERN: ACBDE 36 9

-2 ACCESS PATTERN: ACBDE 37 ACCESS PATTERN: ACBDEB 38-2 ACCESS PATTERN: ACBDEB 39 ACCESS PATTERN: ACBDEB 40 10

Eviction/Replacement Policy Which block in the set to replace on a cache miss? Any invalid block first If all are valid, consult the replacement policy Random FIFO Least recently used (how to implement?) Not most recently used Least frequently used Hybrid replacement policies Optimal replacement policy? 41 11