Predic've Modeling in a Polyhedral Op'miza'on Space - - PowerPoint PPT Presentation

predic ve modeling in a polyhedral op miza on space
SMART_READER_LITE
LIVE PREVIEW

Predic've Modeling in a Polyhedral Op'miza'on Space - - PowerPoint PPT Presentation

Predic've Modeling in a Polyhedral Op'miza'on Space Eunjung EJ Park 1 , Louis-Nol Pouchet 2 , John Cavazos 1 , Albert Cohen 3 , and P. Sadayappan 2


slide-1
SLIDE 1

Predic've ¡Modeling ¡ ¡ in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡

April ¡5th, ¡2011 ¡ IEEE/ACM ¡Symposium ¡on ¡Code ¡Genera'on ¡and ¡Op'miza'on ¡ Chamonix, ¡France ¡ Eunjung ¡“EJ” ¡Park1, ¡Louis-­‑Noël ¡Pouchet2, ¡John ¡Cavazos1, ¡ ¡ Albert ¡Cohen3, ¡and ¡P. ¡Sadayappan2 ¡

¡

1 ¡University ¡of ¡Delaware ¡ 2 ¡The ¡Ohio ¡State ¡University ¡ 3 ¡ALCHEMY ¡group, ¡INRIA ¡Saclay ¡-­‑ ¡Île-­‑de-­‑France ¡ ¡

slide-2
SLIDE 2

Do ¡you ¡want ¡good ¡performance? ¡

  • Op'mizing ¡loops ¡is ¡crucial! ¡
  • Difficulty ¡on ¡finding ¡good ¡loop ¡op'miza'ons ¡

– Complex ¡interplay ¡between ¡hardware ¡resources ¡ – Conflicts ¡between ¡op'miza'on ¡strategies ¡ – Large ¡compiler ¡op'miza'on ¡space ¡

  • Any ¡Solu'ons? ¡

– Using ¡itera've ¡compila'on ¡ – Using ¡polyhedral ¡framework ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 1 ¡

slide-3
SLIDE 3

Why ¡polyhedral ¡framework? ¡

  • Advantages ¡over ¡standard ¡compiler ¡framework ¡

– Good ¡expressiveness ¡ – Complex ¡op'miza'on ¡sequences ¡ – Loop ¡'ling ¡of ¡imperfectly ¡nested ¡loop ¡

  • Very ¡large ¡op'miza'on ¡space ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 2 ¡

Our ¡Solu?on ¡ Let’s ¡take ¡advantages ¡of ¡Polyhedral ¡Framework ¡and ¡ Itera?ve ¡Compila?on! ¡

slide-4
SLIDE 4

Contribu?ons ¡of ¡this ¡paper ¡

  • Power ¡of ¡three ¡approaches ¡

– Expressiveness ¡from ¡polyhedral ¡framework ¡ – Performance ¡predic'on ¡by ¡machine ¡learning ¡ – Itera've ¡compila'on ¡

  • Build ¡predic'on ¡model ¡for ¡polyhedral ¡op'miza'on ¡

primi'ves ¡

  • Reduce ¡number ¡of ¡evalua'ons, ¡achieve ¡good ¡

performance ¡ ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 3 ¡

slide-5
SLIDE 5

Polyhedral ¡Compiler ¡Framework ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 4 ¡

Extract ¡ Polyhedral ¡ Representa'on ¡ Build ¡Legal ¡ Transforma'ons ¡ Source ¡Code ¡ Genera'on ¡ Input ¡Program ¡ Transformed ¡Program ¡by ¡ Polyhedral ¡Op'miza'ons ¡ PoCC: ¡source-­‑to-­‑source ¡itera've ¡and ¡ ¡ model-­‑driven ¡polyhedral ¡compiler ¡

slide-6
SLIDE 6

Encode ¡in ¡fixed ¡length ¡vector ¡T ¡

Polyhedral ¡Op?miza?on ¡Space ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 5 ¡

