Cache Miss Rate Computations

Slides:



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

1 CMPT 300 Introduction to Operating Systems Page Replacement Sample Questions.
CS420 lecture six Loops. Time Analysis of loops Often easy: eg bubble sort for i in 1..(n-1) for j in 1..(n-i) if (A[j] > A[j+1) swap(A,j,j+1) 1. loop.
LRU Replacement Policy Counters Method Example
Cache Organization Topics Background Simple examples.
Fast matrix multiplication; Cache usage
5/27/99 Ashish Sabharwal1 Cache Misses - The 3 C’s n Compulsory misses –cold start –don’t have a choice –except that by increasing block size, can reduce.
COEN 180 Main Memory Cache Architectures. Basics Speed difference between cache and memory is small. Therefore:  Cache algorithms need to be implemented.
Memory and cache CPU Memory I/O. CEG 320/52010: Memory and cache2 The Memory Hierarchy Registers Primary cache Secondary cache Main memory Magnetic disk.
Chapter 21 Virtual Memoey: Policies Chien-Chung Shen CIS, UD
Computer Architecture Lecture 26 Fasih ur Rehman.
ECE 454 Computer Systems Programming Memory performance (Part II: Optimizing for caches) Ding Yuan ECE Dept., University of Toronto
ICC Module 3 Lesson 2 – Memory Hierarchies 1 / 13 © 2015 Ph. Janson Information, Computing & Communication Memory Hierarchies – Clip 9 – Locality School.
11 Intro to cache memory Kosarev Nikolay MIPT Nov, 2009.
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.
CS422 Principles of Database Systems Buffer Management Chengyu Sun California State University, Los Angeles.
Lecture 5 Cache Operation
CSCI206 - Computer Organization & Programming
CMSC 611: Advanced Computer Architecture
Cache Memories.
Two Dimensional Highly Associative Level-Two Cache Design
Caches Samira Khan March 23, 2017.
CSE 351 Section 9 3/1/12.
The Memory System (Chapter 5)
CS2100 Computer Organization
Memory and cache CPU Memory I/O.
Cache Performance Samira Khan March 28, 2017.
Associativity in Caches Lecture 25
Cache Memories CSE 238/2038/2138: Systems Programming
Chapter 21 Virtual Memoey: Policies
Replacement Policy Replacement policy:
The Hardware/Software Interface CSE351 Winter 2013
Section 7: Memory and Caches
Lecture: Cache Hierarchies
CSE Algorithms Quicksort vs Heapsort: the “inside” story or
Cache Memory Presentation I
Consider a Direct Mapped Cache with 4 word blocks
Lecture 6 Memory Hierarchy
CS 105 Tour of the Black Holes of Computing
Lecture: Large Caches, Virtual Memory
Lecture: Cache Hierarchies
Lecture 23: Cache, Memory, Security
BLAS: behind the scenes
Lecture 21: Memory Hierarchy
Lecture 21: Memory Hierarchy
Bojian Zheng CSCD70 Spring 2018
Memory Hierarchies.
Memory and cache CPU Memory I/O.
Lecture 23: Cache, Memory, Virtual Memory
Lecture 22: Cache Hierarchies, Memory
Lecture 22: Cache Hierarchies, Memory
CDA 5155 Caches.
Overheads for Computers as Components 2nd ed.
M. Usha Professor/CSE Sona College of Technology
Siddhartha Chatterjee
Lecture 15: Memory Design
Recitation 6: Cache Access Patterns
Lecture 22: Cache Hierarchies, Memory
Cache Memories Professor Hugh C. Lauer CS-2011, Machine Organization and Assembly Language (Slides include copyright materials from Computer Systems:
ECE 463/563, Microprocessor Architecture, Prof. Eric Rotenberg
Lecture 21: Memory Hierarchy
Cache - Optimization.
Matrix Addition, C = A + B Add corresponding elements of each matrix to form elements of result matrix. Given elements of A as ai,j and elements of B as.
Cache Memory and Performance
Cache Performance Improvements
Lecture 13: Cache Basics Topics: terminology, cache organization (Sections )
Lecture 14: Cache Performance
Overview Problem Solution CPU vs Memory performance imbalance
Writing Cache Friendly Code
Presentation transcript:

Cache Miss Rate Computations Topics Simple examples

Assumed Simple Cache Cache Block 0 Block 1 2 ints per block 2-way set associative 2 blocks total 1 set i.e., same thing as fully associative Replacement policy: Least Recently Used (LRU) block 8 bytes

Array Access: Key Questions How many array elements are there per block? Does the data structure fit in the cache? Do I re-use blocks over time? In what order am I accessing blocks?

Miss rate = #misses / #accesses Simple Array Cache for (i=0;i<N;i++){ … = A[i]; } A 1 2 3 4 Miss rate = #misses / #accesses

Miss rate = #misses / #accesses = Simple Array Cache for (i=0;i<N;i++){ … = A[i]; } A 1 2 3 4 Miss rate = #misses / #accesses = (N//2) / N = ½ = 50%

Simple Array w outer loop Cache for (k=0;k<P;k++){ for (i=0;i<N;i++){ … = A[i]; } A 1 2 3 4 Assume A[] fits in the cache: Miss rate = #misses / #accesses =

Simple Array w outer loop Cache for (k=0;k<P;k++){ for (i=0;i<N;i++){ … = A[i]; } A 1 2 3 4 Assume A[] fits in the cache: First Visit Miss rate = #misses / #accesses = (N//2) / N = ½ = 50%

Simple Array w outer loop Cache for (k=0;k<P;k++){ for (i=0;i<N;i++){ … = A[i]; } A 1 2 3 4 Assume A[] fits in the cache: Miss rate = #misses / #accesses  0% if P  infinity Lesson: for sequential accesses with re-use, If fits in the cache, first visit suffers all the misses

Assume A[] does not fit in the cache: Miss rate = #misses / #accesses Simple Array Cache for (i=0;i<N;i++){ … = A[i]; } A 1 2 3 4 5 6 7 8 Assume A[] does not fit in the cache: Miss rate = #misses / #accesses

Simple Array Cache for (i=0;i<N;i++){ … = A[i]; } A 5 6 7 8 A 1 2 3 4 5 6 7 8 Assume A[] does not fit in the cache: Miss rate = #misses / #accesses = (N/2) / N = ½ = 50% Lesson: for sequential accesses, if no-reuse it doesn’t matter whether data structure fits

Simple Array with outer loop Cache for (k=0;k<P;k++){ for (i=0;i<N;i++){ … = A[i]; } A 1 2 3 4 5 6 7 8 Assume A[] does not fit in the cache: Miss rate = #misses / #accesses = (N/2) / N = ½ = 50% Lesson: for sequential accesses with re-use, If the data structure doesn’t fit, same miss rate as no-reuse

Assume A[] fits in the cache: Miss rate = #misses / #accesses = 2D array Cache for (i=0;i<N;i++){ for (j=0;j<N;j++){ … = A[i][j]; } A 1 2 3 4 Assume A[] fits in the cache: Miss rate = #misses / #accesses = (N*N/2) / (N*N) = ½ = 50%

2D array Cache A for (i=0;i<N;i++){ for (j=0;j<N;j++){ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 for (i=0;i<N;i++){ for (j=0;j<N;j++){ … = A[i][j]; } Assume A[] does not fit in the cache: Miss rate = #misses / #accesses = 50% Lesson: for 2D accesses, if row order and no-reuse, same hit rate as sequential, whether fits or not

2D array Cache for (j=0;j<N;j++){ A for (i=0;i<N;i++){ … = A[i][j]; } A 1 2 3 4 Assume A[] fits in the cache: Miss rate = #misses / #accesses = (N*N/2) / N*N = ½ = 50% Lesson: for 2D accesses, if column order and no-reuse, same hit rate as sequential if entire column fits in the cache

2D array Cache A for (j=0;j<N;j++){ for (i=0;i<N;i++){ … = A[i][j]; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Assume A[] does not fit in the cache: Miss rate = #misses / #accesses = 100% Lesson: for 2D accesses, if column order, if entire column doesn’t fit, then 100% miss rate (block (1,2) is gone after access to element 9).