![Page 1: Efficient Program Compilation through Machine Learning Techniques](https://reader035.vdocument.in/reader035/viewer/2022062310/56816271550346895dd2e123/html5/thumbnails/1.jpg)
Efficient Program Compilation through Machine Learning Techniques
Gennady PekhimenkoIBM Canada
Angela Demke BrownUniversity of Toronto
![Page 2: Efficient Program Compilation through Machine Learning Techniques](https://reader035.vdocument.in/reader035/viewer/2022062310/56816271550346895dd2e123/html5/thumbnails/2.jpg)
MotivationMy cool program
Compiler-O2
DCE
Peephole
Unroll
InlineExecutable
But what to do if executable is slow?Replace –O2 with –O5
UnrollUnroll
UnrollUnroll
UnrollUnroll
Optimization 100New
FastExecutable
1-10 minutes
few seconds
Unroll
Inline
Peephole
DCE
![Page 3: Efficient Program Compilation through Machine Learning Techniques](https://reader035.vdocument.in/reader035/viewer/2022062310/56816271550346895dd2e123/html5/thumbnails/3.jpg)
Motivation (2)
Compiler-O2
Our cool OperatingSystem
1 hourExecutable
Too slow!
Compiler-O5
20 hours
NewExecutable
We do not have that much time
Why did it happen?
![Page 4: Efficient Program Compilation through Machine Learning Techniques](https://reader035.vdocument.in/reader035/viewer/2022062310/56816271550346895dd2e123/html5/thumbnails/4.jpg)
Basic Idea
UnrollUnroll
UnrollOptimization 100
Do we need all these optimizations for every function?
Probably not.
Compiler writers can typically solve this problem, but how ?
1. Description of every function2. Classification based on the description3. Only certain optimizations for every class
Machine Learning is good for solving this kind of problems
![Page 5: Efficient Program Compilation through Machine Learning Techniques](https://reader035.vdocument.in/reader035/viewer/2022062310/56816271550346895dd2e123/html5/thumbnails/5.jpg)
Overview
Motivation System Overview Experiments and Results Related Work Conclusions Future Work
![Page 6: Efficient Program Compilation through Machine Learning Techniques](https://reader035.vdocument.in/reader035/viewer/2022062310/56816271550346895dd2e123/html5/thumbnails/6.jpg)
Initial Experiment
3X difference on average
![Page 7: Efficient Program Compilation through Machine Learning Techniques](https://reader035.vdocument.in/reader035/viewer/2022062310/56816271550346895dd2e123/html5/thumbnails/7.jpg)
Initial Experiment (2)
0100200300400500
bzip
2cr
afty
eon
gap
gzip
mcf
vort
ex vpr
amm
pap
plu
art
equa
kefa
cere
cfm
a3d
galg
ellu
cas
mes
am
grid
sixtr
ack
swim
wup
wise
Time, secs
Benchmarks
SPEC2000 execution time at –O3 and –qhot –O3
"-O3""-qhot -O3"
![Page 8: Efficient Program Compilation through Machine Learning Techniques](https://reader035.vdocument.in/reader035/viewer/2022062310/56816271550346895dd2e123/html5/thumbnails/8.jpg)
Classification parameters
Our SystemPrepare
• extract features• modify heuristic
values• choose
transformations • find hot methods
Gather Training Data
Compile Measure run time
LearnLogistic Regression Classifier
Best feature settingsOffline
Deploy
TPO/XL Compilerset heuristic values
Online
![Page 9: Efficient Program Compilation through Machine Learning Techniques](https://reader035.vdocument.in/reader035/viewer/2022062310/56816271550346895dd2e123/html5/thumbnails/9.jpg)
Data Preparation
Three key elements: Feature extraction Heuristic values modification Target set of transformations
• Total # of insts• Loop nest level• # and % of Loads, Stores,
Branches• Loop characteristics• Float and Integer # and %
• Existing XL compiler is missing functionality
• Extension was made to the existing Heuristic Context approach
• Unroll • Wandwaving• If-conversion• Unswitching• CSE• Index Splitting ….
![Page 10: Efficient Program Compilation through Machine Learning Techniques](https://reader035.vdocument.in/reader035/viewer/2022062310/56816271550346895dd2e123/html5/thumbnails/10.jpg)
Gather Training Data Try to “cut” transformation backwards (from
last to first)
If run time not worse than before, transformation can be skipped
Otherwise we keep it We do this for every hot function of every testThe main benefit is linear complexity.
Late Inlining Unroll Wandwaving
![Page 11: Efficient Program Compilation through Machine Learning Techniques](https://reader035.vdocument.in/reader035/viewer/2022062310/56816271550346895dd2e123/html5/thumbnails/11.jpg)
Learn with Logistic Regression
Function Descriptions
Best Heuristic Values
Input Classifier
• Logistic Regression• Neural Networks• Genetic
Programming
Output.hpredictfiles
Compiler +Heuristic Values
![Page 12: Efficient Program Compilation through Machine Learning Techniques](https://reader035.vdocument.in/reader035/viewer/2022062310/56816271550346895dd2e123/html5/thumbnails/12.jpg)
Deployment
Online phase, for every function: Calculate the feature vector Compute the prediction Use this prediction as heuristic context
Overhead is negligible
![Page 13: Efficient Program Compilation through Machine Learning Techniques](https://reader035.vdocument.in/reader035/viewer/2022062310/56816271550346895dd2e123/html5/thumbnails/13.jpg)
Overview
Motivation System Overview Experiments and Results Related Work Conclusions Future Work
![Page 14: Efficient Program Compilation through Machine Learning Techniques](https://reader035.vdocument.in/reader035/viewer/2022062310/56816271550346895dd2e123/html5/thumbnails/14.jpg)
Experiments
Benchmarks: SPEC2000 Others from IBM customers
Platform: IBM server, 4 x Power51.9 GHz, 32GB RAMRunning AIX 5.3
![Page 15: Efficient Program Compilation through Machine Learning Techniques](https://reader035.vdocument.in/reader035/viewer/2022062310/56816271550346895dd2e123/html5/thumbnails/15.jpg)
Results: compilation time
00.10.20.30.40.50.60.70.80.9
1bz
ip2
craft
yeo
nga
pgz
ipm
cfvo
rtex vp
ram
mp
appl
u art
equa
kefa
cere
cfm
a3d
galg
ellu
cas
mes
am
grid
sixtr
ack
swim
wup
wise
GeoM
ean
Normalized Time
Benchmarks
Oracle
Classifer
2x average speedup
![Page 16: Efficient Program Compilation through Machine Learning Techniques](https://reader035.vdocument.in/reader035/viewer/2022062310/56816271550346895dd2e123/html5/thumbnails/16.jpg)
Results: execution time
0
50
100
150
200
250
300
350bz
ip2
craft
yeo
nga
pgz
ipm
cfvo
rtex vp
ram
mp
appl
uar
teq
uake
face
rec
fma3
dga
lgel
luca
sm
esa
mgr
idsix
trac
ksw
imw
upw
ise
Time, secs
Benchmarks
BaselineOracleClassifer
![Page 17: Efficient Program Compilation through Machine Learning Techniques](https://reader035.vdocument.in/reader035/viewer/2022062310/56816271550346895dd2e123/html5/thumbnails/17.jpg)
New benchmarks: compilation time
00.20.40.60.8
1
Normalized Time
Benchmarks
Classifier
![Page 18: Efficient Program Compilation through Machine Learning Techniques](https://reader035.vdocument.in/reader035/viewer/2022062310/56816271550346895dd2e123/html5/thumbnails/18.jpg)
New benchmarks: execution time
0
50
100
150
200
250
300
350
apsi parser twolf dmo argonne
Time, secs
Benchmarks
Baseline
Classifer
4% speedup
![Page 19: Efficient Program Compilation through Machine Learning Techniques](https://reader035.vdocument.in/reader035/viewer/2022062310/56816271550346895dd2e123/html5/thumbnails/19.jpg)
Overview
Motivation System Overview Experiments and Results Related Work Conclusions Future Work
![Page 20: Efficient Program Compilation through Machine Learning Techniques](https://reader035.vdocument.in/reader035/viewer/2022062310/56816271550346895dd2e123/html5/thumbnails/20.jpg)
Related Work Iterative Compilation
Pan and Eigenmann Agakov, et al.
Single Heuristic Tuning Calder, et al. Stephenson, et al.
Multiple Heuristic Tuning Cavazos, et al. MILEPOST GCC
![Page 21: Efficient Program Compilation through Machine Learning Techniques](https://reader035.vdocument.in/reader035/viewer/2022062310/56816271550346895dd2e123/html5/thumbnails/21.jpg)
Conclusions and Future Work 2x average compile time decrease Future work
Execution time improvement -O5 level Performance Counters for better method
description Other benefits
Heuristic Context Infrastructure Bug Finding
![Page 22: Efficient Program Compilation through Machine Learning Techniques](https://reader035.vdocument.in/reader035/viewer/2022062310/56816271550346895dd2e123/html5/thumbnails/22.jpg)
Thank you
Raul Silvera, Arie Tal, Greg Steffan, Mathew Zaleski
Questions?