Ch. 12 Cache Direct Mapped Cache. Comp Sci 251 -- mem hierarchy 2 Memory Hierarchy Registers: very few, very fast cache memory: small, fast main memory:

Slides:



Advertisements
Similar presentations
Cache Memory Exercises. Questions I Given: –memory is little-endian and byte addressable; memory size; –number of cache blocks, size of cache block –An.
Advertisements

Lecture 19: Cache Basics Today’s topics: Out-of-order execution
1 Parallel Scientific Computing: Algorithms and Tools Lecture #2 APMA 2821A, Spring 2008 Instructors: George Em Karniadakis Leopold Grinberg.
© Karen Miller, What do we want from our computers?  correct results we assume this feature, but consider... who defines what is correct?  fast.
CS2100 Computer Organisation Cache II (AY2014/2015) Semester 2.
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.
How caches take advantage of Temporal locality
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.
COMP3221: Microprocessors and Embedded Systems Lecture 26: Cache - II Lecturer: Hui Wu Session 2, 2005 Modified from.
331 Lec20.1Fall :332:331 Computer Architecture and Assembly Language Fall 2003 Week 13 Basics of Cache [Adapted from Dave Patterson’s UCB CS152.
Computer ArchitectureFall 2007 © November 12th, 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
331 Lec20.1Spring :332:331 Computer Architecture and Assembly Language Spring 2005 Week 13 Basics of Cache [Adapted from Dave Patterson’s UCB CS152.
CDA 3103 Computer Organization Review Instructor: Hao Zheng Dept. Comp. Sci & Eng. USF.
COEN 180 Main Memory Cache Architectures. Basics Speed difference between cache and memory is small. Therefore:  Cache algorithms need to be implemented.
CMPE 421 Parallel Computer Architecture
Lecture 19: Virtual Memory
Cache Basics Define temporal and spatial locality.
Multilevel Memory Caches Prof. Sirer CS 316 Cornell University.
How to Build a CPU Cache COMP25212 – Lecture 2. Learning Objectives To understand: –how cache is logically structured –how cache operates CPU reads CPU.
10/18: Lecture topics Memory Hierarchy –Why it works: Locality –Levels in the hierarchy Cache access –Mapping strategies Cache performance Replacement.
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
Computer Science and Engineering Copyright by Hesham El-Rewini Advanced Computer Architecture CSE 8383 January Session 2.
CS2100 Computer Organisation Cache II (AY2015/6) Semester 1.
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.
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.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 5:
CS2100 Computer Organisation Cache I (AY2015/6) Semester 1.
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.
Additional Slides By Professor Mary Jane Irwin Pennsylvania State University Group 1.
3/1/2002CSE Virtual Memory Virtual Memory CPU On-chip cache Off-chip cache DRAM memory Disk memory Note: Some of the material in this lecture are.
COMP 3221: Microprocessors and Embedded Systems Lectures 27: Cache Memory - III Lecturer: Hui Wu Session 2, 2005 Modified.
نظام المحاضرات الالكترونينظام المحاضرات الالكتروني Cache Memory.
Fall EE 333 Lillevik 333f06-l16 University of Portland School of Engineering Computer Organization Lecture 16 Write-through, write-back cache Memory.
Memory Hierarchy and Cache. A Mystery… Memory Main memory = RAM : Random Access Memory – Read/write – Multiple flavors – DDR SDRAM most common 64 bit.
COSC3330 Computer Architecture
Main Memory Cache Architectures
Tutorial Nine Cache CompSci Semester One 2016.
Memory COMPUTER ARCHITECTURE
Lecture 12 Virtual Memory.
How will execution time grow with SIZE?
Lecture: Large Caches, Virtual Memory
Lecture 21: Memory Hierarchy
Lecture 21: Memory Hierarchy
Chapter 8 Digital Design and Computer Architecture: ARM® Edition
Andy Wang Operating Systems COP 4610 / CGS 5765
CSCI206 - Computer Organization & Programming
Lecture 22: Cache Hierarchies, Memory
Andy Wang Operating Systems COP 4610 / CGS 5765
10/16: Lecture Topics Memory problem Memory Solution: Caches Locality
Chap. 12 Memory Organization
CDA 5155 Caches.
CMSC 611: Advanced Computer Architecture
CSE 351: The Hardware/Software Interface
Main Memory Cache Architectures
EE108B Review Session #6 Daxia Ge Friday February 23rd, 2007
Lecture 22: Cache Hierarchies, Memory
CS-447– Computer Architecture Lecture 20 Cache Memories
Lecture 21: Memory Hierarchy
Some of the slides are adopted from David Patterson (UCB)
Chapter Five Large and Fast: Exploiting Memory Hierarchy
Cache Memory and Performance
Lecture 13: Cache Basics Topics: terminology, cache organization (Sections )
Sarah Diesburg Operating Systems CS 3430
Andy Wang Operating Systems COP 4610 / CGS 5765
Sarah Diesburg Operating Systems COP 4610
Presentation transcript:

Ch. 12 Cache Direct Mapped Cache

Comp Sci mem hierarchy 2 Memory Hierarchy Registers: very few, very fast cache memory: small, fast main memory: large, slow secondary memory (disk): huge, very slow Example:

Comp Sci mem hierarchy 3 Memory Hierarchy Registers: very small, very fast cache memory: small, fast  Up to Intel® CoreTM 2 Duo E6700 (2.60GHz, 4MB L2 cache, 1066MHz FSB) main memory: large, slow  Up to 4GB1 Dual-Channel DDR22 SDRAM3 (667MHz) secondary memory (disk): huge, very slow  Up to 2 hard drives and 1 TB of data

Comp Sci mem hierarchy 4 Goal: Illusion of Large Fast Memory Exploit two characteristics of programs: Temporal locality: programs tend to re- access recently accessed locations Spatial locality: programs tend to access neighbors of recently accessed locations

Comp Sci mem hierarchy 5 Exploiting Locality Keep most recently accessed items and their neighbors in faster memory We will focus on the cache/main memory interface

Comp Sci mem hierarchy 6 Terminology Cache hit  word we want to access is already in cache  transaction is fast Cache miss  word we want is not in cache  main memory access is necessary  transaction is slow

Comp Sci mem hierarchy 7 Hit or Miss? Two questions on each memory access: Is the requested word in cache? Where in cache is it? Cache block contains: copy of main memory word(s) info about where word(s) came from (Note: cache block can contain >1 memory word)

Comp Sci mem hierarchy 8 Direct Mapped Cache Each memory word maps to a single cache block “round robin” assignment of words to blocks (assume one-word blocks for now, byte- addressable memory) How do we tell which block a word maps to? number of cache blocks is a power of 2

Comp Sci mem hierarchy 9 Direct Mapped Cache Memory Cache Memory addressdata Memory Address

Comp Sci mem hierarchy 10 Direct Mapped Cache Index0 Index1 Index3 Index2 Index4 Index5 Index6 Index7 Index8 Index9 Index0 Index1 Index3 Index2 Main Memory Index Cache Memory Index

Comp Sci mem hierarchy 11 Direct Mapped Cache If cache has 2 n blocks, cache block index = n bits main memory address: leftover bits are stored in cache as a tag Cache block format: V Tag Data Tag cache index00 Cache index

Comp Sci mem hierarchy 12 Cache Read Operation Look up cache block indexed by low n bits of address Compare Tag in cache with Tag bits of address if valid and match: HIT  read from cache mismatch or invalid: MISS  new word + Tag is brought into cache

Comp Sci mem hierarchy 13 Cache Write Operation (Problem: main memory and cache can become inconsistent) Look up cache block indexed by low n bits of address Compare Tag with high bits of address if valid and match: HIT  write cache and main memory (write-through policy) invalid or mismatch: MISS  write main memory  overwrite cache with new word + Tag

Comp Sci mem hierarchy 14 Exercise Byte-addressable main memory 32-bit main memory addresses 1024KB-capacity cache; one word per cache block  256K = 2 18 cache blocks Show cache block format & address decomposition Access memory address 0x c  Which cache block?  What tag bits?

Comp Sci mem hierarchy 15 Cache Block Size A cache block may contain > 1 main memory word (why is this a good idea?) Example:  byte-addressable memory  4-word cache block Address: | block address |offset|00 |tag|cache index|offset|00

Comp Sci mem hierarchy 16 Exercise Byte-addressable main memory 32-bit main memory addresses 1024KB-capacity cache; four words per cache block  64K=2 16 cache blocks Show cache block format & address decomposition Access memory address 0x c  Which cache block?  What tag bits?

Comp Sci mem hierarchy 17 Address (binary)Contents (Hex) aa bb cc dd ff ee a bc de f0 1a a 3a 4a 5a a 7a 8a 9a b 2b 3b 4b b2 b3 b4 b c1 c2 c3 c d1 d2 d3 d e1 e2 e3 e f1 f2 f3 f a1 a2 a3 a c 3c 4c 5c d 3d 4d 5d Given main memory of 256 bytes, a memory block is one word, cache size (number of blocks ) is 8 What is the total size of the cache in bits? Memory address is m bytes long 256 bytes = 2 m bytes → m = ? You need n bits to address 8 blocks in cache. n = ? You need b bits to address 4 bytes in a word. b = ? Size of tag bits = t = m - n - b Size of cache = (1+ t + 32) x 8

Comp Sci mem hierarchy 18 Address (binary)Contents (Hex) aa bb cc dd ff ee a bc de f0 1a a 3a 4a 5a a 7a 8a 9a b 2b 3b 4b b2 b3 b4 b c1 c2 c3 c d1 d2 d3 d e1 e2 e3 e f1 f2 f3 f a1 a2 a3 a c 3c 4c 5c d 3d 4d 5d Given main memory of 256 bytes, a memory block is 2 words, cache size is 8 What is the total size of the cache in bits? Memory address is m bytes long 256 bytes = 2 m bytes → m = ? You need n bits to address 8 blocks in cache. n = ? You need b bits to address the bytes in 2 words. b = ? Size of tag bits = t = m - n – b Size of cache = (1+ t + 64) x 8

Comp Sci mem hierarchy 19 Suppose a memory address is 32 bits, a memory block is 8 words and the cache size is 16K blocks. What is the total size of the cache in bytes? 32-bit Memory address Data in 8-word block 16K blocks vTag Cache