reuseDist2:
reuseDist2 or reuse distance measures cache effectiveness by looking at the number
of memory references between two accesses to the same cache block. A memory reference
is said to have high reuseDist2 if the next access to it is within 3 memory references
(accessing other arrays for example).
Assume that a cache block is 64 Bytes in size. This means that any array references that
are 16 locations apart (for a 4 Byte data type) will access differenct cache blocks.
This reduces reuse distance.
Reuse distance is measured for each memory reference and reuseDist2 is the aggregate
of these values.
Classifying reuseDist2:
reuseDist2 can be classified into low, medium or high as follows:
Bucket | Condition |
---|---|
Low | Fewer than a third of the array references have a reuse distance of 2. |
Medium | About half the array references have a reuse distance of 2. |
High |
More than 2 out of every 3 array references has a reuse distance of 2.
OR
The region of code contains only three or fewer unique array references.
|
Example 1:
Consider the following code:
for (i=0; i<1000; i++) result[i] = arrayOne[i] * arrayTwo[i];This code contains three memory references to result, arrayOne & arrayTwo. Since the number of memory references is less than 3, it would be safe to assume that each of these arrays will be reused in every third memory reference. Therefore, reuseDist2 can be estimated to be high.
Example 2:
Let's look at another example:
for (i=0; i<1000; i++){ if(touched[i] == false) result[i] = arrayOne[i] + arrayTwo[i]; }In this example, there are 3 other references between consecutive accesses to each of these arrays. Therefore, none of these references can have a reuse distance of 2 (the reuse distance is 3 in this case). Therefore, reuseDist2 can be estimated to be low.