1 / 27

Yixin Shou, Robert A. van Engelen, Johnnie Birch, Kyle A. Gallivan

Toward Efficient Flow-Sensitive Induction Variable Analysis and Dependence Testing for Loop Optimization. Yixin Shou, Robert A. van Engelen, Johnnie Birch, Kyle A. Gallivan Restructuring Compilers Research Lab Florida State University. Outline. Motivation The CR# Algebra

keahi
Download Presentation

Yixin Shou, Robert A. van Engelen, Johnnie Birch, Kyle A. Gallivan

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Toward Efficient Flow-SensitiveInduction Variable Analysis and Dependence Testing for Loop Optimization Yixin Shou, Robert A. van Engelen, Johnnie Birch, Kyle A. Gallivan Restructuring Compilers Research Lab Florida State University

  2. Outline • Motivation • The CR# Algebra • Flow-Sensitive Induction Variable Analysis Algorithms with CRs on SSA forms • Application: Data Dependence Testing • Conclusions

  3. Induction Variable Recognition: a Classic Compiler Problem Most Loop Optimizations Rely on Accurate IV Recognition Loop strength reduction IV elimination IV substitution Array recovery Array data dependence testing Problem nonlinear IV conditionally updated IV Pointer arithmetic in loops Motivation

  4. Motivating Examples (cont.) Conditional updated IV and partial wrap around variables in loops

  5. Motivating Examples IVs which do not have closed forms

  6. More Powerful IV Recognition Methods • IV recognition can quickly gets more complicated with deps and flow • Induction variable recognition with chains of recurrences by van Engelen • Linear, nonlinear and conditional IV • Further improve other compiler optimizations • Extend IV analysis algorithm • based on CR# algebra • on SSA form

  7. Outline • Motivation • The CR# Algebra • Flow-Sensitive Induction Variable Analysis Algorithms on SSA forms • Application: Data Dependence Testing • Conclusions

  8. Preliminaries • A chain of recurrences (CR) represents a polynomial or exponential function or mix evaluated over a unit-distance grid • Basic form: Фi = {ϕ0, ⊙1, f1}i, where ⊙1 = + or * A value sequence with initial value ϕ0 updated by adding or multiplying the current value by step function f1 • When f1 is another CR form, this produces a chain of recurrences Фi = {ϕ0, ⊙1, {ϕ1, ⊙2, {ϕ2,..., ⊙k,{ϕk}i}i}i}i which is usually written in flattened form Фi = {ϕ0, ⊙1, ϕ1, ⊙2, ϕ2,..., ⊙ k, ϕ k}i • Multi-variate CR forms • CR coefficients are nested CR forms of a different grid variable

  9. Chains of Recurrences: Algebra • CR simplification rules produces an equivalent CR expression that can be evaluated more efficiently. • CR Inverse rules (CR-1) derive a closed form functions corresponding to CR expressions. • Some selected rules

  10. How to Obtain CR Forms using CR Algebra • Algorithm to compute the CR form of a symbolic function f(i): • Replace index i with its CR form {0,+,1} in the symbolic form of f • Compute CR form using the CR algebra rewrite rules • Example: f(i) = c·(i+a) = c·({0, +, 1}+a) = c{a, +, 1} = {c·a, +, c}

  11. CR# Alignment and Bounds • CR# Algebra: a new extension of CR algebra • The Delay Operator # • Define recurrences with out of sequence values • CR form with Delayed operator can be used to define any sequence of values followed by a polynomial, geometric CR form, or another delayed form. • wrap-around variables can be accurately represented using delayed forms • Aligned CR forms • Same index variable • Same length • Operators pairwise match • CR Alignment Rules • Lemma 1, 2, 3 • Compute bounds for two CR form after CR alignment

  12. Example • Close form function of CRs • f(i) = {1, #, 1, +, 2}i = 1 if i = 0 • 2*i -1 if i > 0 • g(i) = {1, *, 2}i= 2i for i = 0…n • After CR alignment • f(i) = {1, #, 1, +, 2}i = {1, #, 1, +, 2, *, 1}i • g(i) = {1, *, 2}i = {1, #, 2, *, 2}i = {1, #, 2, +, 2, *, 2}i • After CR Bounding • Min({1, #, 1, +, 2, *, 1}i ,{1, #, 2, +, 2, *, 2}i) = {1, #, 1, +, 2, *, 1}I • Max({1, #, 1, +, 2, *, 1}i ,{1, #, 2, +, 2, *, 2}i) = {1, #, 2, +, 2, *, 2}I

  13. Outline • Motivation • The CR# Algebra • Flow-Sensitive Induction Variable Analysis Algorithms on SSA forms • Application: Data Dependence Testing • Conclusions

  14. SSA Form • Static Single Assignment (SSA) Form: a internal compiler representation • each use refers to a single definition • each definition has a unique name by attaching indices to variables • The compiler inserts special join functions (called -functions) at points where different control flow paths meet. • Advantage of SSA • explicit def-use pairs to help compiler data flow optimizations • no anti and output data dependences • Compiler dataflow optimizations algorithms are strongly enhanced by using SSA forms.

  15. Integrate CR Approach on SSA Form • Static Single Assignment (SSA) form is used in many modern compilers to facilitate a wide range of powerful compiler dataflow optimizations. • CR representation is a very effective form for induction expression in loops and facilitate the loop analysis, optimization and dependence testing. • Integrate the CR approach in SSA forms • improve many data flow analysis and dependence testing. • Make our unified CR framework adapt to a much wider range of compilers

  16. Flow-Sensitive Induction Variable Analysis Algorithms on SSA forms • The algorithm for IV recognition with CRs is based on A major observation from Gerlek, Stolz, and Wolfe • A strongly connected region (SCR) of SSA chain graph represent a induction variable in the loop. • SCR: a set of node in the graph where there exist a path for any two nodes in the set. • Collect initial value and induction sequence information in the SCR cycle. • Determine recurrence relations and then CR form of the induction variable

  17. 1 a0 2 a1 1 + + a2 x0 Example 1: Linear recurrences pattern

  18. 1 0 i0 x0 i1 1 x1 + + x2 i2 Example 2: Non-linear recurrences pattern

  19. 0 j0 2 j1 + 3 + j4 j2 j3 Example 3: Conditional recurrences pattern

  20. Example 4: Conditional and Wrap Around Recurrences

  21. Outline • Motivation • The CR# Algebra • Flow-Sensitive Induction Variable Analysis Algorithms on SSA forms • Application: Data Dependence Testing • Conclusions

  22. Data Dependence testing Based on CR# algebra • Accurate data dependence testing is crucial for parallelizing compilers • Benefits of Array & Pointer Dependence Testing with CRs • Directly build the dependence equation based on CR forms • Eliminates IV substitution phase • Eliminates the need for pointer-to-array conversion for dependence testing on pointer-based C code • Able to solve dependence with linear, nonlinear, conditional updated variables and pointers arithmetic.

  23. CR Dependence Equations • Compute dependence equations in CR form for pointer and array accesses in loop nests directly without IV substitution or pointer-to-array conversion • Solve the equations by computing value ranges of the CR forms to determine solution intervals • If the solution space is empty, there is no dependence

  24. Determining the Value Range of a CR Form on a Domain • If a function is monotonic on its domain, then it is trivial to find its exact value range • The monotonic properties of a CR form are determined by the stepping functions • Suppose x(i) = {x0, +, s(i-1)} for i = 0, …, n • If s(i-1) > 0 then x(i) is monotonically increasing • If s(i-1) < 0 then x(i) is monotonically decreasing

  25. Example:

  26. Conclusions • The CR-based compiler analysis framework supports: • IV recognition • Array dependence testing with affine, nonlinear, and symbolic dependence equations • Dependence testing on pointer arithmetic • Induction variable substitution • Flow-sensitive generalized induction variables (GIVs) analysis algorithm based on CR# algebra are able to analyze • nonlinear index expression • Non-closed index expression • Enhance the monotonic analysis, data dependence testing and other compiler optimizations

  27. Thanks

More Related