|
- Using normalized iteration vectors the shape of the iteration space changes as shown below
 |
The dependence distance are (0,1) and (1,-1)
|
This dependence prevents loop interchange |
- If normalization can prevent interchange then un-normalization can enable loop interchange
- This is called loop skewing
- Skewing changes the iteration vector of each iteration by adding the outer loop index value to the inner loop index
- (I,j) becomes (I, j+i)
- A dependence relation from (i1, j1) to (i2, j2) will have distance (i1, j1) –(i2-j2) = (d1, d2)
- After skewing the distance will change to (i1, j1+i1) –(i2, j2+i2) = (d1, d2+d1)
- In general loops can be skewed by a factor changing iteration label from (I,j) to (I, j+fi)
- This changes distance from (d1, d2) to (d1, d2+fd1)
- F can also be negative
- Choosing whether to skew and the factor by which to skew depends upon the goal to enable other transformations
Example
- Interchange following loop using skewing
for I = 2, n
for j = 2, m
A[I,j] = 0.5 * (A[i-1, j-1]+A[i-1, j+1])
endfor
Endfor |
- The two dependence distances are (1,1) and (1,-1)
- The second one prevents the interchange
- Skewing the loop would change the dependence distance to (1,2) and (1,0) allowing the interchange
- The compiler must generate the correct limits using FM method
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|