Algorithms for Auto-tuning OpenACC Accelerated Kernels - - PowerPoint PPT Presentation

algorithms for auto tuning openacc accelerated kernels
SMART_READER_LITE
LIVE PREVIEW

Algorithms for Auto-tuning OpenACC Accelerated Kernels - - PowerPoint PPT Presentation

Outline Algorithms for Auto-tuning OpenACC Accelerated Kernels Fatemah Al-Zayer 1 , Ameerah Al-Mu2ry 1 , Mona Al-Shahrani 1, Saber Feki 2 , and David Keyes 1


slide-1
SLIDE 1

GPU Technology Conference 2016

Outline

Fatemah ¡Al-­‑Zayer1, ¡Ameerah ¡Al-­‑Mu2ry1, ¡Mona ¡Al-­‑Shahrani1, ¡ ¡Saber ¡Feki2, ¡and ¡David ¡Keyes1 ¡

¡ ¡

1Extreme ¡Compu,ng ¡Research ¡Center, ¡ 2KAUST ¡Supercompu,ng ¡Laboratory, ¡

King ¡Abdullah ¡University ¡of ¡Science ¡and ¡Technology ¡(KAUST), ¡Thuwal, ¡Saudi ¡Arabia ¡

Algorithms ¡for ¡Auto-­‑tuning ¡OpenACC ¡ Accelerated ¡Kernels ¡

GTC ¡2016 ¡– ¡San ¡Jose-­‑ ¡CA ¡– ¡April ¡6th ¡2016 ¡

slide-2
SLIDE 2

GPU Technology Conference 2016 2

Outline ¡

  • Mo,va,on ¡
  • Auto-­‑Tuning ¡Methodology ¡
  • Performance ¡Results ¡
  • Toward ¡a ¡Vector ¡Model ¡
  • Preliminary ¡Results ¡
  • Conclusion ¡and ¡Future ¡work ¡

¡ ¡

slide-3
SLIDE 3

GPU Technology Conference 2016 3

  • Tuning ¡loops ¡execu,ons ¡is ¡one ¡important ¡step ¡to ¡op,mize ¡the ¡

performance ¡of ¡your ¡OpenACC ¡accelerated ¡code. ¡

– Gang ¡(num_gangs) ¡and ¡Vector ¡(vector_length) ¡clauses ¡ – Tile ¡ – Collapse ¡

  • Manually ¡tuning ¡these ¡parameters ¡can ¡be ¡tedious ¡and ¡,me ¡
  • consuming. ¡

¡ ¡ ¡Auto-­‑Tuning ¡

Mo,va,on ¡

slide-4
SLIDE 4

GPU Technology Conference 2016 4

Tuning ¡Time ¡! ¡

  • Using ¡brute ¡force ¡search ¡is ¡very ¡,me ¡consuming ¡

Ø Historic ¡Learning ¡Approach ¡ Ø Using ¡faster ¡deriva,ve-­‑free ¡search ¡algorithms: ¡

– Random ¡Search ¡ – Simulated ¡Annealing ¡ – Gene,c ¡Algorithm ¡ – Nelder-­‑Mead ¡

Ø A ¡hybrid ¡solu,on ¡using ¡search ¡algorithms ¡combined ¡with ¡historic ¡

  • learning. ¡

4 ¡

slide-5
SLIDE 5

GPU Technology Conference 2016 5

Automa,c ¡Performance ¡Tuning ¡Method ¡

slide-6
SLIDE 6

GPU Technology Conference 2016 6

Seismic ¡Imaging ¡Kernel ¡

  • Solve ¡the ¡acous,c ¡wave ¡equa,on ¡(Isotropic ¡case) ¡
  • Finite ¡difference ¡scheme, ¡2nd ¡order ¡in ¡,me, ¡4th ¡or ¡8th ¡order ¡in ¡space ¡
slide-7
SLIDE 7

GPU Technology Conference 2016 7

Seismic ¡Imaging ¡Kernel ¡– ¡CPU ¡version ¡

slide-8
SLIDE 8

GPU Technology Conference 2016 8

Seismic ¡Imaging ¡Kernel: ¡OpenACC ¡Implementa,on ¡

slide-9
SLIDE 9

GPU Technology Conference 2016 9

Experimental ¡Results ¡

  • Seismic ¡kernel ¡solving ¡the ¡acous,c ¡wave ¡equa,on, ¡finite ¡

difference ¡scheme ¡8th ¡and ¡4th ¡order ¡in ¡space. ¡

  • Performance ¡reported ¡on ¡NVIDIA ¡K20 ¡and ¡K40 ¡GPUs. ¡
  • NVIDIA ¡recommends ¡the ¡vector ¡size ¡to ¡be ¡mul,ple ¡of ¡warp ¡size ¡

(32) ¡on ¡thus ¡we ¡explored ¡the ¡values ¡[32,64,96,…,1024] ¡ ¡

  • Gang ¡values ¡tested ¡on ¡increments ¡of ¡2 ¡star,ng ¡from ¡2 ¡up ¡,ll ¡

1024 ¡

  • Performance ¡and ¡tuning ¡,me ¡while ¡using ¡different ¡search ¡

algorithm ¡and ¡in ¡combina,on ¡with ¡historic ¡learning. ¡

slide-10
SLIDE 10

GPU Technology Conference 2016 10

K20 ¡-­‑ ¡8th ¡order ¡– ¡Speedup ¡ ¡

1.00 ¡ 1.20 ¡ 1.40 ¡ 1.60 ¡ 1.80 ¡ 2.00 ¡ 2.20 ¡ 2.40 ¡ 2.60 ¡ 2.80 ¡

Speedup ¡ Problem ¡Size ¡

Brute ¡Force ¡ Random ¡Walk ¡ Simulated ¡Annealing ¡ Nelder-­‑Mead ¡ Gene,c ¡Algorithm ¡1 ¡ Gene,c ¡Algorithm ¡2 ¡

slide-11
SLIDE 11

GPU Technology Conference 2016 11

K20 ¡-­‑ ¡8th ¡order ¡– ¡Tuning ¡,me ¡ ¡

0.1 ¡ 1 ¡ 10 ¡ 100 ¡ 1000 ¡ 10000 ¡

Time ¡(Sec) ¡ Problem ¡Size ¡

Brute ¡Force ¡ Random ¡Walk ¡ Simulated ¡Annealing ¡ Nelder-­‑Mead ¡ Gene,c ¡Algorithm ¡1 ¡ ¡ Gene,c ¡Algorithm ¡2 ¡

slide-12
SLIDE 12

GPU Technology Conference 2016 12

K20 ¡-­‑ ¡4th ¡order ¡– ¡Speedup ¡ ¡

1.00 ¡ 1.20 ¡ 1.40 ¡ 1.60 ¡ 1.80 ¡ 2.00 ¡ 2.20 ¡ 2.40 ¡ 2.60 ¡

Speedup ¡ Problem ¡Size ¡

Brute ¡Force ¡ Random ¡Walk ¡ Simulated ¡Annealing ¡ Nelder-­‑Mead ¡ Gene,c ¡Algorithm ¡1 ¡ Gene,c ¡Algorithm ¡2 ¡

slide-13
SLIDE 13

GPU Technology Conference 2016 13

K20 ¡-­‑ ¡4th ¡order ¡– ¡Tuning ¡,me ¡

0.1 ¡ 1 ¡ 10 ¡ 100 ¡ 1000 ¡ 10000 ¡

Time ¡(Sec) ¡ Problem ¡Size ¡

Brute ¡Force ¡ Random ¡Walk ¡ Simulated ¡Annealing ¡ Nelder-­‑Mead ¡ Gene,c ¡Algorithm ¡1 ¡ Gene,c ¡Algorithm ¡2 ¡

