CSCE 212 Chapter 7 Memory Hierarchy Instructor: Jason D. Bakos.

Slides:



Advertisements
Similar presentations
Virtual Memory In this lecture, slides from lecture 16 from the course Computer Architecture ECE 201 by Professor Mike Schulte are used with permission.
Advertisements

1 Lecture 13: Cache and Virtual Memroy Review Cache optimization approaches, cache miss classification, Adapted from UCB CS252 S01.
Computer Organization CS224 Fall 2012 Lesson 44. Virtual Memory  Use main memory as a “cache” for secondary (disk) storage l Managed jointly by CPU hardware.
Lecture 34: Chapter 5 Today’s topic –Virtual Memories 1.
CSIE30300 Computer Architecture Unit 10: Virtual Memory Hsin-Chou Chi [Adapted from material by and
Cs 325 virtualmemory.1 Accessing Caches in Virtual Memory Environment.
The Memory Hierarchy (Lectures #24) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer Organization.
Spring 2003CSE P5481 Introduction Why memory subsystem design is important CPU speeds increase 55% per year DRAM speeds increase 3% per year rate of increase.
1 Lecture 20 – Caching and Virtual Memory  2004 Morgan Kaufmann Publishers Lecture 20 Caches and Virtual Memory.
S.1 Review: The Memory Hierarchy Increasing distance from the processor in access time L1$ L2$ Main Memory Secondary Memory Processor (Relative) size of.
1 Chapter Seven Large and Fast: Exploiting Memory Hierarchy.
1 COMP 206: Computer Architecture and Implementation Montek Singh Mon, Oct 31, 2005 Topic: Memory Hierarchy Design (HP3 Ch. 5) (Caches, Main Memory and.
Chapter 7 Large and Fast: Exploiting Memory Hierarchy Bo Cheng.
ECE 232 L27.Virtual.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 27 Virtual.
Translation Buffers (TLB’s)
Virtual Memory. Why do we need VM? Program address space: 0 – 2^32 bytes –4GB of space Physical memory available –256MB or so Multiprogramming systems.
©UCB CS 162 Ch 7: Virtual Memory LECTURE 13 Instructor: L.N. Bhuyan
1  2004 Morgan Kaufmann Publishers Chapter Seven.
1  1998 Morgan Kaufmann Publishers Chapter Seven Large and Fast: Exploiting Memory Hierarchy (Part II)
©UCB CS 161 Ch 7: Memory Hierarchy LECTURE 24 Instructor: L.N. Bhuyan
Lecture 33: Chapter 5 Today’s topic –Cache Replacement Algorithms –Multi-level Caches –Virtual Memories 1.
Lecture 19: Virtual Memory
Lecture 15: Virtual Memory EEN 312: Processors: Hardware, Software, and Interfacing Department of Electrical and Computer Engineering Spring 2014, Dr.
1  2004 Morgan Kaufmann Publishers Multilevel cache Used to reduce miss penalty to main memory First level designed –to reduce hit time –to be of small.
July 30, 2001Systems Architecture II1 Systems Architecture II (CS ) Lecture 8: Exploiting Memory Hierarchy: Virtual Memory * Jeremy R. Johnson Monday.
The Memory Hierarchy 21/05/2009Lecture 32_CA&O_Engr Umbreen Sabir.
Virtual Memory Expanding Memory Multiple Concurrent Processes.
Virtual Memory. DRAM as cache What about programs larger than DRAM? When we run multiple programs, all must fit in DRAM! Add another larger, slower level.
The Three C’s of Misses 7.5 Compulsory Misses The first time a memory location is accessed, it is always a miss Also known as cold-start misses Only way.
1  1998 Morgan Kaufmann Publishers Recap: Memory Hierarchy of a Modern Computer System By taking advantage of the principle of locality: –Present the.
Virtual Memory. Virtual Memory: Topics Why virtual memory? Virtual to physical address translation Page Table Translation Lookaside Buffer (TLB)
Introduction: Memory Management 2 Ideally programmers want memory that is large fast non volatile Memory hierarchy small amount of fast, expensive memory.
Multilevel Caches Microprocessors are getting faster and including a small high speed cache on the same chip.
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  2004 Morgan Kaufmann Publishers Chapter Seven Memory Hierarchy-3 by Patterson.
CS2100 Computer Organisation Virtual Memory – Own reading only (AY2015/6) Semester 1.
Memory Hierarchy How to improve memory access. Outline Locality Structure of memory hierarchy Cache Virtual memory.
Virtual Memory Ch. 8 & 9 Silberschatz Operating Systems Book.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 5:
Virtual Memory Review Goal: give illusion of a large memory Allow many processes to share single memory Strategy Break physical memory up into blocks (pages)
LECTURE 12 Virtual Memory. VIRTUAL MEMORY Just as a cache can provide fast, easy access to recently-used code and data, main memory acts as a “cache”
Summary of caches: The Principle of Locality: –Program likely to access a relatively small portion of the address space at any instant of time. Temporal.
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.
Virtual Memory 1 Computer Organization II © McQuain Virtual Memory Use main memory as a “cache” for secondary (disk) storage – Managed jointly.
High Performance Computing1 High Performance Computing (CS 680) Lecture 2a: Overview of High Performance Processors * Jeremy R. Johnson *This lecture was.
Memory Management memory hierarchy programs exhibit locality of reference - non-uniform reference patterns temporal locality - a program that references.
CS161 – Design and Architecture of Computer
ECE232: Hardware Organization and Design
Memory COMPUTER ARCHITECTURE
CS161 – Design and Architecture of Computer
Lecture 12 Virtual Memory.
Virtual Memory Use main memory as a “cache” for secondary (disk) storage Managed jointly by CPU hardware and the operating system (OS) Programs share main.
Morgan Kaufmann Publishers
CSCI206 - Computer Organization & Programming
Lecture 21: Memory Hierarchy
Andy Wang Operating Systems COP 4610 / CGS 5765
Lecture 23: Cache, Memory, Virtual Memory
Andy Wang Operating Systems COP 4610 / CGS 5765
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
Translation Buffers (TLB’s)
Translation Buffers (TLB’s)
CSC3050 – Computer Architecture
Virtual Memory Lecture notes from MKP and S. Yalamanchili.
Translation Buffers (TLBs)
Virtual Memory Use main memory as a “cache” for secondary (disk) storage Managed jointly by CPU hardware and the operating system (OS) Programs share main.
Virtual Memory.
Sarah Diesburg Operating Systems CS 3430
Andy Wang Operating Systems COP 4610 / CGS 5765
Review What are the advantages/disadvantages of pages versus segments?
Sarah Diesburg Operating Systems COP 4610
Presentation transcript:

CSCE 212 Chapter 7 Memory Hierarchy Instructor: Jason D. Bakos

CSCE Memory Hierarchy Programmers want more memory and faster memory Problems: –Denser memories require longer access times Example: papers on your desk vs. papers in your filing cabinet –Fast memories are extremely expensive per unit capacity Examples: –SRAM:.5 – 5 ns access time, $1K/GB –DRAM: 50 – 70 ns access time, $100/GB –Magnetic disk: 5 – 20 ms access time, $.10/GB

CSCE Locality Goal: –Achieve the access time of smaller memories but have the effective capacity of larger memories Solution: –Temporal locality memory locations are accessed more than once –Spatial locality when a memory location is accessed, there’s a good chance a nearly location will be accessed in the near future

CSCE Memory Hierarchy

CSCE Memory Hierarchy Each level of the hierarchy stores a subset of the level below it Each level can only communicate with the level below it For now, assume 2-level hierarchy –CPU-cache-RAM –cache is usually on-chip Sometimes the data we need is not in cache –hit rate Block or line –spatial locality miss penalty –time required to move a line to the top of the hierarchy (may vary) CPU cache main memory

CSCE Caches Questions: 1.How do we know if the requested location is in the cache? 2.How do we find it?

CSCE Cache Organization n words tags address(31 downto (log 2 n + 2)) Fully associative –Too many tags to compare!

CSCE Direct Mapped Cache

CSCE Direct Mapped Cache Direct mapped – each memory location maps to only one location in the cache 8 words tags addr(31:8) addr(7:5)

CSCE Addresses The memory address can be partitioned: Example: 128 lines, 16 word lines: tag bits index log 2 lines bits (which line in each set?) word offset log 2 lines_size bits (which word in the line?) byte offset 2 bits (which byte in the word?) tag bits indexword offsetbyte offset 1:05:29:331:10

CSCE Cache Organization

CSCE The Three C’s Three different kinds of misses: –Compulsary (cold-start) misses First access to a block –Capacity misses Replaced block is needed again Because… cache capacity isn’t sufficient for the program –Conflict (collision) misses Multiple blocks compete for the same set

CSCE Associativity 2-way set associative: –Two choices where to store a given line Replacement policy (ex. LRU) 8 words tags 0 addr(31:8) addr(7:5) words tags 1 addr(31:8)

CSCE Associative Cache Organization

CSCE Cache Behavior Hits at the top-level cache can usually be performed in one (or a few) clock cycles Misses stall the processor Writes can be handled using –Write-through (write allocate, write no-allocate) When cache data is changed, the lower level memory is updated immediately Use a write buffer –Write-back When cache data is changed, the lower level memory isn’t updated until the cache line containing the changes is replaced

CSCE Memory Systems Main memory is DRAM, designed for density (not access time) How to reduce miss penalty?

CSCE Average Memory Access Time AMAT = hit_time + miss_rate * miss_penalty Reduce miss rate: –Larger cache (capacity misses) –Increase associativity (conflict misses) –Replacement policy –Each of these may increase hit time and miss penalty Reduce miss penalty: –Wider or banked memory bus

CSCE Virtual Memory Main memory acts as a cache to secondary storage –Allows memory to be shared –Make memory appear to be larger than it physically is Each program has own address space Enforces protection Virtual memory block is called a page, a miss is called a page fault Virtual addresses are translated into physical addresses –Address mapping / address translation –Combination of hardware and software

CSCE Virtual Memory

CSCE Virtual Memory

CSCE Page Faults Main memory is 100,000 times faster than disk –Page faults are expensive Reduce page fault rate –Fully associative placement of pages in memory Each process has a page table that maps virtual addresses to physical addresses OS creates space on disk for all the process’s pages –Swap space OS maintains another table that keeps track of each page in main memory –During a page fault, the OS must decide which page to replace –Least recently used (LRU) –Write-back used for writes

CSCE Page Table

CSCE Page Table

CSCE TLB Page lookups must be performed in hardware –Page table is cached on-chip –Translation-lookaside buffer –Small fully associative or large limited associative

CSCE Integrating Cache and VM Data cannot be in the cache unless it is present in main memory Cache can be –physically addressed (TLB in critical path) –virtually addressed (TLB out of critical path) Cache miss requires TLB access TLB miss means: –page is in memory but we need the TLB entry, or –page is not in memory (page fault) –(both handled by OS software)

CSCE TLB Misses and Page Faults When a virtual address causes a page fault… 1.Look up page table entry and find location on disk 2.Choose a physical page to replace, write-back if dirty 3.Read page from disk into chosen physical page (allow another process to run) TLB miss in MIPS –BadVAddr set, special exception triggered ( ), go to TLB miss handler –Context register: bits 31:20  base of the page table bits 19:2  virtual address of the missing page –Use Context register directly to load missing entry If the page table entry is invalid, a page fault exception occurs at the normal handler ( ) –Move missing entry to EntryLo register –Execute tlbwr to move EntryLo to TLB at address stored in Random register (free running counter) –Execute eret to return TLB miss exception doesn’t save process state (fast) while page fault does (slow)