1
play

1 Checking Legality in Kelly & Pugh Framework Loop Fusion - PowerPoint PPT Presentation

Loop Transformations for Parallelism & Locality Loop Fusion Example Last time What are the dependences? Unimodular transformation framework do i = 1,n What are the dependences? Loop permutation s 1 A(i) = B(i) + 1 Loop


  1. Loop Transformations for Parallelism & Locality Loop Fusion Example Last time What are the dependences? – Unimodular transformation framework do i = 1,n What are the dependences? – Loop permutation s 1 A(i) = B(i) + 1 – Loop reversal do i = 1,n enddo s 1 δ f s 2 – Loop skewing s 1 A(i) = B(i) + 1 s 1 δ f s 2 do i = 1,n s 2 C(i) = A(i)/2 s 2 C(i) = A(i)/2 Today s 3 δ a s 2 enddo – Kelly & Pugh transformation framework s 2 δ f s 3 s 3 D(i) = 1/C(i+1) – Loop transformations enddo do i = 1,n – Loop fusion s 3 D(i) = 1/C(i+1) Fusion changes the dependence – Loop fission enddo between s 2 and s 3 , so fusion is illegal CS553 Lecture Loop Transformations 1 CS553 Lecture Loop Transformations 2 Kelly and Pugh Transformation Framework Specifying Loop Fusion in Kelly and Pugh Framework Specify iteration space as a set of integer tuples Specify iteration space as a set of integer tuples Specify data dependences as mappings between integer tuples (i.e., data dependence relations) Specify data dependences as mappings between integer tuples (i.e., data dependence relations) Specify transformations as mappings between integer tuples Specify transformations as mappings between integer tuples Execute iterations in transformed iteration space in lexicographic order CS553 Lecture Loop Transformations 3 CS553 Lecture Loop Transformations 4 1

  2. Checking Legality in Kelly & Pugh Framework Loop Fusion Example (cont) For each dependence, [I] -> [J] the transformed I iteration must be Loop reversal is legal for the original loops – Does not change the direction of any dep in the original code executed after the transformed J iteration. – Will reverse the direction in the fused loop: s 3 δ a s 2 will become s 2 δ f s 3 do i = n,1,-1 s 1 A(i) = B(i) + 1 do i = n,1,-1 enddo s 1 A(i) = B(i) + 1 s 1 δ f s 2 s 1 δ f s 2 do i = n,1,-1 s 2 C(i) = A(i)/2 s 2 C(i) = A(i)/2 s 2 δ f s 3 enddo s 3 D(i) = 1/C(i+1) s 2 δ f s 3 enddo do i = n,1,-1 After reversal and fusion all original s 3 D(i) = 1/C(i+1) dependences are preserved enddo CS553 Lecture Loop Transformations 5 CS553 Lecture Loop Transformations 6 Loop Fission (Loop Distribution) Loop Fission (cont) Idea Legality – Split a loop nest into multiple loop nests (the inverse of fusion) – Fission is legal when the loop body contains no cycles in the dependence graph Example do i = 1,n do i = 1,n A(i) = B(i) + 1 Cycles cannot do i = 1,n do i = 1,n body1 enddo be preserved A(i) = B(i) + 1 body1 enddo because after C(i) = A(i)/2 body2 fission all do i = 1,n enddo do i = 1,n enddo cross-loop body2 C(i) = A(i)/2 dependences enddo enddo flow from Motivation? body1 to body2 – Produces multiple (potentially) less constrained loops – May improve locality – Enable other transformations, such as interchange Legality? CS553 Lecture Loop Transformations 7 CS553 Lecture Loop Transformations 8 2

  3. Loop Fission Example Loop Fission Example (cont) Recall our fusion example If there are no cycles, we can reorder the loops with a topological sort do i = 1,n do i = 1,n Can we perform fission on this loop? Can we perform fission on this loop? s 1 s 1 A(i) = B(i) + 1 A(i) = B(i) + 1 do i = 1,n do i = 1,n enddo enddo s 1 δ f s 2 s 1 δ f s 2 s 1 A(i) = B(i) + 1 s 1 A(i) = B(i) + 1 s 1 δ f s 2 s 1 δ f s 2 do i = 1,n do i = 1,n s 2 C(i) = A(i)/2 s 2 s 3 D(i) = 1/C(i+1) s 2 C(i) = A(i)/2 C(i) = A(i)/2 s 3 δ a s 2 s 3 δ a s 2 enddo enddo s 3 δ a s 2 s 2 δ f s 3 s 3 D(i) = 1/C(i+1) s 3 D(i) = 1/C(i+1) do i = 1,n enddo do i = 1,n enddo s 3 D(i) = 1/C(i+1) s 2 C(i) = A(i)2 enddo enddo CS553 Lecture Loop Transformations 9 CS553 Lecture Loop Transformations 10 Concepts Next Time Loop transformation Lecture – Loop fusion – Tiling – Loop fission Kelly & Pugh Transformation Framework – iteration spaces as constrained sets of integer tuples – data dependences as mappings between integer tuples – transformations as mappings between integer tuples CS553 Lecture Loop Transformations 11 CS553 Lecture Loop Transformations 12 3

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend