180 likes | 305 Views
Statistical Selection of Compiler Options. R.P.J. Pinkers P.M.W. Knijnenburg M. Haneda H.A.G. Wijshoff. Motivation. Modern compilers contain dozens of options. Options can positively or negatively interfere.
E N D
Statistical Selectionof Compiler Options R.P.J. Pinkers P.M.W. Knijnenburg M. Haneda H.A.G. Wijshoff
Motivation • 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
Orthogonal Arrays • If there are N options or factors, the full optimization space contains 2N combinations. • This space is called afull 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.
Definition 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
Orthogonal 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
Main 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.
Relative 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
Improvement 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
Iterative 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
Experimental Setup • SimpleScalar simulator with GCC 2.6.3. • Contains 19 options divided in 14 factors • 6 SPEC95 benchmarks.
Conclusions • 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.