Note on Stride:
Memory stride is the distance between memory accesses and is measured as:
Local stride: This is the memory stride between two memory accesses for the same memory reference.
Global stride: This is the memory stride between memory accesses for consecutive memory references.
Consider the following example:
for (i=0; i<1000; i++){ for(j=0; j<10; j++){ sum += arrayOne[i] + arrayTwo[j]; } result[i] = sum; }The memory stride between consecutive memory accesses for the arrayOne memory reference is its local stride, i.e. (starting address of arrayOne[50] - ending address of arrayOne[49] ) is the local stride of arrayOne.
Note: This also means that if a region of code contains only 1 memory reference, global stride will be the same as local stride.
gStride1:
gStride1 or global stride 1 is a measure of the number of consecutive memory references that access consecutive memory locations.
Classifying gStride1:
gStride1 can be classified as low, medium or high as follows:
Bucket | Condition |
---|---|
Low |
The region of code contains no memory references.
OR
1 or fewer out of every 3 array references have a global stride of 1.
|
Medium | 1 out of every 3 array references have a global stride of 1. |
High |
2 out of every 3 array references have a global stride of 1.
OR
The region of code contains only 1 memory reference in each iteration of the outermost loop and the reference accesses consecutive memory locations.
|
Example 1:
Consider the following code:
for (i=0; i<1000; i++){ for(j=0; j<10; j++){ sum += arrayOne[i] + arrayTwo[j]; } result[i] = sum; }This code contains 3 memory references (through arrays arrayOne, arrayTwo & result) and none of these references access successive locations since they all access different arrays.
Example 2:
Let's look at another example:
for (i=0; i<1000; i++){ result[i] = 0; }This code contains just one memory reference, a store at the array result. This causes each memory access to be made to consecutive memory locations.