ECE 445 – Computer Organization

Slides:



Advertisements
Similar presentations
Virtual Memory 1 Computer Organization II © McQuain Virtual Memory Use main memory as a cache for secondary (disk) storage – Managed jointly.
Advertisements

Morgan Kaufmann Publishers Large and Fast: Exploiting Memory Hierarchy
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.
The Memory Hierarchy (Lectures #24) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer Organization.
1 Lecture 20 – Caching and Virtual Memory  2004 Morgan Kaufmann Publishers Lecture 20 Caches and Virtual Memory.
1  1998 Morgan Kaufmann Publishers Chapter Seven Large and Fast: Exploiting Memory Hierarchy.
1  1998 Morgan Kaufmann Publishers Chapter Seven Large and Fast: Exploiting Memory Hierarchy.
1  2004 Morgan Kaufmann Publishers Chapter Seven.
1  1998 Morgan Kaufmann Publishers Chapter Seven Large and Fast: Exploiting Memory Hierarchy (Part II)
1 CSE SUNY New Paltz Chapter Seven Exploiting Memory Hierarchy.
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.
Virtual Memory Expanding Memory Multiple Concurrent Processes.
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 Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University.
Introduction: Memory Management 2 Ideally programmers want memory that is large fast non volatile Memory hierarchy small amount of fast, expensive memory.
Lecture 14: Caching, cont. EEN 312: Processors: Hardware, Software, and Interfacing Department of Electrical and Computer Engineering Spring 2014, Dr.
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.
Computer Organization CS224 Fall 2012 Lessons 41 & 42.
Virtual Memory Ch. 8 & 9 Silberschatz Operating Systems Book.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 5:
1  1998 Morgan Kaufmann Publishers Chapter Seven.
Caches 1 Computer Organization II © McQuain Memory Technology Static RAM (SRAM) – 0.5ns – 2.5ns, $2000 – $5000 per GB Dynamic RAM (DRAM)
The Memory Hierarchy (Lectures #17 - #20) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer.
Chapter 5 Large and Fast: Exploiting Memory Hierarchy.
Virtual Memory 1 Computer Organization II © McQuain Virtual Memory Use main memory as a “cache” for secondary (disk) storage – Managed jointly.
Cache Issues Computer Organization II 1 Main Memory Supporting Caches Use DRAMs for main memory – Fixed width (e.g., 1 word) – Connected by fixed-width.
Virtual Memory Chapter 8.
CS161 – Design and Architecture of Computer Systems
CS161 – Design and Architecture of Computer
CMSC 611: Advanced Computer Architecture
Virtual Memory Chapter 7.4.
COSC3330 Computer Architecture
ECE232: Hardware Organization and Design
Memory COMPUTER ARCHITECTURE
Morgan Kaufmann Publishers Large and Fast: Exploiting Memory Hierarchy
Morgan Kaufmann Publishers Large and Fast: Exploiting Memory Hierarchy
Morgan Kaufmann Publishers Large and Fast: Exploiting Memory Hierarchy
CS161 – Design and Architecture of Computer
Morgan Kaufmann Publishers Large and Fast: Exploiting Memory Hierarchy
CS352H: Computer Systems Architecture
Morgan Kaufmann Publishers Large and Fast: Exploiting Memory Hierarchy
CS 704 Advanced Computer Architecture
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
Morgan Kaufmann Publishers Memory & Cache
Morgan Kaufmann Publishers Large and Fast: Exploiting Memory Hierarchy
Morgan Kaufmann Publishers
Morgan Kaufmann Publishers
Morgan Kaufmann Publishers Large and Fast: Exploiting Memory Hierarchy
ECE 445 – Computer Organization
COSC121: Computer Systems. Managing Memory
Lecture 14 Virtual Memory and the Alpha Memory Hierarchy
Morgan Kaufmann Publishers
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
Contents Memory types & memory hierarchy Virtual memory (VM)
CSC3050 – Computer Architecture
Chapter Five Large and Fast: Exploiting Memory Hierarchy
Memory Hierarchy Lecture notes from MKP, H. H. Lee and S. Yalamanchili.
Virtual Memory Lecture notes from MKP and S. Yalamanchili.
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.
Memory & Cache.
Presentation transcript:

ECE 445 – Computer Organization The Memory Hierarchy (Lectures #23) The slides included herein were taken from the materials accompanying Computer Organization and Design, 4th Edition, by Patterson and Hennessey, and were used with permission from Morgan Kaufmann Publishers.

ECE 445 - Computer Organization Material to be covered ... Chapter 5: Sections 1 – 5, 11 – 12 Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Associative Caches Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Associative Caches Fully associative Allow a given block to go in any cache entry Requires all entries to be searched at once Comparator per entry (expensive) n-way set associative Each set contains n entries Block number determines which set (Block number) modulo (#Sets in cache) Search all entries in a given set at once n comparators (less expensive) Fall 2010 ECE 445 - Computer Organization

Associative Cache Example Memory address being accessed is in Block #12 in Main memory. Fall 2010 ECE 445 - Computer Organization

Spectrum of Associativity For a cache with 8 entries Fall 2010 ECE 445 - Computer Organization

Associativity Example Compare 4-block caches Direct mapped (aka. 1-way set associative) 2-way set associative Fully associative Block access sequence: 0, 8, 0, 6, 8 Fall 2010 ECE 445 - Computer Organization

Associativity Example Direct mapped # of Cache Blocks = 4 Block address Cache index Hit/miss Cache content after access 1 2 3 miss Mem[0] 8 Mem[8] 6 Mem[6] Cache index = (Block Address) modulo (# of Cache Blocks) Fall 2010 ECE 445 - Computer Organization

Associativity Example 2-way set associative # of Cache Sets = 2 # of Entries per Set = 2 Block address Cache index Hit/miss Cache content after access Set 0 Set 1 miss Mem[0] 8 Mem[8] hit 6 Mem[6] Cache index = (Block Address) modulo (# of Sets in Cache) Fall 2010 ECE 445 - Computer Organization

Associativity Example Fully associative # of Cache Sets = 1 # of Entries per Set = 4 Block address Hit/miss Cache content after access miss Mem[0] 8 Mem[8] hit 6 Mem[6] Any memory address can be located in any entry of the cache. Fall 2010 ECE 445 - Computer Organization

How Much Associativity Increased associativity decreases miss rate But with diminishing returns Simulation of a system with 64KB D-cache, 16-word blocks; using SPEC2000 benchmark 1-way: 10.3% 2-way: 8.6% 4-way: 8.3% 8-way: 8.1% Fall 2010 ECE 445 - Computer Organization

Set Associative Cache Organization 4-way Set Associative Cache Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Replacement Policy Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Replacement Policy Direct mapped: no choice Each block in main memory is mapped to exactly one location in the cache. Set associative Prefer non-valid entry, if there is one Otherwise, choose among entries in the set Least-recently used (LRU) Choose the one unused for the longest time Simple for 2-way, manageable for 4-way, too hard beyond that. Random Gives approximately the same performance as LRU for high associativity. Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Multi-level Caches Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Multilevel Caches Primary (L1) cache attached to CPU Small, but fast Level-2 (L2) cache services misses from primary cache Larger, slower, but still faster than main memory Main memory services L2 cache misses Some high-end systems include L3 cache Main Memory CPU L2 L1 Fall 2010 ECE 445 - Computer Organization

Multilevel Cache Example Given CPU base CPI = 1, clock rate = 4GHz Miss rate/instruction = 2% Main memory access time = 100ns With just primary cache Miss penalty = 100ns/0.25ns = 400 cycles Effective CPI = 1 + 0.02 × 400 = 9 Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Example (cont.) Now add L2 cache Access time = 5ns Global miss rate to main memory = 0.5% Primary miss with L2 hit Penalty = 5ns/0.25ns = 20 cycles Primary miss with L2 miss Extra penalty = (0.5%) * (100ns/0.25ns) CPI = 1 + 0.02 × 20 + 0.005 × 400 = 3.4 Performance ratio = 9/3.4 = 2.6 Fall 2010 ECE 445 - Computer Organization

Multilevel Cache Considerations Primary cache Focus on minimal hit time L2 cache Focus on low miss rate to avoid main memory access Hit time has less overall impact Results L1 cache usually smaller than a single cache L1 block size smaller than L-2 block size Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Virtual Memory Fall 2010 ECE 445 - Computer Organization

The term virtual memory as defined by Merriam-Webster: “a section of a hard drive that can be used as if it were an extension of a computer's random-access memory” Fall 2010 ECE 445 - Computer Organization

The term virtual memory as defined by Wikipedia: “Virtual memory is a computer system technique which gives an application program the impression that it has contiguous working memory (an address space), while in fact it may be physically fragmented and may even overflow on to disk storage.” Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Courtesy of Ehamberg (Wikipedia: Virtual Memory) Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization 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 memory Each gets a private virtual address space holding its frequently used code and data Protected from other programs CPU and OS translate virtual addresses to physical addresses VM “block” is called a page VM translation “miss” is called a page fault Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Address Translation Fixed-size pages (e.g., 4K) Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Page Fault Penalty On page fault, the page must be fetched from disk Takes millions of clock cycles Handled by OS code Try to minimize page fault rate Fully associative placement Smart replacement algorithms Fall 2010 ECE 445 - Computer Organization

Page Tables According to Wikipedia: “A page table is the data structure used by a virtual memory system in a computer operating system to store the mapping between virtual addresses and physical addresses. Virtual addresses are those unique to the accessing process. Physical addresses are those unique to the CPU, i.e., RAM.” Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Page Tables Stores placement information Array of page table entries, indexed by virtual page number Page table register in CPU points to page table in physical memory If page is present in memory PTE stores the physical page number Plus other status bits (referenced, dirty, …) If page is not present PTE can refer to location in swap space on disk Fall 2010 ECE 445 - Computer Organization

Translation Using a Page Table Fall 2010 ECE 445 - Computer Organization

Mapping Pages to Storage Fall 2010 ECE 445 - Computer Organization

ECE 445 - Computer Organization Questions? Fall 2010 ECE 445 - Computer Organization