Docsity

Profile Directed Compilation - Compiler Optimisation - Lecture Slides, Slides of Computer Science

Partial preview of the text

Download Profile Directed Compilation - Compiler Optimisation - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

Adaptive and Profile Directed Compilation

Michael O’BoyleMarch, 2011

M. O’Boyle

Adaptive and Profile Directed Compilation

Overview

-^ Why we fail to fully optimise •^ How to overcome this •^ Profile Directed Compilation •^ Iterative Compilation •^ Critical evaluation and conclusion M. O’Boyle^

Adaptive and Profile Directed Compilation

Profile directed compilation

-^ Direct addresses problem of compile time unknown data •^ Key(simple) idea: run program once and collect some useful information •^ Use this runtime information to better improve program performance •^ In effect move the first runtime into the compile time phase •^ Makes sense if gathering the profile data is cheap and user willing to pay for 2compiles. Can still use after first compile. •^ Allows specialisation to runtime data - pros and cons? M. O’Boyle^

Adaptive and Profile Directed Compilation

PDC schematic Compiler^

executable

program

data^0 results

Compiler^

data executable

profile

results

0

1 1

Profile information is an additional output.Data can change from run to run. Executable still correct. M. O’Boyle

Adaptive and Profile Directed Compilation

March, 2011

PDC Example 1

Sequence of basic blocksFrequency of execution on edges andnodesPrimarily ABEFOther entry/exit control-flowprevents mergingSuper-block - frequently executed pathMerge and tidy-upOptimise larger unit

D^

E F

C A 100

10 B (^9090100) 0

10 10 (^90090900) 1 99

M. O’Boyle

Adaptive and Profile Directed Compilation

PDC Example 2

Selecting the traceStart at most frequent blockAdd blocks on most frequent successorsRepeat on other nodesDone in both control-flow directionsDo on remaining nodes

D^

E F

C A 100

10 B 90 90 0

10 10 (^90090900) 1 99

F 100

M. O’Boyle

Adaptive and Profile Directed Compilation

Beyond Path profiling

-^ Although useful, the performance gains are modest •^ Challenge of undecidability and processor behaviour not addressed. •^ What happens if data changes on the second run?? •^ Really focuses on persistent control-flow behaviour •^ All other information eg runtime values, memory locations accessed ignored •^ Can we get more out of knowing data and its impact on program behaviour? M. O’Boyle^

Adaptive and Profile Directed Compilation

Evolution of PDC

PDC one compile

Compiler^

executable

program

data^0 results

Compiler^

data executable

profile

results

Iterative: multiple compiles

Compiler^

executable

program

data^0 results

profile 0

M. O’Boyle

Adaptive and Profile Directed Compilation

UltraSparc: space within 20% of minimum

N^ = 400

10 20 30

Tile Size Unroll Minimum at: Unroll = 3 and Tile size = 57.Near minimum: 2.6%. Original 4.99 secs, Minimum 0.56 secs M. O’Boyle

Adaptive and Profile Directed Compilation

UltraSparc

N^ = 400 0 20 40

Number of Evaluations Within % of minimium 50 steps: within 0.0%. Initially 2.65 times slower than minimum M. O’Boyle

Adaptive and Profile Directed Compilation

Alpha^ N

= 512 0 20 40

Number of Evaluations Within % of minimium 50 steps: within 21.9%.Originally 5.25 times slower than minimum M. O’Boyle

Adaptive and Profile Directed Compilation

Pentium Pro: space within 20% of minimum

N^ = 400

10 20 30

Tile Size Unroll Minimum at: Unroll = 19 and Tile size = 57.Near minimum: 4.3%. Original 4.88 Minimum 1.43 M. O’Boyle

Adaptive and Profile Directed Compilation

R10000:

N^ = 512 10 20 30

Tile Size Unroll Minimum at: Unroll = 4 and Tile size = 85.Near minimum: 7.2%. Original 2.79, Minimum 1.09 M. O’Boyle

Adaptive and Profile Directed Compilation

R

N^ = 512 0 20 40

Number of Evaluations Within % of minimium 50 steps: within 4.9%. M. O’Boyle

Adaptive and Profile Directed Compilation