Lctures 33: Cache Memory - I. Some of the slides are adopted from David Patterson (UCB)

Similar documents
CS61C - Machine Structures. Lecture 17 - Caches, Part I. October 25, 2000 David Patterson

Cache Memory - II. Some of the slides are adopted from David Patterson (UCB)

CS61C : Machine Structures

CS61C : Machine Structures

UC Berkeley CS61C : Machine Structures

CS61C : Machine Structures

UCB CS61C : Machine Structures

UCB CS61C : Machine Structures

UC Berkeley CS61C : Machine Structures

! CS61C : Machine Structures. Lecture 22 Caches I. !!Instructor Paul Pearce! ITʼS NOW LEGAL TO JAILBREAK YOUR PHONE!

CS61C : Machine Structures

Review : Pipelining. Memory Hierarchy

Chapter 2: Memory Hierarchy Design, part 1 - Introducation. Advanced Computer Architecture Mehran Rezaei

COMP 3221: Microprocessors and Embedded Systems

LECTURE 11. Memory Hierarchy

Memory Hierarchy. Mehran Rezaei

Review: Performance Latency vs. Throughput. Time (seconds/program) is performance measure Instructions Clock cycles Seconds.

CS152 Computer Architecture and Engineering Lecture 17: Cache System

ECE468 Computer Organization and Architecture. Memory Hierarchy

Memory Hierarchy, Fully Associative Caches. Instructor: Nick Riasanovsky

CS61C : Machine Structures

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

CS 61C: Great Ideas in Computer Architecture. Direct Mapped Caches

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

CSC Memory System. A. A Hierarchy and Driving Forces

Caches and Memory Hierarchy: Review. UCSB CS240A, Winter 2016

14:332:331. Week 13 Basics of Cache

14:332:331. Week 13 Basics of Cache

Memory Hierarchy Technology. The Big Picture: Where are We Now? The Five Classic Components of a Computer

Levels in memory hierarchy

Caches and Memory Hierarchy: Review. UCSB CS240A, Fall 2017

CHAPTER 6 Memory. CMPS375 Class Notes Page 1/ 16 by Kuo-pao Yang

Registers. Instruction Memory A L U. Data Memory C O N T R O L M U X A D D A D D. Sh L 2 M U X. Sign Ext M U X ALU CTL INSTRUCTION FETCH

Administrivia. Expect new HW out today (functions in assembly!)

Computer and Digital System Architecture

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

Recap: Machine Organization

CpE 442. Memory System

Memory Hierarchy: Caches, Virtual Memory

Caches. Hiding Memory Access Times

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

Welcome to Part 3: Memory Systems and I/O

ECE232: Hardware Organization and Design

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

CS152 Computer Architecture and Engineering Lecture 16: Memory System

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

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

Donn Morrison Department of Computer Science. TDT4255 Memory hierarchies

The Memory Hierarchy 10/25/16

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

CS61C : Machine Structures

CS61C : Machine Structures

EE 4683/5683: COMPUTER ARCHITECTURE


CS 31: Intro to Systems Storage and Memory. Kevin Webb Swarthmore College March 17, 2015

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

Memory hierarchy and cache

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

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

Basic Memory Hierarchy Principles. Appendix C (Not all will be covered by the lecture; studying the textbook is recommended!)

MEMORY. Objectives. L10 Memory

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

Cache Memory and Performance

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

Key Point. What are Cache lines

Memory Hierarchy. Memory Flavors Principle of Locality Program Traces Memory Hierarchies Associativity. (Study Chapter 5)

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

Chapter 6 Memory 11/3/2015. Chapter 6 Objectives. 6.2 Types of Memory. 6.1 Introduction

The University of Adelaide, School of Computer Science 13 September 2018

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

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

Cache Policies. Philipp Koehn. 6 April 2018

CPE 631 Lecture 04: CPU Caches

Caches Part 1. Instructor: Sören Schwertfeger. School of Information Science and Technology SIST

ECE ECE4680

CENG 3420 Computer Organization and Design. Lecture 08: Cache Review. Bei Yu

Chapter 8 :: Topics. Chapter 8 :: Memory Systems. Introduction Memory System Performance Analysis Caches Virtual Memory Memory-Mapped I/O Summary

