1 / 69

Dependence Testing

Dependence Testing. Part II. Optimizing Compilers for Modern Architectures, Chapter 3 Allen and Kennedy Presented by Rachel Tzoref and Rotem Oshman. Roadmap. Single Subscript Tests: SIV tests MIV tests GCD Test Banerjee Inequality Trapezoidal Banerjee Inequality

draco
Download Presentation

Dependence Testing

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. Dependence Testing Part II Optimizing Compilers for Modern Architectures, Chapter 3Allen and Kennedy Presented by Rachel Tzoref and Rotem Oshman

  2. Roadmap • Single Subscript Tests: • SIV tests • MIV tests • GCD Test • Banerjee Inequality • Trapezoidal Banerjee Inequality • Testing in coupled groups: Delta Test • Empirical results

  3. MIV Subscripts DO i1 = L1, U1 DO i2 = L2, U2 ... DO in = Ln, Un S1 A(f(i1, ..., in)) = ... S2 ... = A(g(i1, ..., in)) ENDDO ... ENDDO ENDDO

  4. MIV Subscripts • We will assume that

  5. MIV Subscripts • Rearranging, we get ?

  6. GCD Test • Theorem: the equation has a solution iff • No solution ) no dependence! divides

  7. GCD Test: drawbacks • Doesn’t take into account loop bounds • The most common GCD is… 1

  8. The Banerjee Inequality • Input: • A pair of array references A(f(i1, ..., in)), A(g(i1, ..., in)) • Loop bounds L1, U1, …, Ln, Un • A direction vector D = (D1, …, Dn) • Output: whether or not a dependency exists in direction D

  9. The Banerjee Inequality (cont’d) • Define • Let R be the region defined by

  10. The Banerjee Inequality (cont’d) • Does h(x1, …, xn, y1, … yn) = 0 have a solution in the region R? iff

  11. The Banerjee Inequality (cont’d) • Recall: • Define:

  12. The Banerjee Inequality (cont’d) The problem is reduced to:

  13. Finding • is a plane:

  14. Finding • Define

  15. Finding

  16. What about the direction vector? ?

  17. Lemma

  18. Lemma: proof  

  19. Finding

  20. The Banerjee Inequality • We have:

  21. The Banerjee Inequality • Similarly, we obtain:

  22. The Banerjee Inequality:Wrap-up Dependency exists in direction D

  23. Example • Example: DO i = 1, 100 DO j = 1, i - 1 A(j) = A(i + j - 1) + C ENDDO ENDDO D = ( = , = )

  24. Example (cont’d) • Example: DO i = 1, 100 DO j = 1, i - 1 A(j) = A(i + j - 1) + C ENDDO ENDDO D = ( = , = )  Dependence!

  25. Example (cont’d) • Upon closer examination… DO i = 1, 100 DO j = 1, i - 1 A(j) = A(i + j - 1) + C ENDDO ENDDO No dependence!

  26. Trapezoidal Banerjee Inequality • Assume linear bounds:

  27. Trapezoidal Banerjee Inequality • Recall: Dependence • Old strategy: • Minimize / maximize each separately: • Calculate for each independently.

  28. Trapezoidal Banerjee Inequality (cont’d) • New strategy: • We would like to do: . . . min . . . max

  29. Trapezoidal Banerjee Inequality (cont’d) • The problem: • ‘s bounds depend on outer indices: • We can use H- and H+, but we will get

  30. Trapezoidal Banerjee Inequality (cont’d) • Step 1: • Obtain: • Rinse and repeat

  31. Trapezoidal Banerjee Inequality (cont’d) • Algorithm:

  32. Trapezoidal Banerjee Inequality (cont’d) • A closer look: • Suppose Di= “*”. • We want to use: xj or yj ? sink source

  33. Trapezoidal Banerjee Inequality (cont’d) • To prove the bound for Di= “*“, we use Lemma:

  34. Trapezoidal Banerjee Inequality (cont’d) • To prove the bound for Di= “=“, we use Lemma: x’ s AND y’ s! x’s or y’s? sink source

  35. Trapezoidal Banerjee Inequality (cont’d) • What happens if we choose wrong? • Bounds are still correct • … we gave the loop index “more freedom” than it has in reality • Bounds may not be tight ) the test is not precise.

  36. Banerjee Inequality ? 2 array references Loop bounds Direction vector Dependence exists (yes / no) Set of direction vectors 2 array references Loop bounds Using the Banerjee Inequality The desired test:

  37. Testing For All Direction Vectors • Naïve approach (brute force):

  38. Testing For All Direction Vectors • Burke & Cytron’s algorithm:  ? (*, *, *)  ? (<, *, *) (=, *, *) (>, *, *) ?  (=, <, *) (=, =, *) (=, >, *) …

  39. Testing For All Direction Vectors • Burke & Cytron’s algorithm: D: current direction vector k: current coordinate dvlist: set of vectors found in prev. calls

  40. Roadmap • Single Subscript Tests: • ZIV • SIV • MIV • Testing in coupled groups: Delta Test • Empirical results

  41. Reminder • Coupled group: DO i = 1, 100 DO j = 1, 100 A(i + 10, j) = A(i, i - 5) ENDDO i + 10 j i i - 5 < > < > , , coupled

  42. Delta Test Motivation Coupled Subscript group Direction vectors

  43. Motivation • What happens if coupled subscripts are tested separately? • Result = “independent”  really independent • Result = “dependent”  not necessarily dependent • Goal: use information provided by other subscripts where the index appears DO i = 1, 5 A(i + 10, i) = A(i, i) ENDDO

  44. Example 1 DO i = 1, 100 A(i + 1, i) = A(i, i + 1) + C ENDDO • Subscript 1: < • Subscript 2: > • No dependence. Some information can be gained by intersecting direction vectors.

  45. Example 2 DO i = 1, 100 A(i + 1, i + 2) = A(i, i) + C ENDDO • Subscript 1: < • Subscript 2: < • Dependence with direction vector D = ( “<“ ) • … except not.

  46. Example 2 (Take Two) DO i = 1, 100 A(i + 1, i + 2) = A(i, i) + C ENDDO • Subscript 1: d = 1 • Subscript 2: d = 2 • No dependence. More complete information can be gained by intersecting distance vectors.

  47. The Delta Test • Main idea: • Test SIV subscripts (easiest), and get: • Independence, or • Constraint E.g., d = 1 • Apply constraints, hoping to: • Prove independence E.g., (d = 1)  (d = 2) =  or • Reduce MIV subscripts to SIV or ZIV

  48. Example: Reducing Subscript Complexity DO i = 1, 100 DO j = 1, 100 A(i + 1, i + j) = A(i, i + j - 1) ENDDO ENDDO MIV Subscript!

  49. Constraints • Maintain a constraint vector • constraints for the ith index DO i1 = 1, 100 DO i2 = 1, 100 … What can be?

  50. Constraint Types • Initially: <none> • Eventually (we hope): ; Independence

More Related