Question

I am stuck with a question which is stated below,

Describe the general characteristics and behavior of a program that would exhibit:
(a) Low temporal locality with regard to data accesses
(b) Low temporal locality with regard to instruction fetches

I understand temporal locality, but I am unable to understand what does it mean with regard to data access and instruction fetch. I would be very thankful if someone could explain it to me.

Was it helpful?

Solution

They're talking about optimising caches for accessing data and instructions in a CPU. Essentially, low temporal locality means that something that is re-used frequently, but not in one big chunk (i.e. spread over time).

Example of low temporal locality:

read file
process data
output result
....
read file
process data
output result
....
read file
process data
output result

To improve this you can re-arrange so that all reads are done together, all processing is done together, and all outputs are done together.

In the context of a CPU, you can say that if you need to do a memory read frequently, just read it once and cache it, then do as much as you can with it before discarding it. For instructions this means keeping things like looped instructions in a very fast cache (usually L1). For data, it means caching whatever you use most.

See these links for a proper explanation:
http://www.dotnetperls.com/temporal-locality
http://en.wikipedia.org/wiki/Locality_of_reference#Use_of_spatial_and_temporal_locality:_hierarchical_memory

OTHER TIPS

  • Low temporal locality for code means no loops and no reuse of instructions.
  • High temporal locality for code means tight loops with lots of reuse.
  • Low spatial locality for code means lots of jumps to far away places.
  • High spatial locality for code means no branches/jumps at all.

REFERENCE: Computer Organization and Design: The Hardware/Software Interface

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top