CS553 Colorado State University =============================================== Loop Transformations =============================================== 10/29/09 -------- ------------------ Loop Interchange/Permutation (slide 2) - we have seen this transformation before - The end result: Will reuse A(2,j) for each iteration of the I loop ------------------ Legality Loop Interchange/Permutation (slides 3-4) - recall that one direction vector can summarize an infinite number of distance vectors - when is it legal given the direction vectors for a loop? ------------------ Loop Interchange Example (slide 5) --> have students set up dependence problem iteration (i,j) writes C(i,j) iteration (i',j') reads C(i'+1, j'-1) i=i'+1 j=j'-1 1 <= i,j,i',j' <= n (i,j) != (i',j') assume anti dependence iteration (i,j) writes C(i,j), target iteration (i',j') reads C(i+1, j-1), source v = (i,j) - (i',j') = (1,-1) can be represented with direction vector (<,>) -------------------- Framework for Loop transformation (slide 6) - frameworks provide a unifying way to specify various loop transformations - can determine the space of possible transformations - for unimodular, all unimodular matrices that keep dependences lexicographically positive are legal - can automatically generate transformed code based on transformation specifications - can compose transformations --> What is the transformation matrix for permutation? ------------------------ Legality of loop permutation using unimodular framework (slide 7) ------------------------ Loop Reversal (slides 8-10) - what does -1 multiplied by < mean? by >? by =? keep in mind that these represent a set of numbers, just take the negation of that set and use the appropriate representation for the result - first do reversal of j loop show on ISG how it intuitively is legal - then do reversal of i loop and show that it isn't legal -------------------- mstrout@cs.colostate.edu, 10/29/09