Reputation: 71
Which locality (spatial/ temporal) will be exploited if we put more than one word in one cache block?
Question Ref: GATE 2011
The answer says spatial locality.
I have tried searching for the explanations but couldn't understand them. A detailed explanation with some example may be helpful. Thank You.
Upvotes: 1
Views: 679
Reputation: 10073
There are two primary concepts related to locality of reference.
Temporal locality exists in many programs because the same memory locations are accessed multiple times.
Spatial locality exists because frequently if a program accesses one memory location it will also access another one that is nearby.
If a program accesses the same word in a cache line repeatedly it would exploit temporal locality because you were reusing the exact same memory location. Storing multiple words in a cache line exploits spatial locality because if the program accesses one word in that line, the program is also likely access another word that is in the same cache line.
Upvotes: 3