mitigating the compiler optimization phase-ordering problem using machine learning

29
UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning Sameer Kulkarni John Cavazos

Upload: santo

Post on 16-Feb-2016

180 views

Category:

Documents


0 download

DESCRIPTION

Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning . Sameer Kulkarni John Cavazos. Introduction to Phase Ordering Present State-of-the-Art Proposed Solution Understand code Predict optimization An example Results Questions. What is Phase Ordering?. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

Mitigating the Compiler Optimization Phase-Ordering

Problem using Machine Learning

Sameer KulkarniJohn Cavazos

Page 2: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

• Introduction to Phase Ordering

• Present State-of-the-Art• Proposed Solution

• Understand code• Predict optimization

• An example• Results• Questions

Page 3: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

What is Phase Ordering? Change ordering of a given set

optimizationsOpt. 1

Opt. 2

Opt. 3

Opt. 4

Opt. 1

Opt. 3

Opt. 2

Opt. 4

Page 4: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

Why is it important? Plethora of optimizations to

choose. All interact with each other

Register Allocation & Instruction Scheduling

Loop Unrolling & CSE Branch Optimization & Static

Analysis

Page 5: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

• Introduction to Phase Ordering

• Present State-of-the-Art• Proposed Solution

• Understand code• Predict optimization

• An example• Results• Questions

Page 6: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

Present Solutions Developer’s intuition Using a static sequence using

search Pseudo Random Search (ML)

Hill Climbing, Genetic Algorithm

Page 7: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

Generation 1

Generation 2

Using Genetic Algorithms…

Page 8: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

Disadvantages of State-of-art One size fits all approach

Change in Compiler Change in Architecture Change in Code

Expensive Search

Page 9: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

A simple experiment Select a set of optimizations, and

set a sequence length Generate 500 random sequences Use each of the optimization

sequence to compile and run a set of benchmarks

Page 10: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

javac

mpega

udio jac

k

raytr

ace

jess

compr

ess

SOR

Serie

s

LUFac

tCry

pt

HeapS

ort

SpM

atmult

FFT

Avera

ge0.95

1

1.05

1.1

1.15

1.2

1.25Effects of static vs dynamic sequence

Best overall Sequence Best Sequence per benchmark

Spee

dup

norm

aliz

ed t

o O

3

SPECjvm 98 Grande

Page 11: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

• Introduction to Phase Ordering

• Present State-of-the-Art• Proposed Solution

• Understand code• Predict optimization

• An example• Results• Questions

Page 12: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

Proposed Solution

Analyze Code

Predict best

optimization

End optimizati

ons?

Apply Optimizati

on

Page 13: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

Static Source Code Features Method level

information Instruction

Mix conditionals memory ops size locals space

Page 14: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

Static Source Code Features Method level

information Instruction

Mix conditionals memory ops size locals space

Page 15: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

Proposed Solution

Analyze Code

Predict best

optimization

End optimizati

ons?

Apply Optimizati

on

Page 16: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

Neural Network

Page 17: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

Proposed Solution

Analyze Code

Predict best

optimization

End optimizatio

ns?

Apply Optimizatio

n

Page 18: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

Page 19: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

Neuro Evolution of Augmented Topologies Evolutionary approach to ANNs Starts with a minimally connected

network

Page 20: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

Generation 1 Generation nGeneration 2

Using NEAT…

Page 21: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

• Introduction to Phase Ordering

• Present State-of-the-Art• Proposed Solution

• Understand code• Predict optimization

• An example• Results• Questions

Page 22: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

scimark.lu bencmark

Generated by default O3

Generated by NEAT

Page 23: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

Advantages Source code agnostic

Customized optimization sequence Train once, use every-time

Elegant stopping criteria Optimization sequence length is not

static Saves time by intelligent selection

Page 24: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

• Introduction to Phase Ordering

• Present State-of-the-Art• Proposed Solution

• Understand code• Predict optimization

• An example• Results• Questions

Page 25: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

jess

jack

rayt

race

java

cco

mpr

ess

mpe

gaud

ioAv

g. S

PEC

jvm

98

fft(s

mal

l)m

onte

_car

lo sor lu

spar

seAv

g. S

PEC

jvm

2008

luin

dex

sunfl

owxa

lan

avro

ralu

sear

chpm

dAv

g. D

aCap

o

Aver

age

Aver

age

O3

SPECjvm 2008 DaCapo

10.012.014.016.018.020.022.024.0

Reduced Average Sequence LengthAv

erag

e Se

quen

ce L

engt

h

Page 26: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

Results on SpecJVM98Sp

eedu

p no

rmal

ized

ove

r O

3

Page 27: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

Results on SpecJVM2008Sp

eedu

p no

rmal

ized

ove

r O

3

Page 28: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

Results on DaCapoSp

eedu

p no

rmal

ized

ove

r O

3

Page 29: Mitigating the Compiler Optimization Phase-Ordering Problem using Machine Learning

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

Mitigating the Compiler Optimization Phase-Ordering

Problem using Machine Learning

Thank you!