Memory Hierarchy. Maurizio Palesi. Maurizio Palesi 1

Memory Hierarchy. Maurizio Palesi. Maurizio Palesi 1

(Refer Slide Time 00:01:09)

Question?! Processor comparison!

Course Administration

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

UCB CS61C : Machine Structures

The Memory Hierarchy. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. April 3, 2018 L13-1

Memory. Lecture 22 CS301

Fundamentals of Computer Systems

Chapter Seven. Large & Fast: Exploring Memory Hierarchy

The Memory Hierarchy & Cache

Digital Logic & Computer Design CS Professor Dan Moldovan Spring Copyright 2007 Elsevier 8-<1>

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

Saeid Nooshabadi. Overview. Page Table... COMP Translation Lookaside Buffer (TLB) Microprocessors and Embedded Systems

Memory Hierarchies &

Memory memories memory

Memory. Memory Technologies

Caching Basics. Memory Hierarchies

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

CS61C : Machine Structures

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

The Memory Hierarchy Cache, Main Memory, and Virtual Memory

Transcription:

Lctures 33: Cache Memory - I Some of the slides are adopted from David Patterson (UCB)

Outline Memory Hierarchy On-Chip SRAM Direct-Mapped Cache

Review: ARM System Architecture Fast on-chip RAM External Lower Speed SRAM, Slower DRAM, Much Slower Flash-ROM

