Spatial versus Temporal Locality I
In classic loop Do I =2,N Do J=2,N FI(I,J) =.25*(FI(I+1,J)+FI(I-1,J)+FI(I,J+1)+FI(I,J-1))
We see spatial locality -- if (I,J) accessed so are neighboring points stored near (I,J) in memory
Spatial locality is essential for distributed memory as ensures that after data decomposition, most data you need is stored in same processor and so communication is modest (surface over volume)
- Spatial locality also exploited by vector machines
Temporal locality says that if you use FI(I,J) in one loop it is used in next J index value as FI(I,(J+1)-1)
Temporal locality makes cache machines work well as ensures after a data value stored into cache, it is used multiple times