generating compiler optimizations from proofs

Download Generating Compiler Optimizations from Proofs

If you can't read please download the document

Upload: asis

Post on 25-Feb-2016

48 views

Category:

Documents


0 download

DESCRIPTION

Generating Compiler Optimizations from Proofs. Ross Tate Michael Stepp Sorin Lerner University of California, San Diego. Optimizing by Hand. Original. Optimized. for (i = 0; i < 5 0 ; i++) for (j = 0; j < 5 0 ; j++) *(img++) = f(i, j); Executes more efficiently. - PowerPoint PPT Presentation

TRANSCRIPT

Generating Compiler Optimizations from Proofs

Generating Compiler Optimizations from ProofsRoss TateMichael SteppSorin LernerUniversity of California, San DiegoOptimizing by HandOriginalfor (i = 0; i < 50; i++) for (j = 0; j < 50; j++) img[i*50 + j] = f(i, j);

Easier to understandOptimizedfor (i = 0; i < 50; i++) for (j = 0; j < 50; j++) *(img++) = f(i, j);

Executes more efficientlyMake the compiler do it!Train the compiler to do it!Many compilers do not perform this optimizationfor (i = 0; i < 50; i++) for (j = 0; j < 50; j++) img[i*50 + j] = f(i, j);

for (i = 0; i < w; i++) for (j = 0; j < h; j++) use(img[i*h + j])Generalizing OptimizationsOriginalOptimizedfor (i = 0; i < 50; i++) for (j = 0; j < 50; j++) *(img++) = f(i, j);

for (i = 0; i < w; i++) for (j = 0; j < h; j++) use(*(img++))Generalizeh is loop-invariantuse does not modify i, j, or imgGeneralizedGeneralizing AutomaticallyOriginalfor (i = 0; i < 50; i++) for (j = 0; j < 50; j++) img[i*50 + j] = f(i, j);Optimizedfor (i = 0; i < 50; i++) for (j = 0; j < 50; j++) *(img++) = f(i, j);How it works

Proof GeneralizerInstantiationProgrammers can teach the compilerwith just one concrete exampleusing a language they already knowProof informs which details in the programs are actually importantTranslation Validator8 + 8 8 = 8

8 + 8 88Translation ValidatorGeneralized Proofx. x x = 0x,y. x = 0 y + x = yi) 8 8 = 0

ii) 8 + 8 8 = 8Uses fact iAdds fact iiAdds fact iTranslation ValidatorProof GeneralizerProof Generalizerc,d.i) 8 8 = 0

8 + 8 88ii) a = bUses fact iAdds fact iiAdds fact ii) c = 0

abi) c = 0

ii) a = bi) c = 0

ii) d + c = bi) c = 0

ii) d + c = dd + cc = 0d + c = de.e e = 0i) e e = 0

i) e e = 0

ii) d + e e = dd + e edInstantiation: d,e 8aabbcccca = bc = 08Learned Optimizationd + e edTranslation ValidatorProof Generalizer8 + 8 88Most General Optimization for this proofby examining a proof of equivalenceAbstract AlgorithmFormalized using category theoryPushoutsPullbacksPushout Completions

Different categories for different logicsDifferent representations of programsDomains besides program optimizationsProof GeneralizerApplication &Evaluation

Translation ValidatorProof GeneralizerTraining the OptimizerNeed a more expressive logicProgram Expression Graphs [POPL 09]Training the OptimizerInter-Loop Strength & Bound ReductionLoop Induction Strength & Bound ReductionPartial & Specialized InliningTemporary Object RemovalLoop Operation Factoring & DistributionEntire Loop Strength ReductionArray Copy PropagationDesign Pattern Overhead ReductionAs translation validation improves,so will optimization learning, for free!We wantadvanced optimizationsthe speed of the rewriterSpeeding Up OptimizationRan on a ray tracerRewriter produced high-quality codeDecomposerOptimization GeneralizerFast Rewriter

Advanced OptimizerFlexible Proof GeneralizationLearn database query optimizations

Improve type error messages in Haskell

Assist with contract debugging in Spec#

Infer polymorphism in typed programs

Proof GeneralizerConclusionAlgorithm to learn compiler optimizationsfrom programmersfrom superoptimizers

Abstract proof generalization algorithmApplicable to other logicsApplicable to other domains

Thank YouConclusionAlgorithm to learn compiler optimizationsfrom programmersfrom superoptimizers

Abstract proof generalization algorithmApplicable to other logicsApplicable to other domains

???