slide-14
SLIDE 14

GPU Technology Conference 2016 14

K40 ¡-­‑ ¡8th ¡order ¡– ¡Speedup ¡

1.00 ¡ 1.50 ¡ 2.00 ¡ 2.50 ¡ 3.00 ¡ 3.50 ¡ Speedup ¡ Problem ¡Size ¡ Brute ¡Force ¡ Random ¡Walk ¡ Simulated ¡Annealing ¡ Nelde-­‑Mead ¡ Gene,c ¡Algorithm ¡1 ¡ Gene,c ¡Algorithm ¡2 ¡

slide-15
SLIDE 15

GPU Technology Conference 2016 15

K40 ¡-­‑ ¡8th ¡order ¡– ¡Tuning ¡,me ¡

0.1 ¡ 1 ¡ 10 ¡ 100 ¡ 1000 ¡ 10000 ¡

Time ¡(Sec) ¡ Problem ¡Size ¡ Brute ¡Force ¡ Random ¡Walk ¡ Simulated ¡Annealing ¡ ¡ Nelder-­‑Mead ¡ Gene,c ¡Algorithm ¡1 ¡ Gene,c ¡Algoithm ¡2 ¡ ¡

slide-16
SLIDE 16

GPU Technology Conference 2016 16

K20 ¡-­‑ ¡8th ¡order ¡– ¡Speedup ¡with ¡historical ¡learning ¡

1.00 ¡ 1.20 ¡ 1.40 ¡ 1.60 ¡ 1.80 ¡ 2.00 ¡ 2.20 ¡ 2.40 ¡ 2.60 ¡ 2.80 ¡ 80x140x275 ¡ 1500x150x15 ¡ 120x83x402 ¡ 98x418x392 ¡ 288x288x288 ¡

Speedup ¡ Problem ¡Size ¡

Brute ¡Force ¡ Historic ¡Learning ¡and ¡Brute ¡Force ¡ Historic ¡Learning ¡and ¡Random ¡Walk ¡ Historic ¡Learning ¡and ¡Nelder-­‑Mead ¡ Historic ¡Learning ¡and ¡Gene,c ¡Algorithm ¡

slide-17
SLIDE 17

GPU Technology Conference 2016 17

0.1 ¡ 1 ¡ 10 ¡ 100 ¡ 1000 ¡ 10000 ¡ 80x140x275 ¡ 1500x150x15 ¡ 120x83x402 ¡ 98x418x392 ¡ 288x288x288 ¡

Time ¡(Sec) ¡ Problem ¡Size ¡

Brute ¡Force ¡ Historic ¡Learning ¡and ¡Brute ¡Force ¡ Historic ¡Learning ¡and ¡Random ¡Walk ¡ Historic ¡Learning ¡and ¡Nelder-­‑Mead ¡ Historic ¡Learning ¡and ¡Gene,c ¡Algorithm ¡

K20 ¡-­‑ ¡8th ¡order ¡– ¡Tuning ¡,me ¡historical ¡learning ¡ ¡

slide-18
SLIDE 18

GPU Technology Conference 2016 18

Model ¡for ¡gang ¡and ¡vector ¡? ¡

  • Can ¡we ¡provide ¡a ¡beier ¡model ¡to ¡the ¡compiler ¡to ¡use ¡for ¡selec,ng ¡

the ¡best ¡gang ¡and/or ¡vector ¡values ¡? ¡

  • For ¡a ¡given: ¡

– Three-­‑dimensional ¡problem ¡size ¡ – Applica,on: ¡e.g. ¡8th ¡order ¡vs ¡4th ¡order ¡ – GPU ¡Specifica,on: ¡K20 ¡(K40 ¡results: ¡work ¡in ¡progress) ¡ ¡

  • Correla2ons ¡between ¡the ¡problem ¡size ¡and ¡the ¡best ¡values ¡for ¡