Fusion/Distribu'on ¡ Compute ¡a ¡schedule ¡(Pluto) ¡ Modify ¡schedule ¡ Individually ¡Tile ¡Loops ¡ Process ¡all ¡other ¡op'miza'ons ¡

  • ­‑ ¡Fusion/Distribu'on/Code ¡Mo'on ¡
  • ­‑ ¡Auto ¡Paralleliza'on, ¡Tileability ¡
  • ­‑ ¡Vectoriza'on ¡
  • ­‑ ¡Tiling ¡
  • ­‑ ¡OpenMP ¡Pragma, ¡Unrolling ¡

Op'miza'ons ¡Handled ¡in ¡each ¡step ¡ Final ¡Search ¡ Space ¡ 864 ¡possible ¡ points ¡

slide-7
SLIDE 7

Finding ¡Best ¡Speedup ¡is ¡Hard ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 6 ¡

Low ¡density ¡of ¡best ¡points ¡in ¡actual ¡curve ¡

2 4 6 8 10 12 14 50 100 150 200 250 300 350

Performance Imp.

Actual 1 ¡

Op'miza'on ¡sequences ¡applied ¡(sorted ¡by ¡actual ¡speedup) ¡ Performance ¡Improvement ¡over ¡Baseline ¡

slide-8
SLIDE 8

Predic?on ¡Model ¡

  • Model ¡Descrip'on ¡
  • Building ¡Model ¡

– Model ¡Construc'on ¡ – Model ¡Usage ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 7 ¡

slide-9
SLIDE 9

Speedup ¡Predic?on ¡Model ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 8 ¡

Performance Counter Characteristics Optimizations

… …

Predicted speedup of optimizations

  • ver a baseline
slide-10
SLIDE 10

Building ¡Model ¡

  • Leave-­‑one-­‑out ¡cross ¡valida'on ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 9 ¡

for ¡i-­‑th ¡program ¡where ¡i=1 ¡to ¡N ¡ do ¡ ¡ ¡Train ¡a ¡model ¡on ¡N-­‑1 ¡programs ¡excluding ¡i-­‑th ¡program ¡ ¡Test ¡the ¡model ¡on ¡the ¡i-­‑th ¡program ¡lek ¡out ¡ ¡ done ¡

slide-11
SLIDE 11

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 10 ¡

1 ¡Program ¡ Backend ¡ Compiler ¡ Performance ¡Counters ¡ ¡ for ¡the ¡program ¡

  • Collect ¡dynamic ¡behavior ¡for ¡a ¡program ¡

ICC ¡ Underlying ¡Architecture ¡ … ¡ Performance ¡Counters ¡include ¡total ¡number ¡of ¡

  • ­‑

accesses ¡and ¡misses ¡in ¡all ¡levels ¡of ¡cache ¡and ¡TLB ¡

  • ­‑

stall ¡cycles ¡

  • ­‑

vector ¡instruc'ons ¡

  • ­‑

issued ¡instruc'ons ¡

Model ¡Construc?on ¡

slide-12
SLIDE 12
  • Now ¡do ¡this ¡for ¡N-­‑1 ¡programs ¡

Model ¡Construc?on ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 11 ¡

… ¡ N-­‑1 ¡Programs ¡ Backend ¡ Compiler ¡ Performance ¡Counters ¡ ¡ for ¡N-­‑1 ¡programs ¡ … ¡ … ¡ … ¡ ICC ¡ Underlying ¡Architecture ¡ … ¡

slide-13
SLIDE 13
  • Run ¡transformed ¡programs, ¡and ¡get ¡speedups ¡

Model ¡Construc?on ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 12 ¡

One ¡Program ¡ Backend ¡ Compiler ¡ Polyhedral ¡ Compiler ¡ Baseline ¡(-­‑fast) ¡ … ¡ … ¡ Primi've ¡sequences ¡and ¡ their ¡speedup ¡over ¡baseline ¡

Primi've ¡Sequences(T) ¡ Speedup ¡over ¡ baseline ¡

Transformed ¡Polyhedral ¡Programs ¡ ¡ for ¡the ¡one ¡Program ¡ ICC ¡ … ¡

