1 / 16

Cache Miss Rate Computations

This text explores the cache miss rates for a simple array cache using different scenarios and access patterns. It covers topics such as array fits in cache, reusing blocks, accessing blocks in order, and 2D array accesses.

ronniem
Download Presentation

Cache Miss Rate Computations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Cache Miss Rate Computations Topics • Simple examples

  2. Assumed Simple Cache • 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) Cache Block 0 Block 1

  3. 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?

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

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

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

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

  8. Simple Array w outer loop Cache for (k=0;k<P;k++){ for (i=0;i<N;i++){ … = A[i]; } } A 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

  9. Simple Array Cache for (i=0;i<N;i++){ … = A[i]; } A Assume A[] does not fit in the cache: Miss rate = #misses / #accesses

  10. Simple Array Cache for (i=0;i<N;i++){ … = A[i]; } A 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

  11. Simple Array with outer loop Cache for (k=0;k<P;k++){ for (i=0;i<N;i++){ … = A[i]; } } A 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

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

  13. 2D array Cache A 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

  14. 2D array Cache for (j=0;j<N;j++){ for (i=0;i<N;i++){ … = A[i][j]; } } A 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

  15. 2D array Cache A for (j=0;j<N;j++){ for (i=0;i<N;i++){ … = A[i][j]; } } 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).

More Related