Exam Review of Cache Memories Dec 11, 2001

Slides:



Advertisements
Similar presentations
CS492B Analysis of Concurrent Programs Memory Hierarchy Jaehyuk Huh Computer Science, KAIST Part of slides are based on CS:App from CMU.
Advertisements

HW/Study Guide. Synchronization Make sure you understand the HW problems!
Faculty of Computer Science © 2006 CMPUT 229 Cache Performance Analysis Hitting for performance.
Chapter 6 The Memory Hierarchy
Recitation 7 Caching By yzhuang. Announcements Pick up your exam from ECE course hub ◦ Average is 43/60 ◦ Final Grade computation? See syllabus
CSSE 332 Functions, Pointers in C. 2 Functions - why and how ? If a problem is large If a problem is large Modularization – easier to: Modularization.
Computer ArchitectureFall 2007 © November 14th, 2007 Majd F. Sakr CS-447– Computer Architecture.
How caches take advantage of Temporal locality
Caches The principle that states that if data is used, its neighbor will likely be used soon.
Lecture 41: Review Session #3 Reminders –Office hours during final week TA as usual (Tuesday & Thursday 12:50pm-2:50pm) Hassan: Wednesday 1pm to 4pm or.
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, ,
Memory Map, Programming Language, and Windows Dr. Harold D. Camp IT February 2007.
Lecture 40: Review Session #2 Reminders –Final exam, Thursday 3:10pm Sloan 150 –Course evaluation (Blue Course Evaluation) Access through.
Lecture 17 Final Review Prof. Mike Schulte Computer Architecture ECE 201.
What we will cover A crash course in the basics of C “Teach yourself C in 21 days”
Additional Slides By Professor Mary Jane Irwin Pennsylvania State University Group 1.
Cache Organization 1 Computer Organization II © CS:APP & McQuain Cache Memory and Performance Many of the following slides are taken with.
CSE 351 Caches. Section Feedback Before we begin, we’d like to get some feedback about section If you could answer the following questions on the provided.
Problem byte direct-mapped cache 16-byte blocks sizeof(int) = 4 struct algae_position{ int x; int y; }; Struct algae_position grid[16][16]; grid.
Introduction to Computer Systems Topics: Assembly Stack discipline Structs/alignment Caching CS 213 S ’12 rec8.pdf “The Class That Gives CMU Its.
CSCI206 - Computer Organization & Programming
CSE 351 Section 9 3/1/12.
Tutorial Nine Cache CompSci Semester One 2016.
The Memory System (Chapter 5)
C Primer.
Day 03 Introduction to C.
Direct Cache Structure
The Hardware/Software Interface CSE351 Winter 2013
Day 03 Introduction to C.
Consider a Direct Mapped Cache with 4 word blocks
INC 161 , CPE 100 Computer Programming
Von Neumann model - Memory
CS 105 Tour of the Black Holes of Computing
Memory hierarchy.
ECE 445 – Computer Organization
Basic notes on pointers in C
Caches and Blocking 8 October 2018.
Lecture 21: Memory Hierarchy
Circular Buffers, Linked Lists
Lecture 21: Memory Hierarchy
Cache Memories September 30, 2008
Bases and Representations, Memory, Pointers, Arrays, For-Loops
Virtual Memory S04, Recitation, Section A
FIGURE 12-1 Memory Hierarchy
Lecture 22: Cache Hierarchies, Memory
Dynamic Memory Allocation
Direct Mapping.
CSE 351: The Hardware/Software Interface
Von Neumann model - Memory
Lecture 20: OOO, Memory Hierarchy
Morgan Kaufmann Publishers Memory Hierarchy: Cache Basics
Lecture 20: OOO, Memory Hierarchy
Siddhartha Chatterjee
Memory Operation and Performance
2 code samples int [] array; int i, j, temp; for(i = 0; i < array.length/2; i++) { j = array.length-1-i; temp = array[i]; array[i] = array[j]; array[j]
Initializing variables
Lecture 22: Cache Hierarchies, Memory
CS 3410, Spring 2014 Computer Science Cornell University
Virtual Memory Prof. Eric Rotenberg
Basic Cache Operation Prof. Eric Rotenberg
Lecture 21: Memory Hierarchy
Cache Memory and Performance
Lecture 13: Cache Basics Topics: terminology, cache organization (Sections )
Cache Memory and Performance
9/27: Lecture Topics Memory Data transfer instructions
15213 C Primer 17 September 2002.
Caches and Blocking 26th February 2018.
Caches III CSE 351 Spring 2019 Instructor: Ruth Anderson
Presentation transcript:

Exam Review of Cache Memories Dec 11, 2001 15-213 “The course that gives CMU its Zip!” Exam Review of Cache Memories Dec 11, 2001 Topics Cache memory organization Cache analysis of C code Sanjit A. Seshia

General organization of a cache memory A cache of size C contains S sets each of which has E cache blocks B bytes Set bits = s = log(S) Associativity E = 1 for direct mapped Block offset bits = b = log(B) C = E x S x B m bits for Addressing #(tag bits) = t = m – (s+b)

Cache Analysis Problem from Fall 1999 Final Exam (also Homework probs 6.28--6.30 in the textbook) Therefore, E = 1 S = 16K = 2^14 Consider the following system: Direct mapped cache Cache size, C = 64Kbytes Block size, B = 4 bytes struct pixel { char r; char g; char b; char a; } struct pixel buffer[480][640]; register int i, j; register char *cptr; register int *iptr; Assumptions: sizeof(char) == 1, sizeof(int) == 4 buffer begins at address 0 Cache is initially empty All other variables are in registers

Cache Analysis(contd) struct pixel { char r; char g; char b; char a; } struct pixel buffer[480][640]; register int i, j; register char *cptr; register int *iptr; A “write” is a write to a C variable of a primitive data type. For pointers, the size of the target location depends on the pointer type. Code is just scanning the entire array once for(j=0; j < 640; j++){ for(i=0; i < 480; i++){ buffer[i][j].r = 0; buffer[i][j].g = 0; buffer[i][j].b = 0; buffer[i][j].a = 0; } What percentage of writes in this code will miss?

Cache Analysis(contd) struct pixel { char r; char g; char b; char a; } struct pixel buffer[480][640]; register int i, j; register char *cptr; register int *iptr; ………. buffer j i for(j=0; j < 640; j++){ for(i=0; i < 480; i++){ buffer[i][j].r = 0; buffer[i][j].g = 0; buffer[i][j].b = 0; buffer[i][j].a = 0; } What percentage of writes in this code will miss? Cache Block: r g b a order of access

Cache Analysis(contd) struct pixel { char r; char g; char b; char a; } struct pixel buffer[480][640]; register int i, j; register char *cptr; register int *iptr; ………. buffer j i for(j=0; j < 640; j++){ for(i=0; i < 480; i++){ buffer[i][j].r = 0; MISS buffer[i][j].g = 0; HIT buffer[i][j].b = 0; HIT buffer[i][j].a = 0; HIT } What percentage of writes in this code will miss? Cache Block: r g b a order of access

Cache Analysis(contd) struct pixel { char r; char g; char b; char a; } struct pixel buffer[480][640]; register int i, j; register char *cptr; register int *iptr; ………. buffer j i for(j=0; j < 640; j++){ for(i=0; i < 480; i++){ buffer[i][j].r = 0; MISS buffer[i][j].g = 0; HIT buffer[i][j].b = 0; HIT buffer[i][j].a = 0; HIT } What percentage of writes in this code will miss? ANS: 25 % of writes will miss

Cache Analysis(contd) struct pixel { char r; char g; char b; char a; } struct pixel buffer[480][640]; register int i, j; register char *cptr; register int *iptr; Accesses the array in Row-major order cptr = (char *) buffer; for(; cptr < ((char *) buffer) + 640*480*4; cptr++){ *cptr = 0; } What percentage of writes in this code will miss?

Cache Analysis(contd) struct pixel { char r; char g; char b; char a; } struct pixel buffer[480][640]; register int i, j; register char *cptr; register int *iptr; j ………. i buffer cptr = (char *) buffer; for(; cptr < ((char *) buffer) + 640*480*4; cptr++){ *cptr = 0; } What percentage of writes in this code will miss? Still 25% (previous analysis still holds)

Cache Analysis(contd) struct pixel { char r; char g; char b; char a; } struct pixel buffer[480][640]; register int i, j; register char *cptr; register int *iptr; iptr = (int *) buffer; for(; iptr < ((int *) buffer) + 640*480; iptr++){ *iptr = 0; } What percentage of writes in this code will miss?

Cache Analysis(contd) struct pixel { char r; char g; char b; char a; } struct pixel buffer[480][640]; register int i, j; register char *cptr; register int *iptr; j “grouped” into an int ………. i Same access pattern as cptr case, but ¼ times as many writes! iptr = (int *) buffer; for(; iptr < ((int *) buffer) + 640*480; iptr++){ *iptr = 0; }

Cache Analysis(contd) iptr = (int *) buffer; for(; iptr < ((int *) buffer) + 640*480; iptr++){ *iptr = 0; } What percentage of writes in this code will miss? 100% of writes will miss

Summary For more problems: See homework problems at the back of Chapter 6 Cache problems on previous exams These slides will be available on the “lectures” webpage.