is reducing the size of the stripe of the B matrix by blocking the k loop so that the stripe is of size ib × kb. Blocking the k loop means that the C array will be loaded and stored N/kb times, for a total of memory transfers. B is still transferred N/ib times, for transfers. So long as 2*N/kb + N/ib < N/balance the machine's memory system will keep up with the floating point unit and the code will run at maximum performance. The 16KB cache of the Pentium 4 is not quite big enough: if ib=24 and kb=64 were chosen instead, 12KB of the cache would be used—avoiding completely filling it, which is desirable so the C and B arrays have to have some room to flow through. These numbers come within 20% of the peak floating-point speed of the processor. Here is the code with loop k blocked. for (ii = 0; ii < N; ii += ib) { for (kk = 0; kk < N; kk += kb) { for (j=0; j < N; j += 2) { for (i = ii; i < ii + ib; i += 2) { if (kk == 0) acc00 = acc01 = acc10 = acc11 = 0; else { acc00 = C[i + 0][j + 0]; acc01 = C[i + 0][j + 1]; acc10 = C[i + 1][j + 0]; acc11 = C[i + 1][j + 1]; } for (k = kk; k < kk + kb; k++) { acc00 += B[k][j + 0] * A[i + 0][k]; acc01 += B[k][j + 1] * A[i + 0][k]; acc10 += B[k][j + 0] * A[i + 1][k]; acc11 += B[k][j + 1] * A[i + 1][k]; } C[i + 0][j + 0] = acc00; C[i + 0][j + 1] = acc01; C[i + 1][j + 0] = acc10; C[i + 1][j + 1] = acc11; } } } } The above code examples do not show the details of dealing with values of N which are not multiples of the blocking factors. Compilers which do loop nest optimization emit code to clean up the edges of the computation. For example, most LNO compilers would probably split the kk == 0 iteration off from the rest of the kk iterations, to remove the if statement from the i loop. This is one of the values of such a compiler: while it