Title: Statistical Selection of Compiler Options
1Statistical Selectionof Compiler Options
- R.P.J. Pinkers
- P.M.W. Knijnenburg
- M. Haneda
- H.A.G. Wijshoff
2Motivation
- Modern compilers contain dozens of options.
- Options can positively or negatively interfere.
- Optimal setting of those options depends on
application as well as target architecture. - Standard Ox settings produce sub-optimal
results. - We propose almost automatic iterative procedure
to select options for a given application and
architecture based on statistical analysis
3Fragment Optimization Space gcc
4Fragment Optimization Space ijpeg
5Orthogonal Arrays
- If there are N options or factors, the full
optimization space contains 2N combinations. - This space is called a full factorial design.
- A fractional factorial design is a subset of the
full factorial design. - An Orthogonal Array (OA) or Taguchi design is a
well-known approach to fractional factorial
designs. - An OA allows us to determine the effect of a
factor in the presence of other factors using a
reduced space.
6Definition of Orthogonal Arrays
- OA is N x k matrix of zeroes and ones.
- The columns are interpreted as options.
- Each row defines a compiler setting.
- An OA has the property that two arbitrary columns
contain the patterns - equally often.
- Each option Oi is turned on and off equally
often. - If Oi is turned on, then each other option Oj is
turned on and off equally often.
00 01 10 11
7Orthogonal Array (Example)
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0
1 0 1 0 1 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0 1
1 0 0 1 1 0 0 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
1 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1 1 1 1 0 0 0 0 1
1 1 1 0 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 0 0 0 0
0 0 1 1 1 1 1 1 1 1 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0
0 1 1 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 0 0
1 1 0 0 1 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 1 0 1 1 0
1 0 1 0 1 0 0 1 0 1 0 1 1 1 1 0 0 1 1 0 0 0 0 1 1
1 1 0 1 0 0 1 1 0 0 1 0 1 1 0
8Main Effects of Options
- An OA allows us to calculate the main effect of
options. - The main effect of an option Oi wrt an OA A is
defined as -
-
-
- where s denotes a row in A and T(s) denotes the
execution time of the program when compiles with
setting s.
9Relative Effects
- Execution times are given in cycles or seconds.
- Effects of options for different benchmarks
cannot be compared easily. - We define relative effect of an option Oi as
10Improvement of Options
- An option can improve or degrade performance.
- The main effect is always positive and does not
distinguish between improvement or degradation. - We define the improvement of an option Oi wrt an
OA A as
11Iterative Algorithm
- Repeat
- Compile application with each row from A as
compiler setting and execute optimized
application. - Compute effect of each option.
- If effect is larger than threshold of 10
- if option has positive improvement, switch option
on - else switch option off.
- Construct new OA A by dropping columns
corresponding to selected options. - until all options are set
12Experimental Setup
- SimpleScalar simulator with GCC 2.6.3.
- Contains 19 options divided in 14 factors
- 6 SPEC95 benchmarks.
O1 unroll-loops, strength-reduce, rerun-cse-after-loop
O2 fast-math
O3 schedule-insns, schedule-insns2
O4 inline, inline-functions
O5 cse-follow-jumps, cse-skip-blocks
O6 float-store
O7 Defer-pop
O8 Force-mem
O9 Force-addr
O10 Omit-frame-pointer
O11 Thread-jumps
O12 Expensive-optimizations
O13 Caller-saves
O14 peephole
13Iteration 1 for gcc
14Iteration 2 for gcc
15Iteration 3 for gcc
16Comparison with Standard Settings
17Conclusions
- We have proposed a method based on statistical
analysis of the effect of options using
Orthogonal Arrays. - Method uses (almost) no knowledge of compiler.
- Can be implemented as a simple driver on top of
any compiler. - Significant improvement can be obtained by
automatically tuning compiler options over
standard optimization settings.