Next: ... Up: Motivation: an example Previous: Optimising memory accesses

Blocking (a.k.a. ``tiling'')

Idea: reorder exec tex2html_wrap_inline1022 of loop nest so data isn't evicted from cache before it's needed again.

Blocking is a combination of two transformations: ``strip mining'', followed by interchange; we start with

  for (i = 0; i < 500; i++)
    for (k = 0; k < 500; k++){
      r = A[i][k];
      for (j = 0; j < 500; j++)
        C[i][j] += r * B[k][j]; }
Strip mine the k and j loops:
for (i = 0; i < 500; i++)
 for (kk = 0; kk < 500; kk += BLKSZ)
   for (k = kk; k < min(kk+BLKSZ,500); k++){
    r = A[i][k];
    for (jj = 0; jj < 500; jj += BLKSZ)
     for (j = jj; j < min(jj+BLKSZ, 500); j++)
       C[i][j] += r * B[k][j];
    }



Paul H J Kelly Thu Dec 4 18:15:31 GMT 1997