ECE473 Computer Architecture and Organization. Memory Hierarchy: Set Associative Cache

Similar documents
Q3: Block Replacement. Replacement Algorithms. ECE473 Computer Architecture and Organization. Memory Hierarchy: Set Associative Cache

ECE232: Hardware Organization and Design

ECE331: Hardware Organization and Design

14:332:331. Week 13 Basics of Cache

Review: Computer Organization

ECE 30 Introduction to Computer Engineering

The Memory Hierarchy & Cache

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Caches Part 2

CS 61C: Great Ideas in Computer Architecture Caches Part 2

CISC 360. Cache Memories Exercises Dec 3, 2009

ECSE 425 Lecture 20: Cache Basics

ECE232: Hardware Organization and Design

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Caches Part 2

CS 152 Computer Architecture and Engineering. Lecture 7 - Memory Hierarchy-II

10/16/17. Outline. Outline. Typical Memory Hierarchy. Adding Cache to Computer. Key Cache Concepts

CS 152 Computer Architecture and Engineering. Lecture 7 - Memory Hierarchy-II

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Caches Part 2

Memory Hierarchy Motivation, Definitions, Four Questions about Memory Hierarchy

ECEC 355: Cache Design

Figure 1: Organisation for 128KB Direct Mapped Cache with 16-word Block Size and Word Addressable

Memory Hierarchy. Maurizio Palesi. Maurizio Palesi 1

EECS151/251A Spring 2018 Digital Design and Integrated Circuits. Instructors: John Wawrzynek and Nick Weaver. Lecture 19: Caches EE141

Memory Hierarchy. Maurizio Palesi. Maurizio Palesi 1

Cache Memory and Performance

Chapter 2: Memory Hierarchy Design, part 1 - Introducation. Advanced Computer Architecture Mehran Rezaei

CPE300: Digital System Architecture and Design

ECE331 Homework 4. Due Monday, August 13, 2018 (via Moodle)

Topics. Computer Organization CS Improving Performance. Opportunity for (Easy) Points. Three Generic Data Hazards

Paging! 2/22! Anthony D. Joseph and Ion Stoica CS162 UCB Fall 2012! " (0xE0)" " " " (0x70)" " (0x50)"

CS 61C: Great Ideas in Computer Architecture. Direct Mapped Caches, Set Associative Caches, Cache Performance

ECE331: Hardware Organization and Design

Memory Hierarchy: Motivation

Virtual Memory, Address Translation

EECS 470 Lecture 13. Basic Caches. Fall 2018 Jon Beaumont

Chapter Seven. Large & Fast: Exploring Memory Hierarchy

COSC 6385 Computer Architecture - Memory Hierarchies (I)

Virtual Memory, Address Translation

Computer Architecture Spring 2016

ECE331: Hardware Organization and Design

Lec-3-HW-1-cacheVM Consider the following 16-bit machine (datapath and register width is 2B).

CS 3510 Comp&Net Arch

1. Memory technology & Hierarchy

Levels in memory hierarchy

14:332:331. Week 13 Basics of Cache

Direct-Mapped and Set Associative Caches. Instructor: Steven Ho

CISC 662 Graduate Computer Architecture Lecture 16 - Cache and virtual memory review

ECE331: Hardware Organization and Design

COMP 3221: Microprocessors and Embedded Systems

Memory Hierarchy: Caches, Virtual Memory

CS 465 Final Review. Fall 2017 Prof. Daniel Menasce

ECE 2300 Digital Logic & Computer Organization. More Caches

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Advanced Computer Architecture

The Memory Hierarchy & Cache The impact of real memory on CPU Performance. Main memory basic properties: Memory Types: DRAM vs.

Cache memories are small, fast SRAM-based memories managed automatically in hardware. Hold frequently accessed blocks of main memory

Direct Mapped Cache Hardware. Direct Mapped Cache. Direct Mapped Cache Performance. Direct Mapped Cache Performance. Miss Rate = 3/15 = 20%

Lecture 11 Cache. Peng Liu.

Virtual Memory Virtual memory first used to relive programmers from the burden of managing overlays.

Cache Memory COE 403. Computer Architecture Prof. Muhamed Mudawar. Computer Engineering Department King Fahd University of Petroleum and Minerals