gang ¡and ¡vector ¡parameters. ¡Which ¡dimensions? ¡

slide-19
SLIDE 19

GPU Technology Conference 2016 19

Vector ¡as ¡func,on ¡of ¡Z ¡dimension ¡

0 ¡ 200 ¡ 400 ¡ 600 ¡ 800 ¡ 1000 ¡ 1200 ¡ 30 ¡ 50 ¡ 80 ¡ 100 ¡ 128 ¡ 136 ¡ 167 ¡ 215 ¡ 256 ¡ 256 ¡ 275 ¡ 300 ¡ 300 ¡ 310 ¡ 392 ¡ 400 ¡ 402 ¡ 500 ¡ 545 ¡ 640 ¡ 678 ¡ 730 ¡ 753 ¡ 788 ¡ 807 ¡ 840 ¡ 870 ¡ 900 ¡ 915 ¡ 920 ¡ 1010 ¡ 1024 ¡ 1024 ¡

Best ¡Vector ¡Value ¡ Z ¡-­‑ ¡Dimension ¡

8th ¡order ¡on ¡K20 ¡

slide-20
SLIDE 20

GPU Technology Conference 2016 20

Vector ¡Models ¡as ¡func,on ¡of ¡Z ¡dimension ¡

0 ¡ 50 ¡ 100 ¡ 150 ¡ 200 ¡ 250 ¡ 300 ¡ 350 ¡ 400 ¡ 450 ¡ 30 ¡ 50 ¡ 80 ¡ 100 ¡ 128 ¡ 136 ¡ 167 ¡ 215 ¡ 256 ¡ 256 ¡ 275 ¡ 300 ¡ 300 ¡ 310 ¡ 392 ¡ 400 ¡ 402 ¡

Vector ¡Value ¡ Z ¡-­‑ ¡Dimension ¡

BF ¡Vector ¡ M1 ¡Vector ¡ M2 ¡Vector ¡ 0 ¡ 200 ¡ 400 ¡ 600 ¡ 800 ¡ 1000 ¡ 1200 ¡ 478 ¡ 510 ¡ 580 ¡ 640 ¡ 700 ¡ 740 ¡ 788 ¡ 830 ¡ 870 ¡ 900 ¡ 915 ¡ 920 ¡ 1010 ¡ 1024 ¡ 1024 ¡

Vector ¡Value ¡ Z ¡-­‑ ¡Dimension ¡ ¡

BF ¡Vector ¡ M3 ¡Vector ¡ M4 ¡Vector ¡

slide-21
SLIDE 21

GPU Technology Conference 2016 21

  • Best ¡value: ¡average ¡speedup ¡over ¡all ¡problem ¡sizes ¡using ¡(gAT,vAT) ¡

with ¡the ¡auto-­‑tuning ¡in ¡comparison ¡to ¡the ¡compiler ¡(gc,vc) ¡

  • We ¡report ¡the ¡average ¡speedup ¡while ¡using ¡the ¡model ¡value ¡for ¡

vector ¡and: ¡

– Computed ¡value ¡of ¡gang: ¡(gc*vc/vM, ¡vM) ¡ ¡ – Auto-­‑Tuned ¡value ¡of ¡gang: ¡(gAT,vM) ¡ ¡ – Compiler ¡value ¡of ¡gang: ¡(gc,vM) ¡ ¡ ¡

Performance ¡Speedup ¡(I) ¡

slide-22
SLIDE 22

GPU Technology Conference 2016 22

Performance ¡Speedup ¡(II) ¡

0.00% ¡ 5.00% ¡ 10.00% ¡ 15.00% ¡ 20.00% ¡ 25.00% ¡ 30.00% ¡ 35.00% ¡ 40.00% ¡ Auto-­‑Tuned ¡values ¡

  • f ¡gang ¡and ¡vector ¡

