15-447 Computer ArchitectureFall 2008 © October 27th, 2008 Majd F. Sakr CS-447– Computer Architecture.

Slides:



Advertisements
Similar presentations
CMPE 421 Parallel Computer Architecture MEMORY SYSTEM.
Advertisements

CML CML CS 230: Computer Organization and Assembly Language Aviral Shrivastava Department of Computer Science and Engineering School of Computing and Informatics.
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.
1 Lecture 20 – Caching and Virtual Memory  2004 Morgan Kaufmann Publishers Lecture 20 Caches and Virtual Memory.
CS 61C L20 Caches I (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C : Machine.
COMP3221 lec33-Cache-I.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lectures 12: Cache Memory - I
1  1998 Morgan Kaufmann Publishers Chapter Seven Large and Fast: Exploiting Memory Hierarchy.
CS61C L23 Caches I (1) Beamer, Summer 2007 © UCB Scott Beamer, Instructor inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #23 Cache I.
CS61C L21 Caches I (1) Garcia, Fall 2005 © UCB Lecturer PSOE, new dad Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C : Machine.
1 Chapter Seven Large and Fast: Exploiting Memory Hierarchy.
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.
Caching I Andreas Klappenecker CPSC321 Computer Architecture.
1  1998 Morgan Kaufmann Publishers Chapter Seven Large and Fast: Exploiting Memory Hierarchy.
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.
1  2004 Morgan Kaufmann Publishers Chapter Seven.
CS 61C L21 Caches II (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C : Machine.
1 SRAM: –value is stored on a pair of inverting gates –very fast but takes up more space than DRAM (4 to 6 transistors) DRAM: –value is stored as a charge.
©UCB CS 161 Ch 7: Memory Hierarchy LECTURE 14 Instructor: L.N. Bhuyan
1 CSE SUNY New Paltz Chapter Seven Exploiting Memory Hierarchy.
Computer ArchitectureFall 2007 © November 12th, 2007 Majd F. Sakr CS-447– Computer Architecture.
DAP Spr.‘98 ©UCB 1 Lecture 11: Memory Hierarchy—Ways to Reduce Misses.
Systems I Locality and Caching
CPE432 Chapter 5A.1Dr. W. Abu-Sufah, UJ Chapter 5A: Exploiting the Memory Hierarchy, Part 1 Adapted from Slides by Prof. Mary Jane Irwin, Penn State University.
CMPE 421 Parallel Computer Architecture
CS1104: Computer Organisation School of Computing National University of Singapore.
Five Components of a Computer
Lecture 19 Today’s topics Types of memory Memory hierarchy.
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 10 Memory Hierarchy.
EEL5708/Bölöni Lec 4.1 Fall 2004 September 10, 2004 Lotzi Bölöni EEL 5708 High Performance Computer Architecture Review: Memory Hierarchy.
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.
CSE378 Intro to caches1 Memory Hierarchy Memory: hierarchy of components of various speeds and capacities Hierarchy driven by cost and performance In early.
Csci 211 Computer System Architecture – Review on Cache Memory Xiuzhen Cheng
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.
Caches Hiding Memory Access Times. PC Instruction Memory 4 MUXMUX Registers Sign Ext MUXMUX Sh L 2 Data Memory MUXMUX CONTROLCONTROL ALU CTL INSTRUCTION.
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.
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.
1  1998 Morgan Kaufmann Publishers Chapter Seven.
Adapted from Computer Organization and Design, Patterson & Hennessy, UCB ECE232: Hardware Organization and Design Part 14: Memory Hierarchy Chapter 5 (4.
1 Chapter Seven. 2 SRAM: –value is stored on a pair of inverting gates –very fast but takes up more space than DRAM (4 to 6 transistors) DRAM: –value.
Memory Management memory hierarchy programs exhibit locality of reference - non-uniform reference patterns temporal locality - a program that references.
Advanced Computer Architecture CS 704 Advanced Computer Architecture Lecture 26 Memory Hierarchy Design (Concept of Caching and Principle of Locality)
COSC3330 Computer Architecture
The Goal: illusion of large, fast, cheap memory
Today How’s Lab 3 going? HW 3 will be out today
Morgan Kaufmann Publishers Memory & Cache
Instructor Paul Pearce
Cache Memories September 30, 2008
Cache Memory.
Memory Hierarchy Memory: hierarchy of components of various speeds and capacities Hierarchy driven by cost and performance In early days Primary memory.
CS-447– Computer Architecture Lecture 20 Cache Memories
Lecturer PSOE Dan Garcia
Some of the slides are adopted from David Patterson (UCB)
Memory Hierarchy Memory: hierarchy of components of various speeds and capacities Hierarchy driven by cost and performance In early days Primary memory.
Csci 211 Computer System Architecture – Review on Cache Memory
Chapter Five Large and Fast: Exploiting Memory Hierarchy
Cache Memory and Performance
Presentation transcript:

Computer ArchitectureFall 2008 © October 27th, 2008 Majd F. Sakr CS-447– Computer Architecture Lecture 19 Memory Hierarchy

Computer ArchitectureFall 2008 © During This Lecture °Introduction to the Memory Hierarchy Processor Memory Gap Locality Latency Hiding

Computer ArchitectureFall 2008 © The Big Picture Processor (active) Computer Control (“brain”) Datapath (“brawn”) Memory (passive) (where programs, data live when running) Devices Input Output Keyboard, Mouse Display, Printer Disk, Network

Computer ArchitectureFall 2008 © Processor-DRAM Memory Gap (latency) µProc 60%/yr. (2X/1.5yr) DRAM 9%/yr. (2X/10 yrs) DRAM CPU 1982 Processor-Memory Performance Gap: (grows 50% / year) Performance Time “Moore’s Law”

Computer ArchitectureFall 2008 © °SRAM: value is stored on a pair of inverting gates very fast but takes up more space than DRAM (4 to 6 transistors) Memories:

Computer ArchitectureFall 2008 © DRAM: value is stored as a charge on capacitor (must be refreshed) very small but slower than SRAM (factor of 5 to 10) Word line Pass Transistor Bit line Capacitor Memories:

Computer ArchitectureFall 2008 © °Users want large and fast memories! °SRAM access times are.5 – 5ns at cost of $4000 to $10,000 per GB. °DRAM access times are 50-70ns at cost of $100 to $200 per GB. °Disk access times are 5 to 20 million ns at cost of $.50 to $2 per GB. Memory 2004

Computer ArchitectureFall 2008 © Storage Trends metric :1980 $/MB8, ,000 access (ns) typical size(MB) ,00015,000 DRAM metric :1980 $/MB19,2002, access (ns) SRAM metric :1980 $/MB ,000 access (ms) typical size(MB) ,0009,000400,000400,000 Disk

Computer ArchitectureFall 2008 © CPU Clock Rates :1980 processor PentiumP-IIIP-4 clock rate(MHz) ,0003,000 cycle time(ns)1, ,333

Computer ArchitectureFall 2008 © The CPU-Memory Gap The gap widens between DRAM, disk, and CPU speeds.

Computer ArchitectureFall 2008 © Locality °Principle of Locality: Programs tend to reuse data and instructions near those they have used recently, or that were recently referenced themselves. Temporal locality: Recently referenced items are likely to be referenced in the near future. Spatial locality: Items with nearby addresses tend to be referenced close together in time. Locality Example: Data –Reference array elements in succession (stride-1 reference pattern): –Reference sum each iteration: Instructions –Reference instructions in sequence: –Cycle through loop repeatedly: sum = 0; for (i = 0; i < n; i++) sum += a[i]; return sum; Spatial locality Temporal locality

Computer ArchitectureFall 2008 © Locality Example °Claim: Being able to look at code and get a qualitative sense of its locality is a key skill for a professional programmer. °Question: Does this function have good locality? int sum_array_rows(int a[M][N]) { int i, j, sum = 0; for (i = 0; i < M; i++) for (j = 0; j < N; j++) sum += a[i][j]; return sum; }

Computer ArchitectureFall 2008 © Locality Example °Question: Does this function have good locality? int sum_array_cols(int a[M][N]) { int i, j, sum = 0; for (j = 0; j < N; j++) for (i = 0; i < M; i++) sum += a[i][j]; return sum; }

Computer ArchitectureFall 2008 © Memory Hierarchy (1/3) °Processor executes instructions on order of nanoseconds to picoseconds holds a small amount of code and data in registers °Memory More capacity than registers, still limited Access time ~ ns °Disk HUGE capacity (virtually limitless) VERY slow: runs ~milliseconds

Computer ArchitectureFall 2008 © Memory Hierarchy (2/3) Processor Size of memory at each level Increasing Distance from Proc., Decreasing speed Level 1 Level 2 Level n Level 3... Higher Lower Levels in memory hierarchy As we move to deeper levels the latency goes up and price per bit goes down.

Computer ArchitectureFall 2008 © Memory Hierarchy (3/3) °If level closer to Processor, it must be: smaller faster subset of lower levels (contains most recently used data) °Lowest Level (usually disk) contains all available data °Other levels?

Computer ArchitectureFall 2008 © Memory Caching °We’ve discussed three levels in the hierarchy: processor, memory, disk °Mismatch between processor and memory speeds leads us to add a new level: a memory cache °Implemented with SRAM technology

Computer ArchitectureFall 2008 © Memory Hierarchy Analogy: Library (1/2) °You’re writing a term paper (Processor) at a table in 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

Computer ArchitectureFall 2008 © Memory Hierarchy Analogy: Library (2/2) °Open books on table are 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

Computer ArchitectureFall 2008 © Memory Hierarchy Basis °Disk contains everything. °When Processor needs something, bring it into to all higher levels of 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)

Computer ArchitectureFall 2008 © Locality °A principle that makes having a memory hierarchy a good idea °If an item is referenced, temporal locality: it will tend to be referenced again soon spatial locality: nearby items will tend to be referenced soon.

Computer ArchitectureFall 2008 © A View of the Memory Hierarchy Regs L2 Cache Memory Disk Tape Instr. Operands Blocks Pages Files Upper Level Lower Level Faster Larger Cache Blocks

Computer ArchitectureFall 2008 © Our initial focus: two levels (upper, lower) block: minimum unit of data hit: data requested is in the upper level miss: data requested is not in the upper level Cache

Computer ArchitectureFall 2008 © 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.) °How do we know which elements are in cache? °How do we quickly locate them?

Computer ArchitectureFall 2008 © Direct Mapped Cache °Mapping: address is modulo the number of blocks in the cache

Computer ArchitectureFall 2008 © 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 if it exists in the cache Block is the unit of transfer between cache and memory

Computer ArchitectureFall 2008 © Direct-Mapped Cache (2/2) °Cache Location 0 can be occupied by data from: Memory location 0, 4, 8,... 4 blocks => any memory location that is multiple of 4 Memory Memory Address A B C D E F 4 Byte Direct Mapped Cache Cache Index

Computer ArchitectureFall 2008 © Issues with Direct-Mapped °Since multiple memory addresses map to same cache index, how do we tell which one is in there? °What if we have a block size > 1 byte? °Answer: divide memory address into three fields ttttttttttttttttt iiiiiiiiii oooo tagindexbyte to checkto offset if have selectwithin correct blockblockblock WIDTHHEIGHT Tag Index Offset

Computer ArchitectureFall 2008 © Direct-Mapped Cache Terminology °All fields are read as unsigned integers. °Index: specifies the cache index (which “row” of the cache we should look in) °Offset: once we’ve found correct block, specifies which byte within the block we want -- I.e., which “column” °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

Computer ArchitectureFall 2008 © Direct Mapped Cache (for MIPS)

Computer ArchitectureFall 2008 © 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 °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

Computer ArchitectureFall 2008 © 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) # blocks/cache =bytes/cache bytes/block = 2 14 bytes/cache 2 4 bytes/block =2 10 blocks/cache need 10 bits to specify this many rows

Computer ArchitectureFall 2008 © Direct-Mapped Cache Example (3/3) °Tag: use remaining bits as tag tag length = addr length - offset - index = 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)

Computer ArchitectureFall 2008 © TIO cache mnemonic AREA (cache size, B) = HEIGHT (# of blocks) * WIDTH (size of one block, B/block) WIDTH (size of one block, B/block) HEIGHT (# of blocks) AREA (cache size, B) 2 (H+W) = 2 H * 2 W Tag Index Offset