slide-14
SLIDE 14
  • Now ¡do ¡this ¡for ¡N-­‑1 ¡programs ¡

Model ¡Construc?on ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 13 ¡

… ¡ N-­‑1 ¡Programs ¡ Backend ¡ Compiler ¡ Polyhedral ¡ Compiler ¡ … ¡ Transformed ¡Programs ¡ ¡ from ¡each ¡of ¡N-­‑1 ¡Programs ¡ … ¡ … ¡ Baseline ¡(-­‑fast) ¡ … ¡ … ¡ … ¡ … ¡ Primi've ¡sequences ¡and ¡ their ¡speedup ¡over ¡baseline ¡

Primi've ¡sequences ¡(T) ¡ Speedup ¡over ¡ baseline ¡

ICC ¡

slide-15
SLIDE 15

Model ¡Construc?on ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 14 ¡

… ¡ … ¡ Primi've ¡sequences ¡and ¡ their ¡speedup ¡over ¡baseline ¡ Performance ¡Counters ¡ ¡ for ¡a ¡program ¡ … ¡ Linear ¡Regression ¡/ ¡Support ¡Vector ¡Machine ¡(SVM) ¡

… …

Generated ¡model ¡ ¡ for ¡a ¡given ¡machine ¡

slide-16
SLIDE 16

Model ¡Construc?on ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 15 ¡

… ¡ … ¡ … ¡ … ¡ … ¡ … ¡ Performance ¡Counters ¡ ¡ for ¡N-­‑1 ¡programs ¡ … ¡ … ¡ … ¡ Linear ¡Regression ¡/ ¡Support ¡Vector ¡Machine ¡(SVM) ¡

… …

Primi've ¡sequences ¡and ¡their ¡speedup ¡

  • ver ¡baseline ¡for ¡N-­‑1 ¡programs ¡

Generated ¡model ¡ ¡ for ¡a ¡given ¡machine ¡

slide-17
SLIDE 17

Using ¡Model ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 16 ¡ … …

Backend ¡ Compiler ¡ Performance ¡ ¡ Counters ¡ ¡

… ¡ … ¡ … ¡

Nth ¡Program ¡ (one ¡lek ¡out) ¡ Primi've ¡Sequences ¡ Predicted ¡speedup ¡for ¡ each ¡sequences ¡ We ¡can ¡use ¡predicted ¡speedups ¡in ¡two ¡ways ¡

  • ­‑

Non-­‑itera've ¡Fashion ¡

  • ­‑

Itera've ¡Fashion ¡ ICC ¡-­‑fast ¡ Generated ¡model ¡ ¡ for ¡a ¡given ¡machine ¡

slide-18
SLIDE 18

Experimental ¡Configura?on ¡

  • Hardware ¡configura'on ¡

– Nehalem ¡

  • Intel ¡Xeon ¡E5620 ¡2.4GHz, ¡2 ¡sockets ¡4 ¡cores, ¡16 ¡H/W ¡threads, ¡L3 ¡12MB ¡

– R900/Dunnington ¡

  • Intel ¡Xeon ¡E7450 ¡2.4GHz, ¡4 ¡sockets ¡6 ¡cores, ¡24 ¡H/W ¡threads, ¡L3 ¡12MB ¡
  • Sokware ¡Configura'on ¡

– Backend ¡compiler: ¡ICC ¡ ¡ – Baseline: ¡ICC ¡with ¡–fast, ¡single ¡threaded ¡(no ¡auto-­‑par) ¡ – Machine ¡learning ¡framework: ¡Weka ¡v3.6.2 ¡

  • Linear ¡Regression/SVM ¡(SMOReg) ¡

