Siddhartha Chatterjee

Slides:



Advertisements
Similar presentations
Anshul Kumar, CSE IITD CSL718 : Memory Hierarchy Cache Performance Improvement 23rd Feb, 2006.
Advertisements

1 Adapted from UCB CS252 S01, Revised by Zhao Zhang in IASTATE CPRE 585, 2004 Lecture 14: Hardware Approaches for Cache Optimizations Cache performance.
1 COMP 206: Computer Architecture and Implementation Montek Singh Wed, Nov 2, 2005 Mon, Nov 7, 2005 Topic: Caches (contd.)
The University of Adelaide, School of Computer Science
1 COMP 206: Computer Architecture and Implementation Montek Singh Wed., Nov. 10, 2003 Topic: Caches (contd.)
EE Architecture of Digital Systems Lecture 3 Cache Memory
CS252/Culler Lec 4.1 1/31/02 CS203A Graduate Computer Architecture Lecture 14 Cache Design Taken from Prof. David Culler’s notes.
Reducing Cache Misses (Sec. 5.3) Three categories of cache misses: 1.Compulsory –The very first access to a block cannot be in the cache 2.Capacity –Due.
EENG449b/Savvides Lec /13/04 April 13, 2004 Prof. Andreas Savvides Spring EENG 449bG/CPSC 439bG Computer.
ENGS 116 Lecture 141 Caches and Main Memory Vincent H. Berk November 5 th, 2008 Reading for Today: Sections C.4 – C.7 Reading for Wednesday: Sections 5.1.
1 COMP 206: Computer Architecture and Implementation Montek Singh Wed, Nov 9, 2005 Topic: Caches (contd.)
1 COMP 206: Computer Architecture and Implementation Montek Singh Wed., Oct. 30, 2002 Topic: Caches (contd.)
Memory: Virtual MemoryCSCE430/830 Memory Hierarchy: Virtual Memory CSCE430/830 Computer Architecture Lecturer: Prof. Hong Jiang Courtesy of Yifeng Zhu.
CS252/Kubiatowicz Lec 3.1 1/24/01 CS252 Graduate Computer Architecture Lecture 3 Caches and Memory Systems I January 24, 2001 Prof. John Kubiatowicz.
Reducing Cache Misses 5.1 Introduction 5.2 The ABCs of Caches 5.3 Reducing Cache Misses 5.4 Reducing Cache Miss Penalty 5.5 Reducing Hit Time 5.6 Main.
CES 524 May 6 Eleven Advanced Cache Optimizations (Ch 5) parallel architectures (Ch 4) Slides adapted from Patterson, UC Berkeley.
1 IBM 360 Model 85 (1968) had a cache, which helped it outperform the more complex Model 91 (Tomasulo’s algorithm) Maurice Wilkes published the first paper.
Lec17.1 °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)
CSC 4250 Computer Architectures December 5, 2006 Chapter 5. Memory Hierarchy.
The Memory Hierarchy 21/05/2009Lecture 32_CA&O_Engr Umbreen Sabir.
1 Improving on Caches CS #4: Pseudo-Associative Cache Also called column associative Idea –start with a direct mapped cache, then on a miss check.
CS136, Advanced Architecture Cache and Memory Performance.
Chapter 5 Memory III CSE 820. Michigan State University Computer Science and Engineering Miss Rate Reduction (cont’d)
M E M O R Y. Computer Performance It depends in large measure on the interface between processor and memory. CPI (or IPC) is affected CPI = Cycles per.
Nov. 15, 2000Systems Architecture II1 Machine Organization (CS 570) Lecture 8: Memory Hierarchy Design * Jeremy R. Johnson Wed. Nov. 15, 2000 *This lecture.
Improving Direct-Mapped Cache Performance by the Addition of a Small Fully-Associative Cache And Pefetch Buffers Norman P. Jouppi Presenter:Shrinivas Narayani.
Chapter 5 Memory Hierarchy Design
1 Adapted from UC Berkeley CS252 S01 Lecture 18: Reducing Cache Hit Time and Main Memory Design Virtucal Cache, pipelined cache, cache summary, main memory.
Memory Hierarchy—Improving Performance Professor Alvin R. Lebeck Computer Science 220 Fall 2008.
Pradondet Nilagupta (Based on notes Robert F. Hodson --- CNU)
Prefetching Techniques. 2 Reading Data prefetch mechanisms, Steven P. Vanderwiel, David J. Lilja, ACM Computing Surveys, Vol. 32, Issue 2 (June 2000)
1 Adapted from UC Berkeley CS252 S01 Lecture 17: Reducing Cache Miss Penalty and Reducing Cache Hit Time Hardware prefetching and stream buffer, software.
COMP 206 Computer Architecture and Implementation Unit 8b: Cache Misses Siddhartha Chatterjee Fall 2000.
Memory Hierarchy— Five Ways to Reduce Miss Penalty.
现代计算机体系结构 主讲教师:张钢 教授 天津大学计算机学院 通信邮箱: 提交作业邮箱: 2014 年 1.
CS203 – Advanced Computer Architecture Cache. Memory Hierarchy Design Memory hierarchy design becomes more crucial with recent multi-core processors:
Chapter 5 Memory Hierarchy Design. 2 Many Levels in Memory Hierarchy Pipeline registers Register file 1st-level cache (on-chip) 2nd-level cache (on same.
Lecture 12: Design with Genetic Algorithms Memory I
/ Computer Architecture and Design
COMP 740: Computer Architecture and Implementation
CPS220 Computer System Organization Lecture 18: The Memory Hierarchy
Reducing Hit Time Small and simple caches Way prediction Trace caches
Associativity in Caches Lecture 25
Memory Hierarchy 3 Cs and 6 Ways to Reduce Misses
CSC 4250 Computer Architectures
Lecture: Cache Hierarchies
The University of Adelaide, School of Computer Science
Lecture 9: Memory Hierarchy (3)
现代计算机体系结构 主讲教师:张钢 教授 天津大学计算机学院 课件、作业、讨论网址:
11 Advanced Cache Optimizations
5.2 Eleven Advanced Optimizations of Cache Performance
Lecture: Cache Hierarchies
CPE 631 Lecture 07: Cache Design & Main Memory
CPE 631 Lecture 06: Cache Design
CS252 Graduate Computer Architecture Lecture 7 Cache Design (continued) Feb 12, 2002 Prof. David Culler.
CS252 Graduate Computer Architecture Lecture 4 Cache Design
Graduate Computer Architecture Lec 8 – Caches
January 24, 2001 Prof. John Kubiatowicz
Lecture 14: Reducing Cache Misses
CS203A Graduate Computer Architecture Lecture 13 Cache Design
CPE 631 Lecture 05: CPU Caches
CPE 631 Lecture 07: Cache Design & Main Memory
Memory Hierarchy.
/ Computer Architecture and Design
ECE 463/563, Microprocessor Architecture, Prof. Eric Rotenberg
11 Advanced Cache Optimizations
Cache Memory Rabi Mahapatra
Cache Performance Improvements
10/18: Lecture Topics Using spatial locality
Overview Problem Solution CPU vs Memory performance imbalance
Presentation transcript:

Siddhartha Chatterjee Cache Performance Fall 2000 Siddhartha Chatterjee

Sources of Cache Misses COMP 206 Fall 2000 Sources of Cache Misses Direct Mapped N-way Set Associative Fully Associative Cache Size Big Medium Small Compulsory Miss Same Same Same Conflict Miss High Medium Zero Capacity Miss Low(er) Medium High This is a hidden slide. Invalidation Miss Same Same Same If you are going to run “billions” of instruction, compulsory misses are insignificant. Fall 2000 Siddhartha Chatterjee Siddhartha Chatterjee

Siddhartha Chatterjee COMP 206 Fall 2000 3Cs Absolute Miss Rate Conflict Fall 2000 Siddhartha Chatterjee Siddhartha Chatterjee

How to Improve Cache Performance Latency Reduce miss rate (Section 5.3 of HP2) Reduce miss penalty (Section 5.4 of HP2) Reduce hit time (Section 5.5 of HP2) Bandwidth Increase hit bandwidth Increase miss bandwidth Fall 2000 Siddhartha Chatterjee

1. Reduce Misses via Larger Block Size COMP 206 Fall 2000 1. Reduce Misses via Larger Block Size Fall 2000 Siddhartha Chatterjee Siddhartha Chatterjee

2. Reduce Misses via Higher Associativity COMP 206 Fall 2000 2. Reduce Misses via Higher Associativity 2:1 Cache Rule Miss Rate DM cache size N  Miss Rate FA cache size N/2 Not merely empirical Theoretical justification in Sleator and Tarjan, “Amortized efficiency of list update and paging rules”, CACM, 28(2):202-208,1985 Beware: Execution time is only final measure! Will clock cycle time increase? Hill [1988] suggested hit time external cache +10%, internal + 2% for 2-way vs. 1-way Fall 2000 Siddhartha Chatterjee Siddhartha Chatterjee

3. Reduce Conflict Misses via Victim Cache COMP 206 Fall 2000 3. Reduce Conflict Misses via Victim Cache CPU How to combine fast hit time of direct mapped yet still avoid conflict misses Add small highly associative buffer to hold data discarded from cache Jouppi [1990]: 4-entry victim cache removed 20% to 95% of conflicts for a 4 KB direct mapped data cache TAG DATA ? TAG DATA Mem ? Fall 2000 Siddhartha Chatterjee Siddhartha Chatterjee

5. Reduce Misses by Hardware Prefetching of Instruction & Data COMP 206 Fall 2000 5. Reduce Misses by Hardware Prefetching of Instruction & Data Instruction prefetching Alpha 21064 fetches 2 blocks on a miss Extra block placed in stream buffer On miss check stream buffer Works with data blocks too Jouppi [1990] 1 data stream buffer got 25% misses from 4KB cache; 4 streams got 43% Palacharla & Kessler [1994] for scientific programs for 8 streams got 50% to 70% of misses from 2 64KB, 4-way set associative caches Prefetching relies on extra memory bandwidth that can be used without penalty Fall 2000 Siddhartha Chatterjee Siddhartha Chatterjee

6. Reducing Misses by Software Prefetching Data COMP 206 Fall 2000 6. Reducing Misses by Software Prefetching Data Data prefetch Load data into register (HP PA-RISC loads) binding Cache Prefetch: load into cache (MIPS IV, PowerPC, SPARC v9) non-binding Special prefetching instructions cannot cause faults; a form of speculative execution Issuing prefetch instructions takes time Is cost of prefetch issues < savings in reduced misses? Fall 2000 Siddhartha Chatterjee Siddhartha Chatterjee

7. Reduce Misses by Compiler Optimizations Fall 2000 7. Reduce Misses by Compiler Optimizations Instructions Reorder procedures in memory so as to reduce misses Profiling to look at conflicts McFarling [1989] reduced caches misses by 75% on 8KB direct mapped cache with 4 byte blocks Data Merging Arrays Improve spatial locality by single array of compound elements vs. 2 arrays Loop Interchange Change nesting of loops to access data in order stored in memory Loop Fusion Combine two independent loops that have same looping and some variables overlap Blocking Improve temporal locality by accessing “blocks” of data repeatedly vs. going down whole columns or rows Fall 2000 Siddhartha Chatterjee Siddhartha Chatterjee

Merging Arrays Example COMP 206 Fall 2000 Merging Arrays Example /* Before */ int val[SIZE]; int key[SIZE]; /* After */ struct merge { int val; int key; }; struct merge merged_array[SIZE]; Reduces conflicts between val and key Addressing expressions are different Fall 2000 Siddhartha Chatterjee Siddhartha Chatterjee

Loop Interchange Example COMP 206 Fall 2000 Loop Interchange Example /* Before */ for (k = 0; k < 100; k++) for (j = 0; j < 100; j++) for (i = 0; i < 5000; i++) x[i][j] = 2 * x[i][j]; /* After */ for (k = 0; k < 100; k++) for (i = 0; i < 5000; i++) for (j = 0; j < 100; j++) x[i][j] = 2 * x[i][j]; Sequential accesses instead of striding through memory every 100 words Fall 2000 Siddhartha Chatterjee Siddhartha Chatterjee

Siddhartha Chatterjee COMP 206 Fall 2000 Loop Fusion Example /* Before */ for (i = 0; i < N; i++) for (j = 0; j < N; j++) a[i][j] = 1/b[i][j] * c[i][j]; d[i][j] = a[i][j] + c[i][j]; /* After */ for (i = 0; i < N; i++) for (j = 0; j < N; j++) { a[i][j] = 1/b[i][j] * c[i][j]; d[i][j] = a[i][j] + c[i][j];} Two misses per access to a & c vs. one miss per access Fall 2000 Siddhartha Chatterjee Siddhartha Chatterjee

Siddhartha Chatterjee COMP 206 Fall 2000 Blocking Example /* Before */ for (i = 0; i < N; i++) for (j = 0; j < N; j++) {r = 0; for (k = 0; k < N; k++) r = r + y[i][k]*z[k][j]; x[i][j] = r;} Two Inner Loops: Read all NxN elements of z[] Read N elements of 1 row of y[] repeatedly Write N elements of 1 row of x[] Capacity Misses a function of N and Cache Size 3 NxN  no capacity misses; otherwise ... Idea: compute on BxB submatrix that fits Fall 2000 Siddhartha Chatterjee Siddhartha Chatterjee

Siddhartha Chatterjee COMP 206 Fall 2000 Blocking Example /* After */ for (jj = 0; jj < N; jj = jj+B) for (kk = 0; kk < N; kk = kk+B) for (i = 0; i < N; i++) for (j = jj; j < min(jj+B-1,N); j++) {r = 0; for (k = kk; k < min(kk+B-1,N); k++) r = r + y[i][k]*z[k][j]; x[i][j] = x[i][j] + r;} Capacity misses go from 2N3 + N2 to 2N3/B +N2 B called Blocking Factor What happens to conflict misses? Fall 2000 Siddhartha Chatterjee Siddhartha Chatterjee

Summary of Compiler Optimizations to Reduce Cache Misses Fall 2000 Summary of Compiler Optimizations to Reduce Cache Misses Fall 2000 Siddhartha Chatterjee Siddhartha Chatterjee

Siddhartha Chatterjee COMP 206 Fall 2000 Impact of Caches 1960-1985: Speed = ƒ(no. operations) 1997 Pipelined Execution & Fast Clock Rate Out-of-Order completion Superscalar Instruction Issue 1999: Speed = ƒ(non-cached memory accesses) What does this mean for Compilers, Operating Systems, Algorithms, Data Structures? Fall 2000 Siddhartha Chatterjee Siddhartha Chatterjee