Meta Optimization - PowerPoint PPT Presentation

About This Presentation
Title:

Meta Optimization

Description:

Case Study I: IMPACT's Function. Favor frequently ... IMPACT uses four characteristics ... Proof of concept' by evolving three well known priority functions ... – PowerPoint PPT presentation

Number of Views:25
Avg rating:3.0/5.0
Slides: 35
Provided by: mst83
Category:

less

Transcript and Presenter's Notes

Title: Meta Optimization


1
Meta Optimization
  • Improving Compiler Heuristics with Machine
    Learning

Mark Stephenson, Una-May OReilly, Martin Martin,
and Saman Amarasinghe MIT Computer Architecture
Group
Presented by Utku Aydonat
2
Motivation
  • Compiler writers are faced with many challenges
  • Many compiler problems are NP-hard
  • Modern architectures are inextricably complex
  • Simple models cant capture architecture
    intricacies
  • Micro-architectures change quickly

3
Motivation
  • Heuristics alleviate complexity woes
  • Find good approximate solutions for a large class
    of applications
  • Find solutions quickly
  • Unfortunately
  • They require a lot of trial-and-error tweaking to
    achieve suitable performance
  • Fine tuning is a tedious process

4
Priority Functions
  • A single priority or cost function often dictates
    the efficacy of a heuristic
  • Priority Function A function of the factors that
    affect a given problem
  • Priority functions rank the options available to
    a compiler heuristic

5
Priority Functions
  • Graph coloring register allocation (selecting
    nodes to spill)
  • List scheduling (identifying instructions in
    worklist to schedule first)
  • Hyperblock formation (selecting paths to include)
  • Data Prefetching (inserting prefetch
    instructions)

6
List Scheduling
7
Machine Learning
  • They propose using machine learning techniques to
    automatically search the priority function space
  • Feedback directed optimization
  • Find a function that works well for a broad range
    of applications
  • Needs to be applied only once

8
Generic Programming
  • Modeled after Darwinism (Survival of the
    Fittest).
  • Parse trees of operators and operands describe
    the potential priority functions.
  • A population is a collection of parse trees for
    one generation.
  • After testing, several members of the population
    are selected for reproduction via crossover,
    which swaps a random node from each of 2 parse
    trees.
  • Other parse trees are selected for mutation, in
    which a random node is replaced by a random
    expression.

9
Generic Programming
10
Genetic Programming
Create initial population (initial solutions)
Evaluation
Generation of variants (mutation and crossover)
Selection
Generations lt Limit?
END
11
Generic Programming
  • The system selects the smaller of several
    expressions that are equally fit so that the
    parse trees do not grow exponentially.
  • Tournament selection is used repeatedly to select
    parse trees for crossover.
  • Choose N expressions at random from the
    population and select the one with the highest
    fitness.
  • Dynamic subset selection (DSS) is used to reduce
    fitness evaluations to achieve suitable solution.

12
Meta Optimization
  • Just as with Natural Selection, the fittest
    individuals are more likely to survive and
    reproduce.
  • Expressions creating fastest code are the
    fittest.
  • Create 399 random expressions based on
    parameters.
  • It also seeded with the compiler writers best
    guesses

13
Meta Optimization
14
Case Study I Hyperblock Formation
  • Find predictable regions of control flow
  • Prioritize paths based on several characteristics
  • The priority function we want to optimize
  • Add paths to hyperblock in priority order

15
Hyperblock Formation
16
Case Study I IMPACTs Function
17
Hyperblock Formation
  • What are the important characteristic of a
    hyperblock formation priority function?
  • IMPACT uses four characteristics
  • Extract all the characteristics you can think of
    and have a machine learning algorithm find the
    priority function

18
Hyperblock Formation
x1 Maximum ops over paths x2 Dependence height
x3 Number of paths x4 Number of operations
x5 Does path have subroutine calls? x6 Number of branches
x7 Does path have unsafe calls? x8 Path execution ratio
x9 Does path have pointer derefs? x10 Average ops executed in path
x11 Issue width of processor x12 Average predictability of branches in path
xN Predictability product of branches in path
19
Hyperblock ResultsCompiler Specialization
3.5
Train data set
Alternate data set
3
2.5
2
Speedup
1.5
1.54
1.23
1
0.5
0
toast
Average
huff_enc
huff_dec
mpeg2dec
rawcaudio
rawdaudio
g721encode
g721decode
129.compress
20
Hyperblock ResultsA General Purpose Priority
Function
21
Cross ValidationTesting General Purpose
Applicability
22
Case Study II Register AllocationA General
Purpose Priority Function
23
Register Allocation ResultsCross Validation
24
Case Study III PrefetchingA General Purpose
Priority Function
25
Prefecthing ResultsCross Validation
26
Conclusion
  • Machine learning techniques can identify
    effective priority functions
  • Proof of concept by evolving three well known
    priority functions
  • Human cycles v. computer cycles

