cache memories 15 213 introduc on to computer systems
play

Cache Memories 15-213: Introduc;on to Computer Systems 12 - PowerPoint PPT Presentation

Carnegie Mellon Cache Memories 15-213: Introduc;on to Computer Systems 12 th Lecture, Oct. 8, 2015 Instructors: Randal E. Bryant and David R. OHallaron


  1. Carnegie Mellon Cache ¡Memories ¡ ¡ 15-­‑213: ¡Introduc;on ¡to ¡Computer ¡Systems ¡ 12 th ¡Lecture, ¡Oct. ¡8, ¡2015 ¡ Instructors: ¡ ¡ Randal ¡E. ¡Bryant ¡and ¡David ¡R. ¡O’Hallaron ¡ 1 Bryant ¡and ¡O’Hallaron, ¡Computer ¡Systems: ¡A ¡Programmer’s ¡Perspec;ve, ¡Third ¡Edi;on ¡

  2. Carnegie Mellon Today ¡ ¢ Cache ¡memory ¡organiza7on ¡and ¡opera7on ¡ ¢ Performance ¡impact ¡of ¡caches ¡ § The ¡memory ¡mountain ¡ § Rearranging ¡loops ¡to ¡improve ¡spa;al ¡locality ¡ § Using ¡blocking ¡to ¡improve ¡temporal ¡locality ¡ ¡ 2 Bryant ¡and ¡O’Hallaron, ¡Computer ¡Systems: ¡A ¡Programmer’s ¡Perspec;ve, ¡Third ¡Edi;on ¡

  3. Carnegie Mellon Example Memory Hierarchy L0: Regs CPU registers hold words Smaller, retrieved from the L1 cache. L1 cache L1: faster, (SRAM) and L1 cache holds cache lines retrieved from the L2 cache. costlier L2 cache L2: (per byte) (SRAM) storage L2 cache holds cache lines devices retrieved from L3 cache L3 cache L3: (SRAM) L3 cache holds cache lines retrieved from main memory. Larger, L4: Main memory slower, (DRAM) and Main memory holds cheaper disk blocks retrieved (per byte) from local disks. storage Local secondary storage L5: devices (local disks) Local disks hold files retrieved from disks on remote servers Remote secondary storage L6: (e.g., Web servers) 3 Bryant ¡and ¡O’Hallaron, ¡Computer ¡Systems: ¡A ¡Programmer’s ¡Perspec;ve, ¡Third ¡Edi;on ¡

  4. Carnegie Mellon General ¡Cache ¡Concept ¡ Smaller, ¡faster, ¡more ¡expensive ¡ Cache ¡ 8 4 ¡ ¡ 9 ¡ 10 14 ¡ ¡ 3 ¡ memory ¡caches ¡a ¡ ¡subset ¡of ¡ the ¡blocks ¡ Data ¡is ¡copied ¡in ¡block-­‑sized ¡ 10 4 ¡ ¡ transfer ¡units ¡ Larger, ¡slower, ¡cheaper ¡memory ¡ Memory ¡ viewed ¡as ¡par77oned ¡into ¡“blocks” ¡ 0 ¡ 1 ¡ 2 ¡ 3 ¡ 4 4 ¡ ¡ 5 ¡ 6 ¡ 7 ¡ 8 ¡ 9 ¡ 10 10 ¡ ¡ 11 ¡ 12 ¡ 13 ¡ 14 ¡ 15 ¡ 4 Bryant ¡and ¡O’Hallaron, ¡Computer ¡Systems: ¡A ¡Programmer’s ¡Perspec;ve, ¡Third ¡Edi;on ¡

  5. Carnegie Mellon Cache ¡Memories ¡ ¢ Cache ¡memories ¡are ¡small, ¡fast ¡SRAM-­‑based ¡memories ¡ managed ¡automa7cally ¡in ¡hardware ¡ § Hold ¡frequently ¡accessed ¡blocks ¡of ¡main ¡memory ¡ ¢ CPU ¡looks ¡first ¡for ¡data ¡in ¡cache ¡ ¢ Typical ¡system ¡structure: ¡ CPU chip Register file Cache ALU memory System bus Memory bus Main I/O Bus interface memory bridge 5 Bryant ¡and ¡O’Hallaron, ¡Computer ¡Systems: ¡A ¡Programmer’s ¡Perspec;ve, ¡Third ¡Edi;on ¡

  6. Carnegie Mellon General ¡Cache ¡Organiza7on ¡(S, ¡E, ¡B) ¡ E ¡= ¡2 e ¡lines ¡per ¡set ¡ set ¡ line ¡ S ¡= ¡2 s ¡sets ¡ Cache ¡size: ¡ C ¡= ¡S ¡x ¡E ¡x ¡B ¡data ¡bytes ¡ B-­‑1 ¡ tag ¡ 0 ¡ 1 ¡ 2 ¡ v ¡ valid ¡bit ¡ B ¡= ¡2 b ¡bytes ¡per ¡cache ¡block ¡(the ¡data) ¡ 6 Bryant ¡and ¡O’Hallaron, ¡Computer ¡Systems: ¡A ¡Programmer’s ¡Perspec;ve, ¡Third ¡Edi;on ¡

  7. Carnegie Mellon Cache ¡Read ¡ • Locate ¡set ¡ • Check ¡if ¡any ¡line ¡in ¡set ¡ has ¡matching ¡tag ¡ E ¡= ¡2 e ¡lines ¡per ¡set ¡ • Yes ¡+ ¡line ¡valid: ¡hit ¡ • Locate ¡data ¡star@ng ¡ at ¡offset ¡ Address ¡of ¡word: ¡ t ¡bits ¡ s ¡bits ¡ b ¡bits ¡ S ¡= ¡2 s ¡sets ¡ tag ¡ set ¡ block ¡ index ¡ offset ¡ data ¡begins ¡at ¡this ¡offset ¡ tag ¡ B-­‑1 ¡ v ¡ 0 ¡ 1 ¡ 2 ¡ valid ¡bit ¡ B ¡= ¡2 b ¡bytes ¡per ¡cache ¡block ¡(the ¡data) ¡ 7 Bryant ¡and ¡O’Hallaron, ¡Computer ¡Systems: ¡A ¡Programmer’s ¡Perspec;ve, ¡Third ¡Edi;on ¡

  8. Carnegie Mellon Example: ¡Direct ¡Mapped ¡Cache ¡(E ¡= ¡1) ¡ Direct ¡mapped: ¡One ¡line ¡per ¡set ¡ Assume: ¡cache ¡block ¡size ¡8 ¡bytes ¡ Address ¡of ¡int: ¡ v ¡ tag ¡ 0 ¡ 1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡ 7 ¡ t ¡bits ¡ 0…01 ¡ 100 ¡ v ¡ tag ¡ 0 ¡ 1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡ 7 ¡ find ¡set ¡ S ¡= ¡2 s ¡sets ¡ v ¡ tag ¡ 0 ¡ 1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡ 7 ¡ tag ¡ v ¡ 0 ¡ 1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡ 7 ¡ 8 Bryant ¡and ¡O’Hallaron, ¡Computer ¡Systems: ¡A ¡Programmer’s ¡Perspec;ve, ¡Third ¡Edi;on ¡

  9. Carnegie Mellon Example: ¡Direct ¡Mapped ¡Cache ¡(E ¡= ¡1) ¡ Direct ¡mapped: ¡One ¡line ¡per ¡set ¡ Assume: ¡cache ¡block ¡size ¡8 ¡bytes ¡ Address ¡of ¡int: ¡ valid? ¡ ¡ ¡+ ¡ match: ¡assume ¡yes ¡= ¡hit ¡ t ¡bits ¡ 0…01 ¡ 100 ¡ v ¡ tag ¡ tag ¡ 0 ¡ 1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡ 7 ¡ block ¡offset ¡ 9 Bryant ¡and ¡O’Hallaron, ¡Computer ¡Systems: ¡A ¡Programmer’s ¡Perspec;ve, ¡Third ¡Edi;on ¡

  10. Carnegie Mellon Example: ¡Direct ¡Mapped ¡Cache ¡(E ¡= ¡1) ¡ Direct ¡mapped: ¡One ¡line ¡per ¡set ¡ Assume: ¡cache ¡block ¡size ¡8 ¡bytes ¡ Address ¡of ¡int: ¡ valid? ¡ ¡ ¡+ ¡ match: ¡assume ¡yes ¡= ¡hit ¡ t ¡bits ¡ 0…01 ¡ 100 ¡ v ¡ tag ¡ 0 ¡ 1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡ 7 ¡ block ¡offset ¡ int ¡(4 ¡Bytes) ¡is ¡here ¡ If ¡tag ¡doesn’t ¡match: ¡old ¡line ¡is ¡evicted ¡and ¡replaced ¡ 10 Bryant ¡and ¡O’Hallaron, ¡Computer ¡Systems: ¡A ¡Programmer’s ¡Perspec;ve, ¡Third ¡Edi;on ¡

  11. Carnegie Mellon Direct-­‑Mapped ¡Cache ¡Simula7on ¡ t=1 ¡ s=2 ¡ b=1 ¡ M=16 ¡bytes ¡(4-­‑bit ¡addresses), ¡B=2 ¡bytes/block, ¡ ¡ x ¡ xx ¡ x ¡ S=4 ¡sets, ¡E=1 ¡Blocks/set ¡ ¡ ¡ Address ¡trace ¡(reads, ¡one ¡byte ¡per ¡read): ¡ miss ¡ ¡ 0 ¡[0000 2 ], ¡ ¡ hit ¡ ¡1 ¡[0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 v ¡ tag ¡ 0 ¡ 1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡ 7 ¡ 12 Bryant ¡and ¡O’Hallaron, ¡Computer ¡Systems: ¡A ¡Programmer’s ¡Perspec;ve, ¡Third ¡Edi;on ¡

  13. Carnegie Mellon E-­‑way ¡Set ¡Associa7ve ¡Cache ¡(Here: ¡E ¡= ¡2) ¡ E ¡= ¡2: ¡Two ¡lines ¡per ¡set ¡ Assume: ¡cache ¡block ¡size ¡8 ¡bytes ¡ Address ¡of ¡short ¡int: ¡ t ¡bits ¡ 0…01 ¡ 100 ¡ compare ¡both ¡ valid? ¡ ¡+ ¡ ¡ match: ¡yes ¡= ¡hit ¡ v ¡ tag tag ¡ ¡ 0 ¡ 1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡ 7 ¡ v ¡ tag ¡ 0 ¡ 1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡ 7 ¡ block ¡offset ¡ 13 Bryant ¡and ¡O’Hallaron, ¡Computer ¡Systems: ¡A ¡Programmer’s ¡Perspec;ve, ¡Third ¡Edi;on ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend