Module 18: Loop Optimizations
  Lecture 36: Cycle Shrinking
 


Loop Skewing

  • Normalization can change the shape of the iteration space
  • It may affect the ability to interchange loops
  • Consider following code
    for I = 2, n
    for j = I, n
    A[I,j] = 0.5 *(A[I,j-1]+A[i-1,j])
    endfor
    endfor
  • Using un-normalized iteration vector the dependence distances are (0,1) and (1,0)

Iteration Space of The Loop

  • After interchange the code is
    for j = 2, n
    for i = 2, j
    A[I,,j] = 0.5 *(A[I,,j-1]+A[i-1,,j])
    endfor
    endfor