Title: Dataflow Frequency Analysis based on Whole Program Paths
1Dataflow Frequency Analysis based on Whole
Program Paths
Eduard Mehofer Institute for Software
Science University of Vienna mehofer_at_par.univie.a
c.at www.par.univie.ac.at/mehofer
Bernhard Scholz Institute of Computer
Languages Vienna University of Technology scholz_at_
complang.tuwien.ac.at www.complang.tuwien.ac.at/sc
holz
2Dataflow 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
3Outline
- Motivation
- WPP profiling
- Properties of bi-distributive DFAs
- Algorithm
- Experiments
- Conclusion
4Classical Approach
- Classical Program Optimization
optimizer
data flow analysis
Program
Optimized program
binary information
transformation
heavily rarely never
Optimizer
5Profiling Approach
- Probabilistic Program Optimization
Optimizer based on profiling
dataflow freq. analysis
Optimized program
frequency information
transformation
heavily rarely never
Optimizer
6Running Example
- 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?
s
1
3
2
d1 x...
d2 x...
4
...x...
5
7WPP Profiling
- Captures the whole program path
- Larus at PLDI99
- 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
8WPP Example
- Program Run
- 8x left branch
- 1x right branch
9Bi-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
10Representation Relation
- Transition function f 2D? 2D
- represented by f r D ? 2D
- artificial data fact ?
11Matrix Representation
- Matrix representation of function f
12Dataflow Frequencies
- 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
s
v
13Frequency Matrix
- Definition of frequency matrices
- sum computation due matrix calculus
14Terminals
- Transition function
- compose function for acyclic path tu1, u2,
..., uk - represent transition function as matrix
15Nonterminals
- Transition function
- compose transition function for nt?X1, X2, ...,
Xk - represent transition function as matrix
16Example
17Algorithm
- forall v?N do
- forall t?T do
- compute terminal t for node v
- endfor
- forall nt?NT in reverse topological order do
- compute nonterminal nt for node v
- endfor
-
- endfor
18Example
- Transition matrices and frequency matrices for
terminals
19Example
- Transition matrices and frequency matrices for
nonterminals
S
A
a
b
c
Frequency matrix of start symbol S contains the
dataflow frequency information!
20Experiments
- 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
21Node Statistics
- about 40 of nodes are executed
- no computations for 60 of nodes required
22WPP Size Overhead
- Compile time overhead almost proportional to WPP
size
23Conclusion
- 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
24Stop!