This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Reference pattern for array a (Å ¿). The function has poor spatial locality because it scans memory with a stride-´Æ ¢ × Þ Ó ´ reference pattern. Æ ÒØµµ ¾ , because it scans the array column-wise instead of row-wise. Since C arrays are laid out in memory row-wise, the result is a stride-(Æ ¢ × Þ Ó ´ ÒØµµ reference pattern, as shown in Figure 6.19(b). 6.2.2 Locality of Instruction Fetches
Since program instructions are stored in memory and must be fetched (read) by the CPU, we can also evaluate the locality of a program with respect to its instruction fetches. For example, in Figure 6.17 the instructions in the body of the for loop are executed in sequential memory order, and thus the loop enjoys good spatial locality. Since the loop body is executed multiple times, it also enjoys good temporal locality. An important property of code that distinguishes it from program data is that it can not be modiﬁed at runtime. While a program is executing, the CPU only reads its instru...
View Full Document