1
play

1 Distinguishing Upper and Lower Bounds Triangular Iteration Space - PowerPoint PPT Presentation

Code Generation Using Fourier Motzkin Code Generation Previously Goals Data dependences and loops express outermost loop bounds in terms of symbolic constants and constants Loop transformations express inner loop bounds in


  1. Code Generation Using Fourier Motzkin Code Generation Previously Goals – Data dependences and loops – express outermost loop bounds in terms of symbolic constants and constants – Loop transformations – express inner loop bounds in terms of any enclosing loop variables, – Unimodular transformation framework symbolic constants, and constants – Kelly and Pugh transformation framework (affine transformations per statement) Approach – Project out inner loop iteration variables to determine loop bounds for Today outer loops – Code generation – Fourier Motzkin elimination is the algorithm that projects a variable out – use Fourier Motzkin to calculate new loop bounds of a polyhedron – review array access transformations – review loop bounds transformations CS553 Lecture Fourier-Motzkin Elimination 2 CS553 Lecture Fourier-Motzkin Elimination 3 Fourier-Motzkin Elimination: The Idea Fourier-Motzkin Elimination: The Algorithm 1 >= i Polyhedron FM( P, i_k ) => P’ – convex intersection of a set of j <=5 Input: inequalities – model for iteration spaces i <= j Output: j Problem – given a polyhedron how do we generate loop bounds that Algorithm: i scan all of its points? for each lower bound of – example: two possible loop orders for each upper bound of – ( i , j ) – ( j , i ) CS553 Lecture Fourier-Motzkin Elimination 4 CS553 Lecture Fourier-Motzkin Elimination 5 1

  2. Distinguishing Upper and Lower Bounds Triangular Iteration Space Example Simple Algorithm ( i, j ) for target iteration space j <=5 – given that the polyhedron is represented as follows: i <= j j – any constraint with a positive coefficient for i_k is a lower bound – any constraint with a negative coefficient for i_k is an upper bound i ( j, i ) for target iteration space 1 >= i j <=5 i <= j j CS553 Lecture Fourier-Motzkin Elimination 6 CS553 Lecture Fourier-Motzkin Elimination 7 1 >= i i General Algorithm for Generating Loop Bounds Loop Skewing and Permutation Input: Original code where the i vector is the desired loop order do i = 1,6 do j = 1,5 j Output: A(i,j) = A(i-1,j+1)+1 i enddo enddo Algorithm: (1, -1) Distance vector: for k = d to 1 by -1 Skewing followed by Permutation: i’ j’ CS553 Lecture Fourier-Motzkin Elimination 8 CS553 Lecture Fourier-Motzkin Elimination 9 2

  3. Transforming the Dependences and Array Accesses Transforming the Loop Bounds Original code Original code do i = 1,6 do i = 1,6 do j = 1,5 do j = 1,5 A(i,j) = A(i-1,j+1)+1 A(i,j) = A(i-1,j+1)+1 j j enddo enddo i enddo i enddo Bounds: Dependence vector: New Array Accesses: Transformed code (use general loop bound alg) do i’ = 2,11 do j’ = max(i’-5,1), min(6,i’-1) i’ i’ A(j’,i’-j’) = A(j’-1,i’-j’+1)+1 enddo enddo j’ j’ CS553 Lecture Fourier-Motzkin Elimination 10 CS553 Lecture Fourier-Motzkin Elimination 11 Wavefront Parallelism Example Concepts Example Fourier-Motzkin Elimination do i = 1,6 – algorithm do j = 1,min(5,7-i) – using for code generation A(i,j) = A(i-1,j-1) + A(i,j-1) Loop bounds j enddo enddo – how to determine upper and lower bounds for a variable when bounds are i in matrix format Iteration Space Goal – Determine a unimodular transformation that enables indicating that the Examples inner loop is fully parallel. (with an OpenMP directive for example) – triangular matrix do i’ = 1,5 – skew and permute example do j’ = 1, 7-i’ (parallel) – wavefront example A(j’,i’) = A(j’-1,i’-1) + A(j’,i’-1) enddo enddo CS553 Lecture Fourier-Motzkin Elimination 12 CS553 Lecture Fourier-Motzkin Elimination 13 3

  4. Next Time Lecture – Parallelization with no synchronization or communication Suggested Exercises – 11.3.2, 11.3.3, 11.3.4 CS553 Lecture Fourier-Motzkin Elimination 14 4

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