Download Memory Hierarchy in Cache
Transcript
In the column-oriented version, the inner loop is over the columns of the matrix: for (j=0; j<n; j++) for (i=0; i<m; i++) sum += x[i][j]; Without special precautions, the C compiler from the Sun ONE™ Studio 7 Compiler Collection suite transforms the column version with the bad memory access pattern into the row version. This is, of course, the right thing to do, but it defeats the purpose of our experiment. To prevent this optimization, we crafted the example to prevent the compiler from applying the loop interchange. FIGURE 9 shows the performances (in Megaflops per second) as a function of the memory footprint (in kilobytes). Only square nxn matrices are used. The footprint is then given by n * n * 4/1024 kilobytes. Note the log-log scale in the graph. To filter out timing anomalies, each performance experiment was repeated three times. The average over these three results is the value that was plotted. 1000 Performance (Mflop/s) Row version Column version 100 10 1 0 1 10 100 1000 10000 Memory Footprint (KByte) FIGURE 9 22 Performance of the Matrix Summation Operation Memory Hierarchy in Cache-based Systems • November 2002 100000 100000