Memory Hierarchy
What is the main purpose of loop blocking (tiling), used for example in matrix multiplication?
- ATo compute in small cache-sized blocks and increase data reuse
- BTo reduce the number of iterations and hence the branch instructions executed at the end of each iteration
- CTo halve total memory usage without changing the order of computation
Show answer and explanation
Answer: A. To compute in small cache-sized blocks and increase data reuse
Computing a large matrix product directly evicts elements before they are reused, forcing repeated reloads from main memory. Loop blocking splits the matrices into small blocks that fit in the cache and finishes the work within each block, reusing loaded data many times and sharply reducing capacity misses. Reducing branches is the goal of loop unrolling, and total memory usage does not change.
- A. Correct. Computing in cache-sized units increases data reuse.
- B. Reducing branches is the goal of loop unrolling.
- C. The order of computation changes, and total memory usage stays the same.