240 likes | 254 Views
Dataflow Frequency Analysis based on Whole Program Paths. Eduard Mehofer Institute for Software Science University of Vienna mehofer@par.univie.ac.at www.par.univie.ac.at/~mehofer. Bernhard Scholz Institute of Computer Languages Vienna University of Technology
E N D
Dataflow Frequency Analysis based on Whole Program Paths Eduard Mehofer Institute for Software Science University of Vienna mehofer@par.univie.ac.at www.par.univie.ac.at/~mehofer Bernhard Scholz Institute of Computer Languages Vienna University of Technology scholz@complang.tuwien.ac.at www.complang.tuwien.ac.at/scholz
Dataflow Frequency Analysis • Goal • accurately computing frequencies of data flow facts • Problem: • high costs for computing accurate frequencies • requires whole program path • efficient data structures and algorithm? • Approach: • exploiting algebraic properties of bi-distributive DFA problems • employing WPPs to capture control flow • computing frequencies in a bottom-up style on the WPP graph
Outline • Motivation • WPP profiling • Properties of bi-distributive DFAs • Algorithm • Experiments • Conclusion
Classical Approach • Classical Program Optimization: optimizer data flow analysis Program Optimized program binaryinformation transformation • Drawback: heavily rarely never Optimizer
Program Profile Profiling Approach • Probabilistic Program Optimization: Optimizer based on profiling dataflow freq. analysis Optimized program frequencyinformation transformation • Advantage: heavily rarely never Optimizer
Running Example s 1 2 3 d1: x:=... d2: x:=... • CFG Example • simple code fragment • 8 times left branch • terminates via right branch • Reaching definitions problem • two definitions: d1, d2 • d1 kills d2 and vice versa • use of x at the end of loop • Questions • How often does d1 hold at node 5? • How often does d2 hold at node 5? 4 ...x... 5
WPP Profiling • Captures the whole program path • Larus at PLDI’99 • Path profiling techniques for acyclic paths • minimal insertion of instrumentation code • keeps executable fast • Sequitur for compression • builds a grammar • terminals are acyclic paths • nonterminals have only one production • graph representation of grammar • grammar has only sentence • best case: logarithmic size reduction
WPP Graph & Grammar S S a A A A b c s A bb A 1 a b c 2 3 4 • Terminals: • a: [s,1,2,4] • b: [1,2,4] • c: [1,3,4,5] 5 WPP Example • CFG Example • Program Run • 8x left branch • 1x right branch
Bi-Distributive Dataflow Problems • Properties • finite lattice 2D (power set of dataflow facts) • transition functions are monotone • transition functions distribute • representation relation • covers bit-vector problems • Due to properties • transition functions represented as 0/1-matrices • states represented as 0/1-vectors
Example 1 D M(24)r d1 {} 2 d2 {} d1: x:=... 4 {d1, } Representation Relation • Transition function f: 2D 2D • represented by f r : D 2D • artificial data fact
Example Matrix Representation • Matrix representation of function f
Dataflow Frequencies s v • Definition of dataflow frequencies for node v • r whole program path • prefix: set of all sub-paths from start node to node v • : converts data flow facts to 0/1-vector • state(): data flow facts which hold along path • sums up the occurrences of data flow facts which hold in v • Approach for fast computation • adopt definition for grammar symbols of SEQUITUR
Frequency matrices for eliminating sum • Computation of frequency matrices for grammar symbols Frequency Matrix • Definition of frequency matrices • sum computation due matrix calculus
Frequency matrix Terminals • Transitionfunction • compose function for acyclic path t:[u1, u2, ..., uk] • represent transition function as matrix
Frequency matrix Nonterminals • Transitionfunction • compose transition function for ntX1, X2, ..., Xk • represent transition function as matrix
1 2 d1: x:=... 4 • Nonterminal Abb Example • Terminal b: [1,2,4]
Algorithm • Pseudo-Code forallvNdo foralltTdo compute terminaltfor nodev endfor forallntNT in reverse topological orderdo compute nonterminal ntfor nodev endfor endfor
S S a b A A a b c a b c S S c A A a b c a b c Example • Transition matrices and frequency matrices for terminals
S A S A a b c S A a b c Example • Transition matrices and frequency matrices for nonterminals S A a b c Frequency matrix of start symbol S contains the dataflow frequency information!
Experiments • Gcc-Compiler 2.95.2 • data flow frequency analysis written in C++/C • implementation of WPP (runtime & compiletime) • Benchmark • some programs of SpecInt95 • reaching definitions problem • Environment • Sun Ultra Enterprise 450 (4 x 296 MhZ) with 2.5 GB
Node Statistics • about 40% of nodes are executed • no computations for 60% of nodes required
WPP Size & Overhead • Compile Overhead in % • WPP Size in Kbytes • Compile time overhead almost proportional to WPP size
Conclusion • Novel dataflow frequency analysis • designed for bi-distributive dataflow analysis problems • matrix representation of transition functions • employs SEQUITUR Grammars • Accurate and efficient algorithm • Experiments • platform: gcc for Ultra 450 • benchmark: reaching definitions problem for SpecInt95 • overhead is proportional to the size of WPP