Ross Tate Mike Stepp Zach Tatlock Sorin Lerner University of California San Diego Traditional Optimization Phase Ordering Problem Local Profitability Heuristics Original Program ID: 675101
Download Presentation The PPT/PDF document "Equality Saturation: A New Approach to O..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Equality Saturation:A New Approach to Optimization
Ross Tate
, Mike
Stepp
, Zach
Tatlock
,
Sorin
Lerner
University of California, San DiegoSlide2
Traditional Optimization
Phase
Ordering
Problem
Local
Profitability
Heuristics
Original Program
Optimized Program
OptimizationsSlide3
Traditional OptimizationSlide4
Exploring EquivalencesSlide5
Exploring EquivalencesSlide6
Our Approach
CFG→PEG Conversion
P
rogram
E
xpression
G
raphSlide7
Our Approach
Equality SaturationSlide8
Our Approach
Global Profitability HeuristicSlide9
Our Approach
PEG→CFG ConversionSlide10
Mitigates Phase Ordering ProblemNon-destructive updates allow exponential searchGlobal Profitability Heuristic
Explore first, then decide
Translation ValidationVerify translations using equality saturation
BenefitsSlide11
sum = 0;
for (
i
= 0; i < 10; i++)
sum += 4 * i;return sum;
ExampleSlide12
sum = 0;
for (
i
= 0;
i
< 10;
i
++)
sum += 4 *
i
;
return sum;
Representing Loops
1
θ
1
*
4
+
0
Complete Representation
Referentially Transparent
No Intermediate VariablesSlide13
Identify Equalities
PEG Node Granularity
Equality Axioms
∀X. 4*X = (X≪2)
Equality Analyses1
θ
1
*
4
+
0
2
<<
∀
X. 4
*
X = (X≪2)Slide14
Equality Inference
1
θ
1*
4
+
0
+
*
4
1
*
4
θ
1
*
4
*
4
0
∀
X,Y,Z. X
*
(Y+Z) = X
*
Y+ X
*
Z
∀
X. X
*
0 = 0
2
<<
∀
X. 4
*
X = (X≪2)
∀
X,Y. 4
*
θ
(X, Y) =
θ
(4
*
X, 4
*
Y)
∀
X. X
*
1 = XSlide15
E-PEG
1
θ
1
*
4
+
0
*
+
4
1
θ
1
*
4
*
4
0
2
<<Slide16
PEG Selection
+
4
θ
1
0
1
θ
1
*
4
+
0
*
1
*
4
*
4
2
<<
Global Profitability HeuristicSlide17
Optimized PEG
4
θ
1+
0Slide18
sum = 0;
for(j = 0; j < 40; j += 4)
sum += j;
return sum;
Optimized Program
4
θ
1
+
0Slide19
sum = 0;
for(j = 0; j < 40; j += 4)
sum += j;
return sum;
Optimized Program
sum = 0;
for(
i
= 0;
i
< 10;
i
++)
sum += 4
*
i
;
return sum;
Loop Induction Variable Strength ReductionSlide20
Optimizations composed from simple rulesLoop Induction Variable Strength Reduction
Loop-Operation Factoring
Loop-Operation DistributingInter-Loop Strength ReductionTemporary Object RemovalPartial
InliningEmergent OptimizationsSlide21
ImplementationSlide22
Algorithm provided in the Technical ReportModel heap with values having linear types
ImplementationSlide23
Tarjan’s Union-Find Algorithmtracks equivalence classes in the E-PEG
Rete
Pattern Matching Algorithmincrementally finds significant nodes in the E-PEGEquality Analyses:
PEG Operator AxiomsLanguage-Specific AxiomsDomain-Specific AxiomsImplementationSlide24
Pseudo-Boolean SolverAssign a cost to each operation in the E-PEG
Impose constraints for a well-formed PEG
Minimize the cost of the selected PEGImplementationSlide25
1499
msec
14
msec
88 msec43 msec
Observed Emergent Optimizations
Traditionally need to be explicitly implementedDomain-Specific Analyses:7% runtime improvement on Java ray tracerCompilation of
SpecJVM (per method):1030 programs found in less than 200MB memoryAverage compilation time per stage:
Peggy: Java Bytecode Optimizer
1499
msecSlide26
Validation of Soot optimizer on
SpecJVM
:
98% of optimized methods successfully validated
Optimization bug found within remaining 2%
Translation
Validator
CFG→PEG Conversion
CFG→PEG Conversion
Equality Saturation
?Slide27
PowerfulSimultaneous Exponential Search
Emergent Optimizations
ExtensibleCooperative Equality AnalysesDomain-Specific Axioms
GeneralOptimizationTranslation ValidationConclusionsSlide28
E-GraphsDenali: Basic Block Assembly Superoptimizer
Simplify: Theorem
ProverRepresentationsThinned-Gated SSA
Lucid programming languageValue Dependence GraphDependence Flow GraphProgram Dependence Graph/WebRewrite-Based OptimizersTAMPRASF+SDFStratego
Related Work