30 category 2 given the assumptions in problem 628

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: nner loops in the Class routines (Figure 6.45(c) and (d)) have some problems. Each iteration performs two loads and a store (as opposed to the Class routines, which perform 2 loads and no stores). Second, the inner loop scans the columns of and with a stride of Ò. The result is a miss on each load, for As we learned in Chapter 2, floating-point addition is commutative, but in general not associative. In practice, if the matrices do not mix extremely large values with extremely small ones, as if often true when the matrices store physical properties, then the assumption of associativity is reasonable. 2 6.6. PUTTING IT TOGETHER: THE IMPACT OF CACHES ON PROGRAM PERFORMANCE code/mem/matmult/mm.c 1 2 3 4 5 6 7 333 code/mem/matmult/mm.c 1 2 3 4 5 6 7 for (i = 0; i < n; i++) for (j = 0; j < n; j++) { sum = 0.0; for (k = 0; k < n; k++) sum += A[i][k]*B[k][j]; C[i][j] += sum; } code/mem/matmult/mm.c for (j = 0; j < n; j++) for (i = 0; i < n; i++) { sum = 0.0; for (k = 0; k < n; k++) sum += A[i][k]*B[k][j]; C[i][j] += sum; } code/mem/matmult/mm.c (a) Version . code/mem/matmult/mm.c (b) Version . code/mem/matmult/mm.c 1 2 3 4 5 6 for (j = 0; j &l...
View Full Document

Ask a homework question - tutors are online