10/7/13! Anthony D. Joseph and John Canny CS162 UCB Fall 2013! " (0xE0)" " " " (0x70)" " (0x50)"

COSC 3406: COMPUTER ORGANIZATION

Page 1. Multilevel Memories (Improving performance using a little cash )

Topics. Digital Systems Architecture EECE EECE Need More Cache?

Lecture 7 - Memory Hierarchy-II

CPS104 Computer Organization and Programming Lecture 16: Virtual Memory. Robert Wagner

CSE Computer Architecture I Fall 2011 Homework 07 Memory Hierarchies Assigned: November 8, 2011, Due: November 22, 2011, Total Points: 100

Consider the following 16-bit machine (datapath and register width is 2B).

ECE 2300 Digital Logic & Computer Organization. More Caches

ELEC 5200/6200 Computer Architecture and Design Spring 2017 Lecture 7: Memory Organization Part II

Memory Hierarchy. Slides contents from:

Caching Basics. Memory Hierarchies

Caches Part 1. Instructor: Sören Schwertfeger. School of Information Science and Technology SIST

Fig 7.30 The Cache Mapping Function. Memory Fields and Address Translation

registers data 1 registers MEMORY ADDRESS on-chip cache off-chip cache main memory: real address space part of virtual addr. sp.

ECE473 Computer Architecture and Organization. Pipeline: Control Hazard

Computer Architecture and System Software Lecture 09: Memory Hierarchy. Instructor: Rob Bergen Applied Computer Science University of Winnipeg

CS61C Review of Cache/VM/TLB. Lecture 26. April 30, 1999 Dave Patterson (http.cs.berkeley.edu/~patterson)

Page 1. Review: Address Segmentation " Review: Address Segmentation " Review: Address Segmentation "

Improving our Simple Cache

ECE473 Computer Architecture and Organization. Pipeline: Data Hazards

UCB CS61C : Machine Structures

CS 152 Computer Architecture and Engineering. Lecture 11 - Virtual Memory and Caches

The Memory Hierarchy & Cache Review of Memory Hierarchy & Cache Basics (from 350):

Administrivia. CMSC 411 Computer Systems Architecture Lecture 8 Basic Pipelining, cont., & Memory Hierarchy. SPEC92 benchmarks

Conflicting requirements

CS61C : Machine Structures


CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 27, FALL 2012

Lctures 33: Cache Memory - I. Some of the slides are adopted from David Patterson (UCB)

Computer Architecture. Lecture 8: Virtual Memory

Memory. Lecture 22 CS301

Textbook: Burdea and Coiffet, Virtual Reality Technology, 2 nd Edition, Wiley, Textbook web site:

Virtual or Logical. Logical Addr. MMU (Memory Mgt. Unit) Physical. Addr. 1. (50 ns access)

LECTURE 12. Virtual Memory

COSC 6385 Computer Architecture. - Memory Hierarchies (I)

ELE 758 * DIGITAL SYSTEMS ENGINEERING * MIDTERM TEST * Circle the memory type based on electrically re-chargeable elements

Adapted from instructor s supplementary material from Computer. Patterson & Hennessy, 2008, MK]

CMPSC 311- Introduction to Systems Programming Module: Caching

Basic Memory Hierarchy Principles. Appendix C (Not all will be covered by the lecture; studying the textbook is recommended!)

Reducing Conflict Misses with Set Associative Caches

Transcription:

Computer Architecture and Organization Memory Hierarchy: Set Associative Cache Lecturer: Prof. Yifeng Zhu Fall, 2015 Portions of these slides are derived from: Dave Patterson UCB Lec 28.1

Fundamental Questions Q1: Where can a block be placed in the upper level? (Block placement) Q2: How is a block found if it is in the upper level? (Block identification) Q3: Which block should be replaced on a miss? (Block replacement) Q4: What happens on a write? (Write strategy) Lec 28.2

Q1: Block Placement Where can block be placed in cache? In one predetermined place - direct-mapped» Use fragment of address to calculate block location in cache» Compare cache block with tag to test if block present Anywhere in cache - fully associative» Compare tag to every block in cache In a limited set of places - set-associative» Use address fragment to calculate set (like directmapped)» Place in any block in the set» Compare tag to every block in set» Hybrid of direct mapped and fully associative Lec 28.3

