Some of the slides are adopted from David Patterson (UCB)

Slides:



Advertisements
Similar presentations
M. Mateen Yaqoob The University of Lahore Spring 2014.
Advertisements

Chapter 12 Memory Organization
CMPE 421 Parallel Computer Architecture MEMORY SYSTEM.
CS 430 – Computer Architecture
Modified from notes by Saeid Nooshabadi COMP3221: Microprocessors and Embedded Systems Lecture 25: Cache - I Lecturer:
Memory Subsystem and Cache Adapted from lectures notes of Dr. Patterson and Dr. Kubiatowicz of UC Berkeley.
CS 61C L20 Caches I (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C : Machine.
Modified from notes by Saeid Nooshabadi
COMP3221 lec33-Cache-I.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lectures 12: Cache Memory - I
CS61C L23 Caches I (1) Beamer, Summer 2007 © UCB Scott Beamer, Instructor inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #23 Cache I.
Computer ArchitectureFall 2008 © October 27th, 2008 Majd F. Sakr CS-447– Computer Architecture.
CS61C L21 Caches I (1) Garcia, Fall 2005 © UCB Lecturer PSOE, new dad Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C : Machine.
COMP3221: Microprocessors and Embedded Systems Lecture 26: Cache - II Lecturer: Hui Wu Session 2, 2005 Modified from.
CS61C L32 Caches II (1) Garcia, 2005 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures.
CS61C L31 Caches I (1) Garcia 2005 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures.
CS61C L20 Caches I (1) A Carle, Summer 2006 © UCB inst.eecs.berkeley.edu/~cs61c/su06 CS61C : Machine Structures Lecture #20: Caches Andy Carle.
CS61C L30 Caches I (1) Garcia, Fall 2006 © UCB Shuttle can’t fly over Jan 1?  A computer bug has come up for the shuttle – its computers don’t reset to.
CIS °The Five Classic Components of a Computer °Today’s Topics: Memory Hierarchy Cache Basics Cache Exercise (Many of this topic’s slides were.
Inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Lecture 30 – Caches I Touted as “the fastest CPU on Earth”, IBM’s new Power6 doubles.
Computer ArchitectureFall 2007 © November 12th, 2007 Majd F. Sakr CS-447– Computer Architecture.
Computer ArchitectureFall 2007 © November 7th, 2007 Majd F. Sakr CS-447– Computer Architecture.
COMP3221 lec34-Cache-II.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lectures 34: Cache Memory - II
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
Cs 61C L17 Cache.1 Patterson Spring 99 ©UCB CS61C Cache Memory Lecture 17 March 31, 1999 Dave Patterson (http.cs.berkeley.edu/~patterson) www-inst.eecs.berkeley.edu/~cs61c/schedule.html.
331 Lec20.1Spring :332:331 Computer Architecture and Assembly Language Spring 2005 Week 13 Basics of Cache [Adapted from Dave Patterson’s UCB CS152.
CS61C L31 Caches I (1) Garcia, Spring 2007 © UCB Powerpoint bad!!  Research done at the Univ of NSW says that “working memory”, the brain part providing.
CS 61C L21 Caches II (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C : Machine.
COMP3221 lec37-vm-II.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lectures 13: Virtual Memory - II
Computer ArchitectureFall 2007 © November 12th, 2007 Majd F. Sakr CS-447– Computer Architecture.
CMPE 421 Parallel Computer Architecture
CS1104: Computer Organisation School of Computing National University of Singapore.
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 10 Memory Hierarchy.
CSIE30300 Computer Architecture Unit 08: Cache Hsin-Chou Chi [Adapted from material by and
King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
CS61C L17 Cache1 © UC Regents 1 CS61C - Machine Structures Lecture 17 - Caches, Part I October 25, 2000 David Patterson
CML CML CS 230: Computer Organization and Assembly Language Aviral Shrivastava Department of Computer Science and Engineering School of Computing and Informatics.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Csci 211 Computer System Architecture – Review on Cache Memory Xiuzhen Cheng
Multilevel Caches Microprocessors are getting faster and including a small high speed cache on the same chip.
CS.305 Computer Architecture Memory: Caches Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, and from slides kindly made available.
Inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Lecture 30 – Caches I After more than 4 years C is back at position number 1 in.
1 Chapter Seven CACHE MEMORY AND VIRTUAL MEMORY. 2 SRAM: –value is stored on a pair of inverting gates –very fast but takes up more space than DRAM (4.
What is it and why do we need it? Chris Ward CS147 10/16/2008.
COMP 3221: Microprocessors and Embedded Systems Lectures 27: Cache Memory - III Lecturer: Hui Wu Session 2, 2005 Modified.
Memory Management memory hierarchy programs exhibit locality of reference - non-uniform reference patterns temporal locality - a program that references.
CMSC 611: Advanced Computer Architecture
Computer Organization
Cache Memory and Performance
Memory COMPUTER ARCHITECTURE
Yu-Lun Kuo Computer Sciences and Information Engineering
The Goal: illusion of large, fast, cheap memory
How will execution time grow with SIZE?
Morgan Kaufmann Publishers Memory & Cache
Instructor Paul Pearce
Chapter 8 Digital Design and Computer Architecture: ARM® Edition
Cache Memory.
MICROPROCESSOR MEMORY ORGANIZATION
Memory Hierarchy Memory: hierarchy of components of various speeds and capacities Hierarchy driven by cost and performance In early days Primary memory.
CMSC 611: Advanced Computer Architecture
ECE232: Hardware Organization and Design
Memory Organization.
CS-447– Computer Architecture Lecture 20 Cache Memories
Lecturer PSOE Dan Garcia
Memory Hierarchy Memory: hierarchy of components of various speeds and capacities Hierarchy driven by cost and performance In early days Primary memory.
Some of the slides are adopted from David Patterson (UCB)
Modified from notes by Saeid Nooshabadi
Csci 211 Computer System Architecture – Review on Cache Memory
COMP3221: Microprocessors and Embedded Systems
Fundamentals of Computing: Computer Architecture
Presentation transcript:

Some of the slides are adopted from David Patterson (UCB) ELEC2041 Microprocessors and Interfacing Lectures 31: Cache Memory - I http://webct.edtec.unsw.edu.au/ May 2006 Saeid Nooshabadi saeid@unsw.edu.au 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

Memory Hierarchy (#1/5) Processor Disk 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

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

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

If level is closer to Processor, it must be: 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 Purpose: Faster access to large memory from processor (active) Computer Control (“brain”) Datapath (“brawn”) Memory (passive) (where programs, data live when running) Devices Input Output Keyboard, Mouse Display, Printer Disk, Network 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)

Provides fast (zero wait state access to program and data) 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.

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

On-Chip SRAM requires explicit management by the programmer 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 advance 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!)

How do we organize 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? Rabaey, Jan M. Digital integrated circuits :a design perspective / 2003 P 621.395/138 Meyer-Baese, U.(Uwe),1964- Digital signal processing with field programmable gate arrays / 2001 P 621.3822/133M Furber, Stephen B.(Stephen Bo),1953- ARM system-on-chip architecture / 2000 P 004.22/51

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

Direct-Mapped Cache (#2/2) 4 Byte Direct Mapped Cache Cache Index 1 2 3 Memory Memory Address 1 2 3 4 5 6 7 8 9 A B C D E F 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 Let’s look at the simplest cache one can build. A direct mapped cache that only has 4 bytes. In this direct mapped cache with only 4 bytes, location 0 of the cache can be occupied by data form memory location 0, 4, 8, C, ... and so on. While location 1 of the cache can be occupied by data from memory location 1, 5, 9, ... etc. So in general, the cache location where a memory location can map to is uniquely determined by the 2 least significant bits of the address (Cache Index). For example here, any memory location whose two least significant bits of the address are 0s can go to cache location zero. With so many memory locations to chose from, which one should we place in the cache? Of course, the one we have read or write most recently because by the principle of temporal locality, the one we just touch is most likely to be the one we will need again soon. Of all the possible memory locations that can be placed in cache Location 0, how can we tell which one is in the cache?

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 tag to check have correct block ttttttttttttttttttttttttttttttii index to select block Address from the processor Compare address tag with indexed value to check for match 4 Byte Direct Mapped Cache Cache Index 1 2 3 tttttttttttttttttttttttttttttt

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

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

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 24 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 = 214 bytes block contains 24 bytes (4 words) # rows/cache = # blocks/cache (since there’s one block/row) = bytes/cache bytes/row = 214 bytes/cache 24 bytes/row = 210 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 it is redundant in tag check, thus can leave off to save memory (- 10 bits in this example)

So we create a memory hierarchy: 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 lower level contains “most used” data from next lower level exploits temporal locality Locality of reference is a Big Idea