Module 18: Loop Optimizations
  Lecture 36: Cycle Shrinking
 
  • Interchange jt loop with I loop
  • Compiler finds the new lower limits for jt
    For It = -15, 45, 20
    for jt = max(-15,it), 45, 20
    for i = max(I,it), min(50,it+19)
    for j=max(I,jt), min(60, jt+19)
    A[I,j] = A[I,j]+1
    endfor
    endfor
    endfor
    endfor

Circular Loop skewing

  • A variation of loop skewing
  • Skew the inner loop iterations such that they wrap around a cylinder
  • The shape of the iteration space does not change but the relative positions change
  • Backward dependencies with large distances make tiling unprofitable
  • Circular loop skewing shortens backward dependencies
For I = 0, n-1
for j = 0, n-1
A[i] = A[i] + B[i] * C[i]
endfor
endfor
The circular loop skewing does not change the shape of the iteration space. It changes the iterations computed at each point.