Title: New Transformation Structures in AOG
1New Transformation Structures in AOG
2Overriding 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)
3Constraint Propagation NP Complete
Reuse Library
Alternative Refinements of
Program
Refine to
4Large Grain Data Operators Imply Control
b(a ? s)
5Control Diffusion In Extended Expressions
(?p, q (a vp , wq sp , q))
(?p, q (a ip , jq sp , q))
b((a ? s)2 (a ? s)2 )1/2
(?i, j a i , j)
(?v,w a v , w)
(?d,e a d,e)
6Control Localization
- Explicit control considered harmful
- AOG Control implicit in operators and data
- Derive custom, integrated control structure
- Coordinate set of constraints over expression
- Explosion control
- Specialized problem
- Group rules by object phase
- Use domain knowledge
7Global Constraints Affect Code
- SIMD (MMX), DB, UI, middleware, network
- Shape of code determined by external constraints
- Correctness preserving transformations
- Re-shaping code (Architectural Shaping)
8Non-Parallel Architectural Effects
9Non-Parallel Pseudo-Code
If (Off Edge) then bi,j 0 else bi,j (
ai-1, j-1(-1) ai-1, j(-2)
ai-1, j1(-1) ai1, j-11 ai1,
j2 ai1, j11 )
10b(a ? s)2 (a ? s)21/2
INT JM1, JP1, IM1, IP1
FOR (I0 I lt (M-1) I)
IM1I-1 IP1 I1
FOR (J0 J lt (N-1) J)
JM1 J-1 JP1 J1
IF(I0 J0 (I(M-1)) (J(N-1)))
THEN BI, J 0
ELSE
T1AIP1 , JP1 - AIP1 , JM1
(AI , JP1 2) - (AI , JM1 2)
AIM1 , JP1 - AIM1 , JM1
T2 AIP1 , JP1 (AIP1 , J 2)
AIP1 , JM1 - AIM1 , JP1 -
(AIM1 , J 2) - AIM1 , JM1
BI, J SQRT(T1T1 T2T2 )
11Parallel Architectural Effects
12Parallel Pseudo-Code
bi,j unpackadd(padd2(padd2(pmadd3((ai-1,j-1
), (s-1, -1)),
pmadd3((ai, j-1),
(s0, -1))), pmadd3((ai1,j-1),
(s 1, -1)))
13Version for MMX Architecture
int s(-11), (-11)-1, 0, 1, -2, 0 , 2,
-1, 0, 1 int sp (-11), (-11)-1, -2,
-1, 0, 0, 0, -1, -2, -1 for (j0 j lt n
j) b0,j 0 for (i0 i lt m i) bi,0
0 for (j0 j lt n j) b(m-1),j 0 for
(i0 i lt m i) bi,(n-1) 0 for (i1 i lt
(m-1) i) for (j1 j lt (n-1) j)
t1 UNPACKADD(PADD2 (PADD2(PMADD3
((ai-1, j-1), (s-1, -1)) ,
PMADD3 ((ai, j-1), (s 0, -1))), PMADD3
((ai1,j-1), (s 1, -1))) t2
UNPACKADD(PADD2 (PADD2(PMADD3 ((ai-1,
j-1), (sp-1, -1)), PMADD3 ((ai,
j-1), (sp 0, -1))), PMADD3 ((ai1,
j-1), (sp 1, -1))))) bi,j
sqrt(t1t1 t2t2)
14Architectural Shaping
- Computational structure shaped per external
constraints - SIMD (MMX), DB, UI, middleware, network
- Much DK known about parts at creation time
- Optimization trajectories of parts known at
creation - Tags express domain opt. Knowledge
- Tags triggered by events
15Tags Record Properties
?r ? (p q) ?range ? range(s) ?
-11,-11 ?expr ? ai,j s3240p,q
16Tags Record Properties
?r ? (p q) ?range ? range(s) ?
-11,-11 ?expr ? ai,j s3240p,q
17But When to Trigger It??
?r ? (p q) ?range ? range(s) ?
-11,-11 ?expr ? ai,j s3240p,q
(_MMXLOOP p q)
18Event-Driven Tags
- What optimization to apply
- Where to apply it
- When to apply it
19AOG Mechanisms
- Control Localization
- Pattern directed rules
- Organize in 2D space (objects phases)
- Architectural reshaping
- Tag-Directed (TD) transformations
- (What, where, when)
- TD Transformations are procedures
- Large grain, goal oriented, flexible strategies
- Phases and events
- Simplification by partial evaluation
20Problem Context
21The End
22Explosion Control
- DSL-gt DSL translation phases
- DS optimizations
- Specialized metaprograms (Control Localization)
- Group rules by object phase
- Use domain knowledge