1 / 75

A Characterization of Reuse Technologies

A Characterization of Reuse Technologies. Ted J. Biggerstaff tbiggerstaff@austin.rr.com. Reuse Technologies. Concrete components e.g., Functions, OOP, Frameworks, DCOM, … Compositionally Derived Components e.g., Templates, GenVoca, … Pattern-directed transformation systems

shalin
Download Presentation

A Characterization of Reuse Technologies

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. A Characterization of Reuse Technologies Ted J. Biggerstaff tbiggerstaff@austin.rr.com

  2. Reuse Technologies • Concrete components • e.g., Functions, OOP, Frameworks, DCOM, … • Compositionally Derived Components • e.g., Templates, GenVoca, … • Pattern-directed transformation systems • e.g., Draco, CAPE, IP, DMS, Sinapse, ...

  3. Control Regimes • PD Search – Independent Local Choices • Strategically Blind – exploding search space • Biased Toward Local Syntactic Structure • Rules are General & Allow Easy Extension

  4. Control Regimes • PD Search – Independent Local Choices • Strategically Blind – exploding search space • Biased Toward Local Syntactic Structure • Rules are General & Allow Easy Extension • MetaPrograms – Algorithmic • Strategically & Tactically Purposeful • State Dependent Actions Reduce Search Space • Representation Makes Extensions Hard

  5. x Constraint x Constraint Propagation Problem Reuse Library Alternative Refinements of Program Refine to

  6. PD Explosion Control • Group Rules by Phase • Implicit Phases based on Distinct DSLs • Mutually Exclusive DSL Operators & Operands

  7. Draco Domains

  8. Data Base Relational Algebra Index Tuple Abstract Data Types C Code Refinements Component: Insert(Value V, Container C) {Refinement: Stack Condition: LIFO(C) Code: {Push(V,C)}} {Refinement: Sorted Container Condition: SortedOn(C, Value) Assertion: SortedOn(C, Value) Code: {Merge(V,C)}} ...}

  9. PD Explosion Control • Group Rules by Phase • Implicit Phases based on Distinct DSLs • Mutually Exclusive DSL Operators & Operands • … and based MetaProgram • {Refine DSL; Optimize Refined DSL}

  10. Domain to self: Join(?Relation1, Empty_Relation, ?Attribute) =>Empty_Relation Select(?Relation1,TRUE_expression) =>Relation1 Select(?Relation1,FALSE_expression) => Empty_Relation Data Base Relational Algebra Index Tuple Abstract Data Types C Code Optimizing Transforms

  11. Kinds of Optimization • Simplification & DS Optimizations • Key Point: DS Reductions Not Combinations

  12. Pattern-Directed Systems • Example domain: communications protocols • Benefits: • Fine grain rules allow great horizontal scaling • Small search spaces (DSL->DSL) vs. one large • Powerful in-domain optimizations • Shortcomings: • Global reorganizing optimizations can explode search space

  13. Essence of The Technology ClassElementsOperations Concrete Reuse PL Struct. Hand Assem. Composition Abstract PL Inlining PD Generator DSL Struct. PD Xforms

  14. Reuse Technologies • Concrete components • e.g., Functions, OOP, Frameworks, DCOM, … • Compositionally Derived Components • e.g., Templates, GenVoca, … • Pattern-directed transformation systems • e.g., Draco, CAPE, IP, DMS, Sinapse, ... • Reorganizing generator systems • AO generator (AOG), AOP, ...

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

  16. 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)

  17.  Weave   Kinds of Optimization • Simplification & DS Optimizations • Key Point: DS Reductions Not Combinations • Localization • Separate Parts Woven into Computational Form • General Interdependent Parts Problem NP Complete • Tractable Via Narrow Domain Knowledge & Grouping

  18. Explosion Control • Group Rules by Phase • Implicit Phases based on Distinct DSLs & {Refine; Optimize} MetaProgram • Explicit Finer Grain Phases • {Loop Optimization, Code Generation, …} • Group Rules by Named Entity • E.g., Type or Operator or Arbitrary Entity • Mechanisms in AOG, Stratego, etc. • AOG Uses Both Entity and Phase

  19. Explicit Entities & Phases

  20. Example Loop Opt. Transform 

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

  22. 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)

  23. 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)

  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 RHS enablecompositeleaf nil) Pre &Post Routines

  25. 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 (?newleaf) (,arefop (?op) ?idx1 ?idx2))) (Itype BWPixel) (commasplice ?posttags))) RHS enablecompositeleaf nil) Pre &Post Routines

  26. 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

  27. 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

  28. 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  idx48146 ?idx2  idx48149 ?newleaf  bwpixel48143 ?op { ?spaceover Behind The Scenes { { (leaf a (tags (itype image))) ?posttags ?pre ?itype ?pretags

  29. Rewrite Result b=[(bwpixel48143  s)2+ (a  s’)2]1/2 `(leaf ?newleaf (tags (commasplice ?pretags) (_Q (_FORALL (?newleaf) (,arefop (?op) ?idx1 ?idx2))) (itype bwpixel) (commasplice ?posttags))) (leaf bwpixel48143 (tags (_q (_forall (bwpixel48143) (aref (a) idx48146 idx48149))) (itype bwpixel))) Behind The Scenes

  30. Kinds of Optimization • Simplification & DS Optimizations • Key Point: DS Reductions Not Combinations • Localization • Separate Parts Woven into Computational Form • Architectural Shaping • Interdependent, Composed Parts Changed per Global Constraints

  31. Architectural Shaping • Computational Structure Shaped per External Constraints • SIMD (MMX), DB, UI, Middleware, Network

  32. B=(A  s) Image A * s-1,-1 * s-1,0 B[i,j] + * s-1,1 * s1,1 B[i,j]=0 Non-Parallel Architectural Effects

  33. “b=[(a  s)2 + (a  s’)2]1/2” INT JM1, JP1, IM1, IP1; FOR (I=0; I < (M-1); ++I) { IM1=I-1; IP1= I+1; FOR (J=0; J < (N-1); ++J) { JM1= J-1; JP1 = J+1; IF(I==0 || J==0 || (I==(M-1)) || (J==(N-1))) THEN {B[I, J] = 0 ; } ELSE {T1=A[IP1 , JP1] - A[IP1 , JM1] + (A[I , JP1] * 2) - (A[I , JM1] * 2) + A[IM1 , JP1] - A[IM1 , JM1]; T2 = A[IP1 , JP1] + (A[IP1 , J] * 2) + A[IP1 , JM1] - A[IM1 , JP1] - (A[IM1 , J] * 2) - A[IM1 , JM1]; B[I, J] = SQRT(T1*T1 + T2*T2 );}}}

  34. B=(A  s) B[0,j]=0 Image A Pixels Weights S Pmadd3( * ) Pmadd3( * ) B[i,j] + Pmadd3( *) B[i, (n-1)]=0 B[i,0]=0 B[(m-1),j]=0 Parallel Architectural Effects

  35. “b=[(a  s)2 + (a  s’)2]1/2” {int s[(-1:1), (-1:1)]={{-1, 0, 1}, {-2, 0 , 2}, {-1, 0, 1}}; int sp [(-1:1), (-1:1)]={{-1, -2, -1}, {0, 0, 0}, {-1, -2, -1}}; for (j=0; j < n; j++) b[0,j] = 0 ; for (i=0; i < m; i++) b[i,0] = 0 ; for (j=0; j < n; j++) b[(m-1),j] = 0 ; for (i=0; i < m; i++) b[i,(n-1)] = 0 ; {for (i=1; i < (m-1); i++) {for (j=1; j < (n-1); j++) {t1 = UNPACKADD(PADD2 (PADD2(PMADD3 (&(a[i-1, j-1]), &(s[-1, -1])) , PMADD3 (&(a[i, j-1]), &(s[ 0, -1]))), PMADD3 (&(a[i+1,j-1]), &(s[ 1, -1]))); t2 = UNPACKADD(PADD2 (PADD2(PMADD3 (&(a[i-1, j-1]), &(sp[-1, -1])), PMADD3 (&(a[i, j-1]), &(sp[ 0, -1]))), PMADD3 (&(a[i+1, j-1]), &(sp[ 1, -1]))))); b[i,j] = sqrt(t1*t1 + t2*t2);}}}

  36. Architectural Shaping • Computational Structure Shaped per External Constraints • SIMD (MMX), DB, UI, Middleware, Network • Central MetaProgram Combinatorial Complexity • O(100) Transforms To Parallelize Example • Must Recognize Opportunity and Place • Must Rediscover Domain Knowledge (DK) • Much DK Known About Parts at Creation Time • Optimization Trajectories of Parts Known at Creation

  37. Explosion Control • Constraint Propagation NP Complete • Simplify Constraint Propagation • MetaPrograms Exploit DS Knowledge • Global Constraints (MMX) Determine Cooperating, Distributed MetaPrograms • Pre-Propagation of Constraints via Tags • Pre-Plan Ordering Constraints on Distributed MetaPrograms • Result: Tag-Directed Transformations

  38. Explosion Control • Tag-Directed Transformations • MetaPrograms Tagged onto Reusable Parts • WHAT Transformation • (SplitLoopOnCases) • WHEN to Fire • (on EventName (SplitLoopOnCases)) • WHERE to Apply • (if CaseTest then SpecialCase else GeneralCase (Tags (on … (SplitLoopOnCases))))

  39. Example: SplitLoopOnCases for(i=0, j=0; i<m && j<n; i++, j++) if(i==0 || j==0 || i==(m-1) || j==(n-1)) ...then case...; ...else case...;  for(j=0; j<n; j++)...then case with i=0...; for(j=0; j<n; j++)...then case with i=(m-1)...; for(i=0; i<m; i++)...then case with j=0...; for(i=0; i<m; i++)...then case with j=(n-1)...; for(i=1, j=1; i<(m-1) && j<(n-1); i++, j++) ...else case...;

  40. Cooperating TD Transforms • Generate Weight Matrices • Create Loops, Unwrap, Partially Evaluate • Split Loop+If into Loop Cases • Simplify Special Case Loops • Create Loops, Infer Control, Partially Evaluate • Reshape Image Loop Body

  41. Ordering Dependencies • Dependencies Supported • Per Strategic Plan – (on PlanStep …) • Before & After – (on (completion Xform)…) • On Local Action – (on substitutionofme …) • On Signal – (on ?signalvbl …)

  42. Explosion Control Summary • Refinements – Implied DSL to DSL Phases • Specialized Optimizations • Simplification & DS Opt. – PE & PD Rules • Localization – Explicit Rule Grouping • Architectural Shaping –Tag-Directed Control • Distributed MetaPrograms on Reusable Parts • Avoid General NP Complete Problem • Specialized Sub-Problems & Use DK

  43. 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.

  44. Reuse Technologies • Concrete components • e.g., Functions, OOP, Frameworks, DCOM, … • Compositionally Derived Components • e.g., Templates, GenVoca, …

  45. Essence of The Technology ClassElementsOperations Concrete Reuse PL Struct. Hand Assem. Composition Abstract PL Inlining

  46. The scaling plane Large, high payoff Vertical (Programming leverage) Reuse Payoff Small, low payoff Feature variability One-size fits all Customized Horizontal (Optimality of fit)

  47. Reorganizing Generators • Benefits: • Inter-component optimizations (reweavings) • Small search space = reasonably fast • Shortcomings: • Technology immature • Unclear how far it can be pushed

  48. Reuse Technologies • Concrete components • e.g., Functions, OOP, Frameworks, DCOM, …

  49. Essence of The Technology ClassElementsOperations Concrete Reuse PL Struct. Hand Assem.

More Related