Computed ¡value ¡of ¡ gang ¡ Auto-­‑Tuned ¡value ¡

  • f ¡gang ¡

Compiler ¡value ¡of ¡ gang ¡

Model ¡1 ¡Performance ¡Speedup ¡

0.00% ¡ 5.00% ¡ 10.00% ¡ 15.00% ¡ 20.00% ¡ 25.00% ¡ 30.00% ¡ 35.00% ¡ 40.00% ¡ 45.00% ¡ 50.00% ¡ Auto-­‑Tuned ¡values ¡of ¡ gang ¡and ¡vector ¡ Computed ¡value ¡of ¡ gang ¡ Auto-­‑Tuned ¡value ¡of ¡ gang ¡ Compiler ¡value ¡of ¡ gang ¡

Model ¡3 ¡and ¡Model ¡4 ¡Performance ¡Speedup ¡

Model ¡3 ¡ Model4 ¡

Small/Medium ¡Z ¡dimension ¡ Larger ¡Z ¡dimension ¡

slide-23
SLIDE 23

GPU Technology Conference 2016 23

Performance ¡Speedup ¡(III) ¡

  • 4th ¡Order ¡Kernel ¡with ¡8th ¡order ¡Kernel ¡Model ¡1 ¡for ¡all ¡Z-­‑ ¡dimension ¡

values: ¡

0.00% ¡ 5.00% ¡ 10.00% ¡ 15.00% ¡ 20.00% ¡ 25.00% ¡ 30.00% ¡ 35.00% ¡ 40.00% ¡ 45.00% ¡ Auto-­‑Tuned ¡values ¡of ¡gang ¡and ¡ vector ¡ Auto-­‑Tuned ¡value ¡of ¡gang ¡ Compiler ¡value ¡of ¡gang ¡

Model ¡1 ¡ ¡Performance ¡Speedup ¡ ¡

slide-24
SLIDE 24

GPU Technology Conference 2016 24

Conclusions ¡

  • Auto-­‑tuning ¡gang ¡and ¡vector ¡parameters ¡using ¡different ¡

algorithms ¡results ¡in ¡a ¡performance ¡boost ¡of ¡the ¡OpenACC ¡ accelerated ¡kernels. ¡

  • A ¡hybrid ¡of ¡historic ¡learning ¡and ¡Nelder-­‑Mead ¡delivers ¡the ¡best ¡

balance ¡of ¡high ¡performance ¡and ¡low ¡tuning ¡effort. ¡

  • Suggested ¡a ¡“vector” ¡model ¡that ¡can ¡complement ¡the ¡gang ¡choice ¡
  • f ¡the ¡compiler ¡for ¡a ¡near ¡auto-­‑tuned ¡performance. ¡
slide-25
SLIDE 25

GPU Technology Conference 2016 25

Future ¡Work ¡

  • Validate ¡the ¡“vector” ¡model ¡with ¡different ¡OpenACC ¡kernels ¡and ¡

correlate ¡it ¡with ¡kernels ¡profile. ¡

  • Extrapola,on ¡of ¡the ¡“vector” ¡model ¡across ¡architectures ¡ ¡

– different ¡NVIDIA ¡GPUs ¡genera,ons ¡ – other ¡accelerators ¡ ¡

  • Targe,ng ¡other ¡parameters ¡in ¡OpenACC ¡2.5 ¡features ¡such ¡as ¡the ¡

,le ¡clause. ¡ ¡

slide-26
SLIDE 26

GPU Technology Conference 2016

Outline

Thank You! ¡ ¡ ¡ Saber.Feki@kaust.edu.sa ¡

Algorithms ¡for ¡Auto-­‑tuning ¡OpenACC ¡ Accelerated ¡Kernels ¡

GTC ¡2016 ¡– ¡San ¡Jose-­‑ ¡CA ¡– ¡April ¡6th ¡2016 ¡

slide-27
SLIDE 27

GPU Technology Conference 2016 27

Thanks !