27
My Conclusions
  • Heuristics to improve heuristics
  • How to choose population size, mutation rate,
    tournament size?
  • Does it guarantee better results?
  • Requires a lot of experiments for the results to
    converge.
  • Do we have that opportunity?
  • It is very effective for optimizing a specific
    application space.

28
  • Thank you!

29
GP Hyperblock SolutionsGeneral Purpose
  • (add
  • (sub (mul exec_ratio_mean 0.8720) 0.9400)
  • (mul 0.4762
  • (cmul (not has_pointer_deref)
  • (mul 0.6727 num_paths)
  • (mul 1.1609
  • (add (sub
  • (mul (div num_ops dependence_height)
    10.8240)
  • exec_ratio)
  • (sub (mul (cmul has_unsafe_jsr
    predict_product_mean 0.9838)
  • (sub 1.1039 num_ops_max))
  • (sub (mul dependence_height_mean
    num_branches_max) num_paths)))))))

Intron that doesnt affect solution
30
GP Hyperblock SolutionsGeneral Purpose
  • (add
  • (sub (mul exec_ratio_mean 0.8720) 0.9400)
  • (mul 0.4762
  • (cmul (not has_pointer_deref)
  • (mul 0.6727 num_paths)
  • (mul 1.1609
  • (add (sub
  • (mul (div num_ops dependence_height)
    10.8240)
  • exec_ratio)
  • (sub (mul (cmul has_unsafe_jsr
    predict_product_mean 0.9838)
  • (sub 1.1039 num_ops_max))
  • (sub (mul dependence_height_mean
    num_branches_max) num_paths)))))))

Favor paths that dont have pointer dereferences
31
GP Hyperblock SolutionsGeneral Purpose
  • (add
  • (sub (mul exec_ratio_mean 0.8720) 0.9400)
  • (mul 0.4762
  • (cmul (not has_pointer_deref)
  • (mul 0.6727 num_paths)
  • (mul 1.1609
  • (add (sub
  • (mul (div num_ops dependence_height)
    10.8240)
  • exec_ratio)
  • (sub (mul (cmul has_unsafe_jsr
    predict_product_mean 0.9838)
  • (sub 1.1039 num_ops_max))
  • (sub (mul dependence_height_mean
    num_branches_max) num_paths)))))))

32
GP Hyperblock SolutionsGeneral Purpose
  • (add
  • (sub (mul exec_ratio_mean 0.8720) 0.9400)
  • (mul 0.4762
  • (cmul (not has_pointer_deref)
  • (mul 0.6727 num_paths)
  • (mul 1.1609
  • (add (sub
  • (mul (div num_ops dependence_height)
    10.8240)
  • exec_ratio)
  • (sub (mul (cmul has_unsafe_jsr
    predict_product_mean 0.9838)
  • (sub 1.1039 num_ops_max))
  • (sub (mul dependence_height_mean
    num_branches_max) num_paths)))))))

If a path calls a subroutine that may have side
effects, penalize it
33
Case Study I IMPACTs Algorithm
A
4k
24k
Path exec haz ops dep pr
A-B-D-F-G 0 1.0 13 4 0
A-B-F-G 0.14 1.0 10 4 0.21
A-C-F-G 0.79 1.0 9 2 1.44
A-C-E-F-G 0.07 0.25 13 5 0.02
A-C-E-G 0 0.25 11 3 0
B
C
4k
22k
2k
10
E
D
2k
25
10
F
28k
G
28k
34
Case Study I IMPACTs Algorithm
A
4k
24k
Path exec haz ops dep pr
A-B-D-F-G 0 1.0 13 4 0
A-B-F-G 0.14 1.0 10 4 0.21
A-C-F-G 0.79 1.0 9 2 1.44
A-C-E-F-G 0.07 0.25 13 5 0.02
A-C-E-G 0 0.25 11 3 0
B
C
4k
22k
2k
10
E
D
2k
25
10
F
28k
G
28k
Write a Comment
User Comments (0)
About PowerShow.com