– Benchmark: ¡PolyBench ¡2.0 ¡(28 ¡different ¡kernels ¡and ¡applica'ons) ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 17 ¡

slide-19
SLIDE 19

Experimental ¡Analysis ¡

  • Performance ¡of ¡our ¡model ¡
  • Our ¡model ¡versus ¡random ¡

¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 18 ¡

slide-20
SLIDE 20

Experiment ¡1: ¡Performance ¡of ¡our ¡model ¡

  • Shot ¡= ¡Evalua'ng ¡op'miza'on ¡sequence ¡
  • Non-­‑itera've ¡fashion ¡(1-­‑shot ¡model) ¡
  • Itera've ¡fashion ¡

– 2-­‑shot ¡model ¡ – 5-­‑shot ¡model ¡

¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 19 ¡

… …

Performance ¡ ¡ Counters ¡ ¡

… ¡

Primi've ¡Sequences ¡ Predicted ¡speedup ¡for ¡ each ¡sequences ¡

… ¡ … ¡

Primi've ¡Sequences ¡ Predicted ¡speedup ¡for ¡ each ¡sequences ¡

slide-21
SLIDE 21

Experiment ¡1: ¡Performance ¡of ¡our ¡model ¡

  • Shot ¡= ¡Evalua'ng ¡op'miza'on ¡sequence ¡
  • Non-­‑itera've ¡fashion ¡(1-­‑shot ¡model) ¡
  • Itera've ¡fashion ¡

– 2-­‑shot ¡model ¡ – 5-­‑shot ¡model ¡

¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 20 ¡

… ¡ … ¡

Sorted ¡by ¡Predicted ¡Speedup ¡ top1 ¡

slide-22
SLIDE 22

Experiment ¡1: ¡Performance ¡of ¡our ¡model ¡

  • Shot ¡= ¡Evalua'ng ¡op'miza'on ¡sequence ¡
  • Non-­‑itera've ¡fashion ¡(1-­‑shot ¡model) ¡
  • Itera've ¡fashion ¡

– 2-­‑shot ¡model ¡ – 5-­‑shot ¡model ¡

¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 21 ¡

… ¡ … ¡

Sorted ¡by ¡Predicted ¡Speedup ¡ top2 ¡

slide-23
SLIDE 23

Experiment ¡1: ¡Performance ¡of ¡our ¡model ¡

  • Shot ¡= ¡Evalua'ng ¡op'miza'on ¡sequence ¡
  • Non-­‑itera've ¡fashion ¡(1-­‑shot ¡model) ¡
  • Itera've ¡fashion ¡

– 2-­‑shot ¡model ¡ – 5-­‑shot ¡model ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 22 ¡

… ¡ … ¡

Sorted ¡by ¡Predicted ¡Speedup ¡ top5 ¡

slide-24
SLIDE 24

Experiment ¡1: ¡Performance ¡of ¡our ¡model ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 23 ¡

  • Summary ¡

– With ¡5 ¡itera'ons, ¡we ¡reached ¡more ¡than ¡80% ¡of ¡the ¡space ¡op'mal! ¡

  • Space ¡Best ¡vs. ¡Poly ¡vs. ¡ICC ¡

Nehalem ¡ LR ¡ SVM ¡ 3.16x ¡ 3.27x ¡ 3.16x ¡ 3.43x ¡ 1-­‑shot ¡ 2-­‑shot ¡ 3.50x ¡ 4.68x ¡ 5-­‑shot ¡ R900/Dunnington ¡ LR ¡ SVM ¡ 4.91x ¡ 3.77x ¡ 4.92x ¡ 4.91x ¡ 5.82x ¡ 6.60x ¡ SpaceBest ¡ Poly ¡ ICC ¡ Nehalem ¡ R900/Dunnington ¡ 6.10x ¡ 8.04x ¡ 2.13x ¡ 1.98x ¡ 4.48x ¡ 3.38x ¡

slide-25
SLIDE 25

Experiment ¡1: ¡Nehalem ¡1-­‑Shot ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 24 ¡ 0 ¡ 2.5 ¡ 5 ¡ 7.5 ¡ 10 ¡ 12.5 ¡ 15 ¡

Speedup ¡over ¡Baseline ¡ PolyBench ¡

Performance ¡Improvement ¡on ¡Nehalem ¡ (Baseline: ¡ICC ¡11.1 ¡-­‑fast) ¡

LR ¡ SVM ¡

21.54 ¡

Some ¡benchmarks ¡improve ¡performance ¡drama'cally ¡ 1/3 ¡of ¡benchmarks ¡decrease ¡performance! ¡ On ¡Average, ¡LR-­‑3.16x, ¡SVM-­‑3.27x ¡

1 ¡

slide-26
SLIDE 26

Experiment ¡1: ¡Nehalem ¡2-­‑Shot ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 25 ¡ 0 ¡ 2.5 ¡ 5 ¡ 7.5 ¡ 10 ¡ 12.5 ¡ 15 ¡

Speedup ¡over ¡Baseline ¡ PolyBench ¡

Performance ¡Improvement ¡on ¡Nehalem ¡ (Baseline: ¡ICC ¡11.1 ¡-­‑fast) ¡

LR ¡ SVM ¡

21.54 ¡

Not ¡a ¡big ¡difference ¡from ¡1-­‑shot ¡model, ¡ On ¡Average, ¡LR-­‑3.16x, ¡SVM-­‑3.43x ¡

1 ¡

slide-27
SLIDE 27

Experiment ¡1: ¡Nehalem ¡5-­‑shot ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 26 ¡ 0 ¡ 2.5 ¡ 5 ¡ 7.5 ¡ 10 ¡ 12.5 ¡ 15 ¡

Speedup ¡over ¡Baseline ¡ PolyBench ¡

Performance ¡Improvement ¡on ¡Nehalem ¡ (Baseline: ¡ICC ¡11.1 ¡-­‑fast) ¡

LR ¡ SVM ¡

21.54 ¡

3 ¡benchmarks ¡s'll ¡decrease ¡performance ¡in ¡5 ¡itera'ons. ¡ Most ¡benchmarks ¡take ¡benefit ¡of ¡using ¡our ¡model! ¡ ¡ ¡ ¡ ¡On ¡Average, ¡LR-­‑3.50x, ¡SVM-­‑4.68x ¡

1 ¡

slide-28
SLIDE 28
  • Random ¡search ¡discovers ¡performance ¡improvement ¡

¡

  • However, ¡our ¡model ¡performs ¡significantly ¡berer! ¡

¡

Nehalem ¡

Experiment ¡2: ¡Our ¡Model ¡vs. ¡random ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 27 ¡

Random ¡ 1.61x ¡ 2.24x ¡ 1-­‑shot ¡ 2-­‑shot ¡ 3.32x ¡ 5-­‑shot ¡ Our ¡Model ¡ 3.27x ¡ 3.43x ¡ 4.68x ¡ R900/Dunnington ¡ Random ¡ 2.14x ¡ 3.19x ¡ 3.99x ¡ Our ¡Model ¡ 4.91x ¡ 4.92x ¡ 6.60x ¡

slide-29
SLIDE 29

Conclusion ¡

  • Power ¡of ¡three ¡approaches ¡

– Expressiveness ¡from ¡polyhedral ¡framework ¡ – Performance ¡predic'on ¡by ¡machine ¡learning ¡ – Itera've ¡compila'on ¡

  • Build ¡predic'on ¡model ¡for ¡polyhedral ¡op'miza'on ¡primi'ves ¡
  • Reduce ¡number ¡of ¡evalua'ons, ¡achieve ¡good ¡performance ¡ ¡

– More ¡than ¡80% ¡of ¡search ¡space ¡op'mal ¡performance ¡in ¡5 ¡itera'ons ¡

  • Machine-­‑independent ¡algorithm ¡but ¡machine-­‑dependent ¡

result ¡(trained ¡specifically ¡on ¡the ¡target ¡machine) ¡

– Performance ¡portability ¡is ¡achieved ¡

4/7/11 ¡ Predic've ¡Modeling ¡in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡ 28 ¡

slide-30
SLIDE 30

Predic've ¡Modeling ¡ ¡ in ¡a ¡Polyhedral ¡Op'miza'on ¡Space ¡

Thank ¡You! ¡