220 likes | 471 Views
Machine Learning in Compiler Optimization. By Namita Dave. Overview. What are compiler optimizations? Challenges with optimizations Current Solutions Machine learning techniques Structure of Adaptive compilers. Introduction.
E N D
Machine Learning in Compiler Optimization By Namita Dave
Overview • What are compiler optimizations? • Challenges with optimizations • Current Solutions • Machine learning techniques • Structure of Adaptive compilers
Introduction • Optimization refers to process of modifying to achieve maximum efficiency in terms of storage, cost or time. • Machine learning techniques can be effectively used for optimizing based on specifics of program and target platform
Challenges • Inherently hard Problems • Interactions between optimizations
Inherently hard problems • Due to the interaction of compiler optimization with the hardware • Example – Register allocation
Interaction between optimizations • There can be positive or negative interactions • It depends in the order in which optimizations are applied • Positive Interaction Example • GCSE and Loop unrolling • Negative interaction example • Instruction scheduling and Register allocation
Instruction Scheduling vs Register Allocation z = x[i] tmp= x[i+1+n] Pre pass Post Pass
Current Solutions • Employ Heuristics • To decide whether to apply an optimization or not • Example – In lining decisions • Phase ordering • To decide the sequence of optimizations so as to minimize negative interactions
Problem? • Compiler Heuristics and Phase ordering is manual and predetermined • The solution needs to be dependent on specifics of program and the target platform
Solution Using machine learning techniques, a near optimal solution can be developed.
Heuristic selection • Machine learning techniques like supervised classification, function approximation and function selection can be employed for heuristic selection • Example • Supervised classification can be used to predict best unroll loop factor • Genetic programming can be used for learning priority functions
Automatic Phase Ordering • Unsupervised learning techniques can automate phase ordering • Based on the notion of similarity of programs • Offline training data can be used to identify a set of best phase orderings for similar programs • Based on feature vectors, similar programs can be found for a given new program