Associativity Considerations DM and FA are special cases of SA cache Set-Associative: n/m sets; m blocks/set Direct-Mapped: m=1 Fully-Associative: m=n Advantage of Associativity: as associativity increases, miss rate decreases (because more blocks per set that we re less likely to overwrite) Disadvantage of Associativity: as associativity increases, hit time increases (because we have to search more blocks more HW required) Block Replacement: LRU or random. Random is easier to implement and often not much worse Lec 28.4

Q2: Block Identification Every cache block has an address tag that identifies its location in memory Hit when tag and address of desired word match (comparison by hardware) Q: What happens when a cache block is empty? A: Mark this condition with a valid bit Valid 1 Tag 0x00001C0 Data 0xff083c2d Lec 28.5

Q2: Block Identification? Tag on each block No need to check index or block offset Increasing associativity shrinks index, expands tag Tag Block Address Index Block Offset Fully Associative: No index Direct Mapped: Large index Lec 28.6

Direct-Mapped Cache Design 0x0000000 Cache Index ADDRESS Tag Byte Offset DATA HIT =1 3 ADDR 0 V 1 0 Tag 0x00001C0 Data 0xff083c2d 1 0x0000000 0x00000021 1 0x0000000 0x00000103 CACHE SRAM 0 0 1 0 0x23F0210 0x00000009 DATA[59] DATA[58:32] = DATA[31:0] Lec 28.7

Fully Associative Cache Design Key idea: set size of one block 1 comparator required for each block No address decoding Practical only for small caches due to hardware demands tag in 11110111 data out 1111000011110000101011 = = tag 00011100 data 0000111100001111111101 tag 11110111 data 1111000011110000101011 = = = tag 11111110 tag 00000011 tag 11100110 data 0000000000001111111100 data 1110111100001110000001 data 1111111111111111111111 Lec 28.8

Set Associative Cache Design Key idea: Address 31 30 12 11 10 9 8 3 2 1 0 Divide cache into sets 22 8 Allow block anywhere in a set Advantages: Better hit rate Index 0 1 2 V Tag Data V Tag Data V Tag Data V Tag Data Disadvantage: More tag bits 253 254 255 22 32 More hardware Higher access time 4-to-1 multiplexor Hit Data A Four-Way Set-Associative Cache Lec 28.9

Calculating Bits in Cache How many total bits are needed for a direct- mapped cache with 64 KBytes of data and one word blocks, assuming a 32-bit address? How many total bits would be needed for a 4-way set associative cache to store the same amount of data How many total bits are needed for a direct- mapped cache with 64 KBytes of data and 8 word blocks, assuming a 32-bit address? Lec 28.10

Calculating Bits in Cache How many total bits are needed for a direct- mapped cache with 64 KBytes of data and one word blocks, assuming a 32-bit address? 64 Kbytes = 16 K words = 2^14 words = 2^14 blocks block size = 4 bytes => offset size = 2 bits, #sets = #blocks = 2^14 => index size = 14 bits tag size = address size - index size - offset size = 32-14 - 2 = 16 bits bits/block = data bits + tag bits + valid bit = 32 + 16 + 1 = 49 bits in cache = #blocks x bits/block = 2^14 x 49 = 98 Kbytes How many total bits would be needed for a 4-way set associative cache to store the same amount of data block size and #blocks does not change #sets = #blocks/4 = (2^14)/4 = 2^12 => index size = 12 bits tag size = address size - index size - offset = 32-12 - 2 = 18 bits bits/block = data bits + tag bits + valid bit = 32 + 18 + 1 = 51 bits in cache = #blocks x bits/block = 2^14 x 51 = 102 Kbytes Increase associativity => increase bits in cache Lec 28.11

Calculating Bits in Cache How many total bits are needed for a direct- mapped cache with 64 KBytes of data and 8 word blocks, assuming a 32-bit address? 64 Kbytes = 2^14 words = (2^14)/8 = 2^11 blocks block size = 32 bytes => offset size = 5 bits, #sets = #blocks = 2^11 => index size = 11 bits tag size = address size - index size - offset size = 32-11 - 5 = 16 bits bits/block = data bits + tag bits + valid bit = 8x32 + 16 + 1 = 273 bits bits in cache = #blocks x bits/block = 2^11 x 273 = 68.25 Kbytes Increase block size => decrease bits in cache Lec 28.12