50 misses per iteration figure 647 summarizes the

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: h] 20 [h] 28 [h] j=4 5 [m] 13 [m] 21 [m] 29 [m] j=5 6 [h] 14 [h] 22 [h] 30 [h] j=6 7 [h] 15 [h] 23 [h] 31 [h] j=7 8 [h] 16 [h] 24 [h] 32 [h] But consider what happens if we make the seemingly innocuous change of permuting the loops: 324 1 2 3 4 5 6 7 8 9 CHAPTER 6. THE MEMORY HIERARCHY int sumarraycols(int a[M][N]) { int i, j, sum = 0; for (j = 0; j < N; j++) for (i = 0; i < M; i++) sum += a[i][j]; return sum; } In this case we are scanning the array column by column instead of row by row. If we are lucky and the entire array fits in the cache, then we will enjoy the same miss rate of 1/4. However, if the array is larger than the cache (the more likely case), then each and every access of a[i][j] will miss! a[i][j] i=0 i=1 i=2 i=3 j=0 1 [m] 2 [m] 3 [m] 4 [m] j=1 5 [m] 6 [m] 7 [m] 8 [m] j=2 9 [m] 10 [m] 11 [m] 12 [m] j=3 13 [m] 14 [m] 15 [m] 16 [m] j=4 17 [m] 18 [m] 19 [m] 20 [m] j=5 21 [m] 22 [m] 23 [m] 24 [m] j=6 25 [m] 26 [m] 27 [m] 28 [m] j=7 29 [m] 30 [m] 31 [m] 32 [m] Higher miss rates can have a significant impact on running ti...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online