Reorganizing and fetching them at the same time can reduce misses. This technique reduces misses by improving spatial locality. By switching the order in which loops execute, misses can be reduced due to improvements in spatial locality. For example, These loops cause a miss on each memory access because of the long stride given by index j in the inner loop. By switching the order of the loops, the stride is changed to 1, allowing the elements to be accessed in sequential order.
Many programs have separate loops that operate on the same data.
Blocking The above methods work well on array accesses that occur along one dimension only. However, loops that access both rows and columns, such as matrix multiplication, are problems. Reducing Cache Miss Rate Blocking Unoptimized matrix multiplication requires the cache to hold the minimum elements shown shaded below. Capacity misses can occur for large matrices since it may not be possible to store all the elements of Z in the cache. Therefore, matrix multiplication is performed by multiplying the submatrices first.