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

U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Mitigating the Compiler Optimization Phase- Ordering Problem using Machine Learning

Embed Size (px)

Citation preview

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

Mitigating the Compiler Optimization Phase-Ordering

Problem using Machine Learning

Sameer KulkarniJohn Cavazos

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

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

What is Phase Ordering?

Change ordering of a given set optimizationsOpt.

1Opt.

2Opt.

3Opt.

4

Opt. 1

Opt. 3

Opt. 2

Opt. 4

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

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

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

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

Generation 1

Generation 2

Using Genetic Algorithms…

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

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

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

java

c

mpe

gaud

io

jack

rayt

race

jess

com

pres

s SO

R

Serie

s

LUFac

t

Crypt

Hea

pSor

t

SpM

atm

ult

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

Sp

eed

up

norm

ali

zed

to O

3

SPECjvm 98 Grande

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

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

Proposed Solution

Analyze Code

Predict best

optimization

End optimizatio

ns?

Apply Optimizati

on

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

Static Source Code Features

Method level information

Instruction Mix

conditionals memory ops size locals space

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

Static Source Code Features

Method level information

Instruction Mix

conditionals memory ops size locals space

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

Proposed Solution

Analyze Code

Predict best

optimization

End optimizatio

ns?

Apply Optimizati

on

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

Neural Network

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

Proposed Solution

Analyze Code

Predict best optimizatio

n

End optimizatio

ns?

Apply Optimizatio

n

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

Neuro Evolution of Augmented Topologies

Evolutionary approach to ANNs Starts with a minimally connected

network

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

Generation 1 Generation nGeneration 2

Using NEAT…

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

UNIVERSITY OF DELAWARE • Computer & Information Sciences Department

scimark.lu bencmark

Generated by default O3

Generated by NEAT

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

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

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

jess

jack

rayt

race

java

cco

mpre

ssm

peg

au

dio

Avg

. S

PE

Cjv

m98

fft(

small

)m

on

te_c

arl

oso

r lusp

ars

eA

vg.

SP

EC

jvm

2008

luin

dex

sun

flow

xala

navr

ora

luse

arc

hpm

dA

vg.

DaC

apo

Ave

rage

Ave

rage

O3

SPECjvm 2008 DaCapo

10.0

12.0

14.0

16.0

18.0

20.0

22.0

24.0

Reduced Average Sequence Length

Ave

rag

e S

eq

uen

ce L

en

gth

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

Results on SpecJVM98S

peed

up

norm

ali

zed

ove

r O

3

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

Results on SpecJVM2008S

peed

up

norm

ali

zed

ove

r O

3

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

Results on DaCapoS

peed

up

norm

ali

zed

ove

r O

3

UNIVERSITY OF DELAWARE • COMPUTER & INFORMATION SCIENCES DEPARTMENT

Mitigating the Compiler Optimization Phase-Ordering

Problem using Machine Learning

Thank you!