Blocking: Example
- z[j] is reused for each i iteration
- For large n the array z will not be reused from the cache
Blocking the loops for cache:
- nb elements of z array will be brought in to the cache and reused nb times before moving on to the next tile
x[i][j] is traversed in order
z[j] is traversed sequentially
changing loop order is not beneficial
For(it=0; it<n; it += nb)
for(i=it; i<min(jt+nb,n); i++)
for(j=jt; j<min(jt+nb,m); j++)