CSCE614 HW4: Implementing Pseudo-LRU Cache Replacement Policy

Slides:



Advertisements
Similar presentations
361 Computer Architecture Lecture 15: Cache Memory
Advertisements

Project : Phase 1 Grading Default Statistics (40 points) Values and Charts (30 points) Analyses (10 points) Branch Predictor Statistics (30 points) Values.
Tutorial 8 March 9, 2012 TA: Europa Shang
1 COMP 206: Computer Architecture and Implementation Montek Singh Wed., Oct. 23, 2002 Topic: Memory Hierarchy Design (HP3 Ch. 5) (Caches, Main Memory and.
10/20: Lecture Topics HW 3 Problem 2 Caches –Types of cache misses –Cache performance –Cache tradeoffs –Cache summary Input/Output –Types of I/O Devices.
1 Cache and Caching David Sands CS 147 Spring 08 Dr. Sin-Min Lee.
Virtual Memory Introduction to Operating Systems: Module 9.
Lecture 34: Chapter 5 Today’s topic –Virtual Memories 1.
On-Chip Cache Analysis A Parameterized Cache Implementation for a System-on-Chip RISC CPU.
The Lord of the Cache Project 3. Caches Three common cache designs: Direct-Mapped store in exactly one cache line Fully Associative store in any cache.
Multilevel Memory Caches Prof. Sirer CS 316 Cornell University.
Power Efficient IP Lookup with Supernode Caching Lu Peng, Wencheng Lu*, and Lide Duan Dept. of Electrical & Computer Engineering Louisiana State University.
Review CPSC 321 Andreas Klappenecker Announcements Tuesday, November 30, midterm exam.
1 COMP 206: Computer Architecture and Implementation Montek Singh Mon, Oct 31, 2005 Topic: Memory Hierarchy Design (HP3 Ch. 5) (Caches, Main Memory and.
LRU Replacement Policy Counters Method Example
1 COMP 206: Computer Architecture and Implementation Montek Singh Mon., Nov. 3, 2003 Topic: Memory Hierarchy Design (HP3 Ch. 5) (Caches, Main Memory and.
Cache Organization Topics Background Simple examples.
CSCE 212 Quiz 11 – 4/13/11 Given a direct-mapped cache with 8 one-word blocks and the following 32-bit memory address references: 1 2, ,
Cache Memories Effectiveness of cache is based on a property of computer programs called locality of reference Most of programs time is spent in loops.
COEN 180 Main Memory Cache Architectures. Basics Speed difference between cache and memory is small. Therefore:  Cache algorithms need to be implemented.
Caches – basic idea Small, fast memory Stores frequently-accessed blocks of memory. When it fills up, discard some blocks and replace them with others.
Maninder Kaur CACHE MEMORY 24-Nov
Chapter Twelve Memory Organization
Multilevel Memory Caches Prof. Sirer CS 316 Cornell University.
10/18: Lecture topics Memory Hierarchy –Why it works: Locality –Levels in the hierarchy Cache access –Mapping strategies Cache performance Replacement.
CSIT 301 (Blum)1 Cache Based in part on Chapter 9 in Computer Architecture (Nicholas Carter)
Cache Memory By Tom Austin. What is cache memory? A cache is a collection of duplicate data, where the original data is expensive to fetch or compute.
APS105 Lists. Structures Arrays allow a collection of elements –All of the same type How to collect elements of different types? –Structures; in C: struct.
DECStation 3100 Block Instruction Data Effective Program Size Miss Rate Miss Rate Miss Rate 1 6.1% 2.1% 5.4% 4 2.0% 1.7% 1.9% 1 1.2% 1.3% 1.2% 4 0.3%
Cache Memory Chapter 17 S. Dandamudi To be used with S. Dandamudi, “Fundamentals of Computer Organization and Design,” Springer,  S. Dandamudi.
11 Intro to cache memory Kosarev Nikolay MIPT Nov, 2009.
Memory Hierarchy: Terminology Hit: data appears in some block in the upper level (example: Block X)  Hit Rate : the fraction of memory access found in.
Lecture 20 Last lecture: Today’s lecture: Types of memory
Linked list: a list of items (nodes), in which the order of the nodes is determined by the address, called the link, stored in each node C++ Programming:
CAM Content Addressable Memory
Cache Small amount of fast memory Sits between normal main memory and CPU May be located on CPU chip or module.
Cache Memory Yi-Ning Huang. Principle of Locality Principle of Locality A phenomenon that the recent used memory location is more likely to be used again.
CSCI206 - Computer Organization & Programming
Virtual Memory Chapter 7.4.
CSE 351 Section 9 3/1/12.
Review Deleting an Element from a Linked List Deletion involves:
Associativity in Caches Lecture 25
CAM Content Addressable Memory
Replacement Policy Replacement policy:
Multilevel Memories (Improving performance using alittle “cash”)
CSE Algorithms Quicksort vs Heapsort: the “inside” story or
Caches III CSE 351 Autumn 2017 Instructor: Justin Hsia
Cache Memory Presentation I
Consider a Direct Mapped Cache with 4 word blocks
Adaptive Cache Replacement Policy
AVL Trees CENG 213 Data Structures.
EECE.4810/EECE.5730 Operating Systems
Replacement Policies Assume all accesses are: Cache Replacement Policy
Module IV Memory Organization.
Cache Memory.
Module IV Memory Organization.
CDA 5155 Caches.
Adapted from slides by Sally McKee Cornell University
EE108B Review Session #6 Daxia Ge Friday February 23rd, 2007
Caches III CSE 351 Autumn 2018 Instructor: Justin Hsia
Practical Session 8, Memory Management 2
Cache Memory and Performance
Chapter 9: Virtual Memory CSS503 Systems Programming
Practical Session 9, Memory Management continues
Virtual Memory.
Data Structures Using C++ 2E
10/18: Lecture Topics Using spatial locality
Caches III CSE 351 Spring 2019 Instructor: Ruth Anderson
Overview Problem Solution CPU vs Memory performance imbalance
Presentation transcript:

CSCE614 HW4: Implementing Pseudo-LRU Cache Replacement Policy 11/3/2011 Baik Song An

Pseudo-LRU (PLRU) Finds an item that most likely has not been accessed very recently, given a set of items and a sequence of access events to the items Lower overheads compared to true LRU 4-way cache set True LRU: 6 bits needed per set Pseudo-LRU : 3 bits needed per set

Algorithm Use of a binary search tree for each set Represented by bit flags Each bit represents one branch point in a binary decision tree 1 represents The left side has been referenced more recently than the right side “Go right to find a pseudo-LRU element.” 0 vice-versa

Algorithm (Cont’d) Finding a pseudo-LRU element Traverse the tree according to the values of the flags Updating the tree with an access to an item N Traverse the tree to find N During the traversal, set the node flags to denote the direction that is opposite to the direction taken

Example B0 B0 1 Hit CL1 Hit CL0 B1 1 B2 B1 B2 CL0 CL1 CL2 CL3 CL0 CL1 B0 1 Hit CL1 Hit CL0 B1 1 B2 B1 B2 CL0 CL1 CL2 CL3 CL0 CL1 CL2 CL3 B0 1 B0 Miss; CL2 Replaced B1 1 B2 B1 1 B2 1 CL0 CL1 CL2 CL3 CL0 CL1 CL2 CL3

Rules State Replace 00x CL0 01x CL1 1x0 CL2 1x1 CL3 Reference Next State CL0 11_ CL1 10_ CL2 0_1 CL3 0_0 (x: Don’t Care) (_: Unchanged)

Implementation struct cache_set_t { … unsigned int PLRU_bits; }; Adding a variable in a cache set structure definition Unsigned long: 32 bits in x86 Linux Enough for handling 4-way cache sets struct cache_set_t { … unsigned int PLRU_bits; };

cache_access() Access a cache to perform load or store operations Get Tag Value / Set Number from Block Address Look Up Cache using Tag / Set Number Cache Miss Handling (including Block Replacement / Writeback) Cache Hit Handling

Miss Handling in PLRU Add a new case statement in switch() for choosing a new policy Figure out which block should be evicted Need to determine repl (pointer to the replaced block) First, find if there is an invalid block blk->status & CACHE_BLK_VALID If all blocks are valid, choose one by traversing the binary search tree Update PLRU_bits after miss handling

Miss Handling in PLRU (Cont’d) switch(cp->policy) { case LRU: case FIFO: case Random: case PLRU: { } … Determine repl (invalid block / tree traversal) Update PLRU_bits

Cache Hit in PLRU Update PLRU_bits at the end The same as in miss handling Do nothing for cache_fast_hit

Start as early as possible! Tip(s) Start as early as possible! Questions: baiksong@cse.tamu.edu

Good luck!