I'm trying to figure out which locality (spatial/temporal) is used in the following pseudo code and how?
for i = 0, i < 10, i++
sum = sum + array[i]
I hope my question is clear and somebody could help me, thanks in advance! Steven
I'm trying to figure out which locality (spatial/temporal) is used in the following pseudo code and how?
for i = 0, i < 10, i++
sum = sum + array[i]
I hope my question is clear and somebody could help me, thanks in advance! Steven
Generally, given the code-snippet, one can't just determine easily about spatial locality unless the whole code is given.
Temporal Locality refers to the reuse of specific data, and/or resources, within a relatively small time duration..
Whereas, Spatial Locality refers to the use of data elements within relatively close storage locations.
Next, considering this snippet, as sum is to be called 10 times in 10 iterations of i, hence, repetitive reference to sum depicts temporal locality.