1 / 33

Control Localization in Domain Specific Translation

Control Localization in Domain Specific Translation. Ted J. Biggerstaff tbiggerstaff@austin.rr.com. Overriding Problem: Antagonistic Goals. High level operators and operands provide programming leverage & variations E.g., ( image  neighborhood) convolution

arne
Download Presentation

Control Localization in Domain Specific Translation

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. Control Localization in Domain Specific Translation Ted J. Biggerstaff tbiggerstaff@austin.rr.com

  2. Overriding Problem: Antagonistic Goals • High level operators and operands provide programming leverage & variations • E.g., (image  neighborhood) convolution • But fracture and de-localize code pieces • b=((a  s)2 + (a  s’)2 )1/2 • Needed optimizations: code sharing, re-org. & re-weaving • Conventional Optimization approaches induce large search spaces (EXPLOSION)

  3. x Constraint x Constraint Propagation NP Complete Reuse Library Alternative Refinements of Program Refine to

  4. Existing Explosion Control: DS Reductionism • Implicit Phases based on Distinct DSLs • Mutually Exclusive DSL Operators & Operands • Inter-Phase Optimization • Metaprogram = {Refine DSL; Optimize Refined DSL} • Result: Group Rules by Phase • One large search space to several small ones

  5. (p, q : a i+p , j+q) (i, j : a i , j) Image a (p, q (sp , q * a i+p , j+q)) * s-1,-1 * s-1,0 b[i,j] + * s-1,1 * s1,1 If hanging then b[i,j]=0 else sum of products loop b[i,j]=0 Large Grain Data & Operators Imply Control b=(a  s)

  6. DSL for Sobel Edge Detection b=[(a  s)2 + (a  s’)2]1/2 a b

  7. Large Grain Extended Expressions (p, q (a i+p , j+q * sp , q)) (p, q (a v+p , w+q * s’p , q)) b=((a  s)2 + (a  s’)2 )1/2 (d,e: a d,e) (i, j : a i , j) (v,w: a v , w)

  8.  Weave   Explosion Control • DSL-> DSL translation phases • DS optimizations • Specialized metaprograms (Control Localization)

  9. Localizing Implied Control b=((a  s)2 + (a  s’)2 )1/2 b=(((i, j : a i , j)  s)2 + ((v, w : a v , w)  s’)2 )1/2 b=(((i, j : (p,q:ai+p , j+q * sp,q))2) +((v, w:(p,q:a v+p , q+w*s’p,q))2))1/2

  10. Localizing Implied Control b=(((i, j : (p,q:ai+p , j+q * sp,q))2) +((v, w:(p,q:a v+p , w+q*s’p, q))2))1/2 b=((i, j : ((p,q: ai+p , j+q * sp,q))2) +(v, w:((p,q: a v+p , w+q*s’p, q))2))1/2 b=(i, j : (((p,q:ai , j * si+p,j+q))2) + (((p,q: a i+p , j+q*s’p, q))2))1/2

  11. Localizing Implied Control b=(i, j : (((p,q:ai , j * si+p,j+q))2) + (((p,q: a i+p , j+q*s’p, q))2))1/2 b=i, j : ((((p,q:ai , j * si+p,j+q))2) +(((p,q: a i+p , j+q*s’p, q))2))1/2 (d, e:bd , e)=i, j : ((((p,q:ai , j*si+p,j+q))2) + (((p,q: a i+p , j+q*s’p, q))2))1/2

  12. Localizing Implied Control (d, e:bd , e) =i, j : ((((p,q:ai , j*si+p,j+q))2) + (((p,q: a i+p , j+q*s’p, q))2))1/2 (i, j : (b i, j=(((p,q:ai , j*si+p,j+q))2) + (((p,q: a i+p , j+q*s’p, q))2))1/2)

  13.  Weave   Explosion Control • DSL-> DSL translation phases • DS optimizations • Specialized metaprograms (Control Localization) • Group rules by object & phase • Use domain knowledge

  14. Explicit Entities & Phases

  15. Example Loop Opt. Transform 

  16. Example (Idealized) AST Transformation b=((a  s)2 + (a  s’)2 )1/2  b=(((i, j : a i , j)  s)2 + (a s’)2 )1/2

  17. Example (Actual) AST Transformation b=((a  s)2 + (a  s’)2 )1/2  b=((( idx2139, idx2145: bwpixel2136)  s)2 + (a s’)2 )1/2 Wherebwpixel2136 =a idx2139, idx2145

  18. CLOS Object Property List  (leaf a (tags (itype image))) b=((( idx2139, idx2145: bwpixel2136)  s)2 + (a s’)2 )1/2 (leaf bwpixel2136 (tags (_q (_forall (idx2139 idx2145) (_suchthat (_member idx2139 (_range 0 (- m 1))) (_member idx2145 (_range 0 (- n 1))) (mappings (bwpixel2136) (a))))) (itype bwpixel))) Example (Implementation) AST Transformation b=((a  s)2 + (a  s’)2 )1/2

  19. Name, Phase, Location Example Loop Opt. Transform • Refine Image to BWPixel with loop shorthand tags (=> compositeleaf fusion2 image LHS RHS PreRoutine PostRoutine)

  20. Name, Phase, Location Example Loop Opt. Transform • Refine Image to BWPixel with loop shorthand tags (=> compositeleaf fusion2 image `$(pand $(por (leaf ?op) ?op)) …sub-pattern to get type … …sub-pattern to get dimensions of ?op…) LHS RHS PreRoutine PostRoutine)

  21. Name, Phase, Location Example Loop Opt. Transform • Refine Image to BWPixel with loop shorthand tags (=> compositeleaf fusion2 image `$(pand $(por (leaf ?op) ?op)) ($(spanto ?pre (tags)) (tags $(spanto ?pretags (itype ?itype)) ?spaceover $(remain ?posttags))) …sub-pattern to get dimensions of ?op…) LHS RHS PreRoutine PostRoutine)

  22. Name, Phase, Location Example Loop Opt. Transform • Refine Image to BWPixel with loop shorthand tags • Enablecompositeleaf creates ?newleaf, ?idx1, ?idx2 (=> compositeleaf fusion2 image `$(pand $(por (leaf ?op) ?op)) ($(spanto ?pre (tags)) (tags $(spanto ?pretags (itype ?itype)) ?spaceover $(remain ?posttags))) …sub-pattern to get dimensions of ?op…) LHS RHS enablecompositeleaf nil) Pre &Post Routines

  23. RHS Rewrite Form `(leaf ?newleaf (tags (commasplice ?pretags) (_q (_forall (?idx1 ?idx2) (suchthat (_member ?idx1 (_range ?ilow ?ihigh)) (_member ?idx2 (_range ?jlow ?jhigh)) (mappings (?newleaf) (?op))))) (itype BWPixel) (commasplice ?posttags)))

  24. Name, Phase, Location Example Loop Opt. Transform • Refine Image to BWPixel with loop shorthand tags • Enablecompositeleaf creates ?newleaf, ?idx1, ?idx2 (=> compositeleaf fusion2 image `$(pand $(por (leaf ?op) ?op)) ($(spanto ?pre (tags)) (tags $(spanto ?pretags (itype ?itype)) ?spaceover $(remain ?posttags))) …sub-pattern to get dimensions of ?op…) LHS `(leaf ?newleaf (tags (commasplice ?pretags) (_q (_forall (?idx1 ?idx2) (suchthat (_member ?idx1 (_range ?ilow ?ihigh)) (_member ?idx2 (_range ?jlow ?jhigh)) (mappings (?newleaf) (?op))))) (itype BWPixel) (commasplice ?posttags))) RHS enablecompositeleaf nil) Pre &Post Routines

  25. Loop Control Phase Traversal You Are Here b=[(a  s)2 + (a  s’)2]1/2 Property List Behind The Scenes (leaf a (tags (itype image))) CLOS Object

  26. b=[(a  s)2 + (a  s’)2]1/2 Pattern Match Result `$(pand $(por (leaf ?op) ?op)) ($(spanto ?pre (tags)) (tags $(spanto ?pretags (itype ?itype)) ?spaceover $(remain ?posttags)))…) ?op { ?spaceover Behind The Scenes { { (leaf a (tags (itype image))) ?posttags ?pre ?itype ?pretags

  27. b=[(a  s)2 + (a  s’)2]1/2 Pattern Match Result Define enablecompositeleaf (at, bindings) {?idx1 = Create iterator; ?idx2 = Create iterator; ?newleaf = Create bwpixel; return extended bindings} ?idx1  idx2139 ?idx2  idx2145 ?newleaf  bwpixel2136 ?op { ?spaceover Behind The Scenes { { (leaf a (tags (itype image))) ?posttags ?pre ?itype ?pretags

  28. Rewrite Result b=[(bwpixel2136  s)2+ (a  s’)2]1/2 `(leaf ?newleaf (tags (commasplice ?pretags) (_q (_forall (?idx1 ?idx2) (suchthat (_member ?idx1 (_range ?ilow ?ihigh)) (_member ?idx2 (_range ?jlow ?jhigh)) (mappings (?newleaf) (?op))))) (itype BWPixel) (commasplice ?posttags))) (leaf bwpixel2136 (tags (_q (_forall (idx2139 idx2145) (_suchthat (_member idx2139 (_range 0 (- m 1))) (_member idx2145 (_range 0 (- n 1))) (mappings (bwpixel2136) (a))))) (itype bwpixel)))

  29. Bindings Before History After Transform Shown In Debugger

  30. Speculative Refinement • Dynamically build coordinated rules to express constraint set bwpixel2034  b idx2037, idx2043 idx2139  idx2037 idx2145  idx2043 bwpixel2987  bwpixel2136 bwpixel2136  a idx2037, idx2043

  31. Explosion Control • DSL-> DSL translation phases • DSL specific optimizations • Simplification & DS Optimizations • Key Point: DS Reductions Not Combinations • Localization • Separate Parts Woven into Computational Form • Group Rules by Object & Phase • Use Domain Knowledge • Architectural Shaping • Interdependent, Composed Parts Changed per Global Constraints

  32. References • Katz & Volper, Constraint Propagation in Software Libraries of Transformation Systems, IJSE&KE 2,3, 1992. • Biggerstaff, Fixing Some Transformation Problems, Proc. Of Automated Software Engineering, 1999. • Biggerstaff, A New Control Structure for Transformation-Based Generators, ICSR 2000. • Neighbors, Draco: A Method for Engineering Reusable Software Systems, inSoftware Reusability, 1989.

  33. The End

More Related