Processor Memory Hierarchy (#1/5) executes programs runs on order of nanoseconds to picoseconds needs to access code and data for programs: where are these? Disk HUGE capacity (virtually limitless) VERY slow: runs on order of milliseconds so how do we account for this gap?

Memory Hierarchy (#2/5) Memory (DRAM) smaller than disk (not limitless capacity) contains subset of data on disk: basically portions of programs that are currently being run much faster than disk: memory accesses don t slow down processor quite as much Problem: memory is still too slow (hundreds of nanoseconds) Solution: add more layers - On-chip Memory - On-chip Caches

Higher Levels in memory hierarchy Lower Memory Hierarchy (#3/5) Processor Level 1 Level 2 Level 3... Level n Size of memory at each level Increasing Distance from Proc., Decreasing cost / MB

Memory Hierarchy (#4/5) Hard Disk Processor RAM/ROM DRAM EEPROM Control Memory Datapath Memory Memory Memory Memory Registers Speed: Size: Cost: Fastest Smallest Highest Cache L1 SRAM Cache L2 SRAM Slowest Biggest Lowest

Memory Hierarchy (#5/5) If level is closer to Processor, it must be: smaller faster subset of all lower levels (contains most recently used data) contain at least all the data in all higher levels Lowest Level (usually disk) contains all available data

Memory Hierarchy Computer Processor Memory (active) (passive) Control (where ( brain ) programs, Datapath data live ( brawn ) when running) Devices Input Output Keyboard, Mouse Disk, Network Display, Printer Purpose: Faster access to large memory from processor

Memory Hierarchy Analogy: Library (#1/2) You re writing an assignment paper (Processor) at a table in the Library Library is equivalent to disk essentially limitless capacity very slow to retrieve a book Table is memory smaller capacity: means you must return book when table fills up easier and faster to find a book there once you ve already retrieved it

Memory Hierarchy Analogy: Library (#2/2) Open books on table are on-chip memory/cache smaller capacity: can have very few open books fit on table; again, when table fills up, you must close a book much, much faster to retrieve data Illusion created: whole library open on the tabletop Keep as many recently used books open on table as possible since likely to use again Also keep as many books on table as possible, since faster than going to library shelves

Memory Hierarchy Basis Disk contains everything. When Processor needs something, bring it into to all higher levels of memory. On-chip Memory/Cache contains copies of data in memory that are being used. Memory contains copies of data on disk that are being used. Entire idea is based on Temporal Locality: if we use it now, we ll want to use it again soon (a Big Idea)

On Chip SRAM Memory Provides fast (zero wait state access to program and data) It occupies a portion of address space. Requires explicit management by the programmers. Part of the program has to copy itself from slow external slow memory (eg flash-rom), into the internal on-chip ram and start executing from there Works well for limited number of programs where, the program behaviour and space requirement is well defined.

Applications are copied from the FLASH ROM to int. RAM to make them go faster DSLMU on-chip RAM External mem area External Flash ROM Works only if there are a few well behaved applications Int. SRAM App #3 App #2 App #1 Schedul er

A Case for Cache On-Chip SRAM requires explicit management by the programmer Possible for an embedded system with small number of well defined programs Not possible for a general purpose processor with many programs, where the application mix cannot be determined in advanced - Explicit memory management become difficult We need a mechanism where the copying from the slow external RAM to Int. memory is automated by hardware (Cache!)

Cache Design How do we organize cache? Where does each memory address map to? (Remember that cache is subset of memory, so multiple memory addresses map to the same cache location.) (Books from many shelves are on the same table) How do we know which elements are in cache? How do we quickly locate them?

Direct-Mapped Cache (#1/2) In a direct-mapped cache, each memory address is associated with one possible block within the cache Therefore, we only need to look in a single location in the cache for the data to see if it exists in the cache Block is the unit of transfer between cache and memory

Memory Address 0 12 3 4 5 6 7 8 9 A B C D E F Direct-Mapped Cache (#2/2) Memory Cache Index 0 1 2 3 4 Byte Direct Mapped Cache Block size = 1 byte Cache Location 0 can be occupied by data from: Memory location 0, 4, 8,... In general: any memory location that is multiple of 4

Issues with Direct-Mapped Since multiple memory addresses map to same cache index, how do we tell which one is in there? Store the address information along with the data in the cache Address from the processor ttttttttttttttttttttttttttttttii address tag to check have correct block Compare address tag with indexed value to check for match tttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttt index to select block Cache 4 Byte Direct Index Mapped Cache 0 1 2 3

Direct-Mapped with 1 Byte Blocks Example Address tag block index address tag RAM data RAM decoder compare data hit

Reading Material Steve Furber: ARM System On-Chip; 2nd Ed, Addison-Wesley, 2000, ISBN: 0-201- 67519-6. Chapter 10.

Issues with Direct-Mapped with Larger Blocks Since multiple memory blocks map to same cache index, how do we tell which one is in there? How do we select the bytes in the block? Result: divide memory address into three fields tttttttttttttttttttttttttttttioo tag index byte to check to offset if have select within correct block block block

Direct-Mapped with Larger Blocks Example Address tag block index Byte offset address tag RAM data RAM compare mux hit data

Direct-Mapped Cache Terminology All fields are read as unsigned integers. Index: specifies the cache index (which row or line of the cache we should look in) Offset: once we ve found correct block, specifies which byte within the block we want Tag: the remaining bits after offset and index are determined; these are used to distinguish between all the memory addresses that map to the same location

Direct-Mapped Cache Example (#1/3) Suppose we have a 16KB of data in a direct-mapped cache with 4 word blocks Determine the size of the tag, index and offset fields if we re using a 32-bit architecture (ie. 32 address lines) Offset need to specify correct byte within a block block contains 4 words 16 bytes 2 4 bytes need 4 bits to specify correct byte

Direct-Mapped Cache Example (#2/3) Index: (~index into an array of blocks ) need to specify correct row in cache cache contains 16 KB = 2 14 bytes block contains 2 4 bytes (4 words) # rows/cache = # blocks/cache (since there s one block/row) = bytes/cache bytes/row = 2 14 bytes/cache 2 4 bytes/row = 2 10 rows/cache need 10 bits to specify this many rows

Direct-Mapped Cache Example (#3/3) Tag: use remaining bits as tag tag length = mem addr length - offset -index = 32-4 - 10 bits = 18 bits so tag is leftmost 18 bits of memory address Why not full 32 bit address as tag? All bytes within block need same address (-4b) Index must be same for every address within a block, so its redundant in tag check, thus can leave off to save memory (- 10 bits in this example)

Things to Remember We would like to have the capacity of disk at the speed of the processor: unfortunately this is not feasible. So we create a memory hierarchy: each successively higher level contains most used data from next lower level exploits temporal locality Locality of reference is a Big Idea