Download presentation
Presentation is loading. Please wait.
Published byNicholas Rowe Modified over 11 years ago
1
A Framework for Unrestricted Whole-Program Optimization Spyridon Triantafyllis, Matthew J. Bridges, Easwaran Raman, Guilherme Ottoni, David I. August The Liberty Research Group Department of Computer Science Princeton University
2
Velocity Compiler Research 2 Procedure-Based Compilation if (EOB) d=a*b fill B ret z=x*y f(x,y,5) f(1,2,3) g()h()f(a,b,c) Procedure-Based Compilation Pros: Well Known Cons: Can not exploit opportunities that cross procedures …=z
3
Princeton University Velocity Compiler Research 3 Interprocedural Analysis [Sharir78] [Morel78] [Reps95] Pros: Increases available information Enables some optimization across procedure boundaries Cons: Has to analyze the entire program Optimizations need to respect the procedure boundary if (EOB) d=a*b fill B ret z=x*y f(x,y,5) f(1,2,3) g()h()f(a,b,c) …=z
4
Princeton University Velocity Compiler Research 4 Interprocedural Analysis & Interprocedural Opti Interprocedural Analysis [Sharir78] [Morel78] [Reps95] Pros: Increases available information Enables some optimization across procedure boundaries Cons: Has to analyze the entire program Optimizations need to respect the procedure boundary Most optimizations will still be intraprocedural if (EOB) d=z fill B ret z=x*y f(x,y,5,z) f(1,2,3,2) g()h()f(a,b,c,z) …=z
5
Princeton University Velocity Compiler Research 5 Inlining Inlining [Scheifler 77] [Hwu89] [Chang92] Pros: Increases optimization scope Enables specialization Doesnt require opti to understand interprocedural concerns Cons: Hard limit on procedure size Unnecessary code growth z=x*y g() if (EOB) d=z jump fill B if (EOB) d=a*b fill B ret f(1,2,3) h() f(a,b,c) …=z
6
Princeton University Velocity Compiler Research 6 Partial Inlining z=x*y g() if (EOB) d=z f() jump fill B return f() if (EOB) d=a*b fill B ret f(1,2,3) h() f(a,b,c) Partial Inlining [Suganuma03][Way00] Pros: Can alleviate some code growth Cons: Gains are limited …=z
7
Princeton University Velocity Compiler Research 7 Why Procedures? if (EOB) fill B ret z=x*y f(x,y,5) f(1,2,3) g()h()f(a,b,c) z=x*y Procedures Calling convention boundary Single-Entry, Single-Exit Pros: Implicit correlated edges - context sensitivity Natural unit for divide & conquer compilation Cons: Optimized for software- engineering Restricts optimization We dont have to use procedures! …=z d=a*bd=z
8
Princeton University Velocity Compiler Research 8 The Whole-Program CFG if (EOB) d=a*b fill B jump z=x*y Retain useful traits of procedures Correlated edges Compilation unit Goal: Obtain an optimizable whole-program representation Increase optimization scope Allow all opti to operate on increased scope without change Targeted code growth …=z
9
Princeton University Velocity Compiler Research 9 The Whole-Program CFG B C D E HF A G (1(1 (2(2 )1)1 )2)2 Represent calls and returns as special control-flow transitions [Sharir78] Retain useful traits of procedures Correlated edges Compilation unit Goal: Obtain an optimizable whole-program representation Increase optimization scope Allow all opti to operate on increased scope without change Targeted code growth
10
Princeton University Velocity Compiler Research 10 Whole-Program Optimizations B C D E H F A G (1(1 (2(2 )2)2 B C E F )1)1 )1)1 Optimization destroys the programs procedural structure! Example: Superblock Formation [Hwu92] Unconventional call structures! Many-to-many call return relation Must rediscover structure for summary edges
11
Princeton University Velocity Compiler Research 11 Context-Sensitive Interprocedural Analysis [Sharir78] meet over all realizable paths Identify Entry-Exit Pairs (EEP): Correlated call & return arcs Allows use of summary edges Blocks may belong to more than one EEP Analyzing the Whole-Program CFG B C D E H F A G (1(1 (2(2 )2)2 B C E F )1)1 )1)1 (BE) CBE (BF) CBED CBED
12
Princeton University Velocity Compiler Research 12 Determining a Compilation Unit: Region Formation B C D E H F A G (1(1 (2(2 )2)2 B C E F )1)1 )1)1 Region Formation [Hank95] arbitrarily shaped, compiler- selected compilation unit Region Selection Select seed & add neighbors (profile, structure, dataflow …) Success Criteria Optimizability vs. compile time Few too small or too big regions Intra-region transitions » inter- region transitions Encapsulation Make regions independently optimizable Compiler is free to select its own optimization units!
13
Princeton University Velocity Compiler Research 13 Evaluation Framework: The Velocity Compiler Frontend Procedures Superblock Classical & ILP Optimizer Executable Baseline Superblock Executable Procedures Inlining Frontend Inlining PBE WCFG Region Form. Superblock Regions Executable Procedures Frontend Determine Compilation Unit Optimize Compilation Unit Classical & ILP Optimizer Classical & ILP Optimizer Evaluation: Inliner & Opti. ported from IMPACT Targeting Itanium 2 Procedures Scheduling
14
Princeton University Velocity Compiler Research 14 Code Growth Code Size 1.45 1.23
15
Princeton University Velocity Compiler Research 15 Speedup - Train Input 1.07
16
Princeton University Velocity Compiler Research 16 Conclusion Procedure boundaries restrict optimization! Ways to deal with procedures exist, but limited Interprocedural analysis & opti: Scales badly, not always possible Inlining: Unnecessary Code growth Procedures are not the right compilation unit PBE offers unrestricted and practical whole-program optimization An expanded form of interprocedural analysis New region formation framework and heuristics An interprocedural region encapsulation method
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.