Track Reconstruc.on on GPUs MOHAMMAD AL-TURANY GSI Darmstadt - - PowerPoint PPT Presentation

track reconstruc on on gpus
SMART_READER_LITE
LIVE PREVIEW

Track Reconstruc.on on GPUs MOHAMMAD AL-TURANY GSI Darmstadt - - PowerPoint PPT Presentation

Track Reconstruc.on on GPUs MOHAMMAD AL-TURANY GSI Darmstadt Friday, March 26, 2010 Outline 2 26.03.2010 Mohammad Al-Turany, Hades Meeting Friday, March 26, 2010 Outline 2 Few words about GPU


slide-1
SLIDE 1

MOHAMMAD ¡AL-­‑TURANY GSI ¡Darmstadt

Track ¡Reconstruc.on ¡on ¡GPUs

Friday, March 26, 2010

slide-2
SLIDE 2

26.03.2010

Mohammad Al-Turany, Hades Meeting

Outline

2

Friday, March 26, 2010

slide-3
SLIDE 3

26.03.2010

Mohammad Al-Turany, Hades Meeting

Outline

 Few ¡words ¡about ¡GPU ¡vs ¡CPU  CUDA ¡vs ¡GPGPU  Why ¡CUDA?  ¡Runge-­‑KuIa ¡Track ¡propagaMon ¡ ¡ ¡

 HADES ¡

 Track ¡and ¡vertex ¡fiQng ¡(PANDA) ¡

  • ¡ ¡Summary

2

Friday, March 26, 2010

slide-4
SLIDE 4

26.03.2010

Mohammad Al-Turany, Hades Meeting

CPU GPU

CPU ¡vs. ¡GPU

3

Friday, March 26, 2010

slide-5
SLIDE 5

26.03.2010

Mohammad Al-Turany, Hades Meeting

CPU GPU

 CPU ¡ ¡is ¡designed ¡to ¡execute ¡one ¡

stream ¡of ¡instrucMons ¡as ¡fast ¡as ¡

  • possible. ¡

 GPU ¡is ¡designed ¡to ¡execute ¡

many ¡parallel ¡streams ¡of ¡ instrucMons ¡as ¡fast ¡as ¡possible.

CPU ¡vs. ¡GPU

3

Friday, March 26, 2010

slide-6
SLIDE 6

26.03.2010

Mohammad Al-Turany, Hades Meeting

CPU GPU

 CPU ¡ ¡is ¡designed ¡to ¡execute ¡one ¡

stream ¡of ¡instrucMons ¡as ¡fast ¡as ¡

  • possible. ¡

 The ¡CPU ¡spends ¡transistors ¡on ¡

hardware ¡features ¡like ¡ instrucMon ¡reorder ¡buffers, ¡ reservaMon ¡staMons, ¡branch ¡ predicMon ¡hardware, ¡and ¡large ¡

  • n-­‑die ¡cache. ¡

 GPU ¡is ¡designed ¡to ¡execute ¡

many ¡parallel ¡streams ¡of ¡ instrucMons ¡as ¡fast ¡as ¡possible.

 The ¡GPU ¡spends ¡transistors ¡in ¡

processor ¡arrays, ¡mulMthreading ¡ hardware, ¡shared ¡memory, ¡and ¡ mulMple ¡memory ¡controllers.

CPU ¡vs. ¡GPU

3

Friday, March 26, 2010

slide-7
SLIDE 7

26.03.2010

Mohammad Al-Turany, Hades Meeting

CPU GPU

CPU ¡vs. ¡GPU

4

Friday, March 26, 2010

slide-8
SLIDE 8

26.03.2010

Mohammad Al-Turany, Hades Meeting

CPU GPU

 The ¡CPU ¡uses ¡cache ¡to ¡

improve ¡performance ¡by ¡ reducing ¡the ¡latency ¡of ¡ memory ¡accesses. ¡

 The ¡GPU ¡uses ¡cache ¡(or ¡

soXware-­‑managed ¡shared ¡ memory) ¡to ¡amplify ¡ bandwidth.

CPU ¡vs. ¡GPU

4

Friday, March 26, 2010

slide-9
SLIDE 9

26.03.2010

Mohammad Al-Turany, Hades Meeting

CPU GPU

 The ¡CPU ¡uses ¡cache ¡to ¡

improve ¡performance ¡by ¡ reducing ¡the ¡latency ¡of ¡ memory ¡accesses. ¡

 CPUs ¡support ¡one ¡or ¡two ¡

threads ¡per ¡core. ¡

 The ¡GPU ¡uses ¡cache ¡(or ¡

soXware-­‑managed ¡shared ¡ memory) ¡to ¡amplify ¡ bandwidth.

 CUDA ¡capable ¡GPUs ¡

support ¡up ¡to ¡1024 ¡ threads ¡per ¡streaming ¡

  • mulMprocessor. ¡

CPU ¡vs. ¡GPU

4

Friday, March 26, 2010

slide-10
SLIDE 10

26.03.2010

Mohammad Al-Turany, Hades Meeting

CPU GPU

CPU ¡vs. ¡GPU

5

Friday, March 26, 2010

slide-11
SLIDE 11

26.03.2010

Mohammad Al-Turany, Hades Meeting

CPU GPU

 The ¡CPU ¡handles ¡memory ¡

latency ¡by ¡using ¡large ¡caches ¡ and ¡branch ¡predicMon ¡hardware. ¡ These ¡take ¡up ¡a ¡large ¡deal ¡of ¡ die-­‑space ¡and ¡are ¡oXen ¡power ¡ hungry.

 The ¡GPU ¡handles ¡latency ¡by ¡

supporMng ¡thousands ¡of ¡threads ¡ in ¡flight ¡at ¡once. ¡If ¡a ¡parMcular ¡ thread ¡is ¡waiMng ¡for ¡a ¡load ¡from ¡ memory, ¡the ¡GPU ¡can ¡switch ¡to ¡ another ¡thread ¡with ¡no ¡delay.

CPU ¡vs. ¡GPU

5

Friday, March 26, 2010

slide-12
SLIDE 12

26.03.2010

Mohammad Al-Turany, Hades Meeting

CPU GPU

 The ¡CPU ¡handles ¡memory ¡

latency ¡by ¡using ¡large ¡caches ¡ and ¡branch ¡predicMon ¡hardware. ¡ These ¡take ¡up ¡a ¡large ¡deal ¡of ¡ die-­‑space ¡and ¡are ¡oXen ¡power ¡ hungry.

 The ¡cost ¡of ¡a ¡CPU ¡thread ¡switch ¡

is ¡hundreds ¡of ¡cycles.

 The ¡GPU ¡handles ¡latency ¡by ¡

supporMng ¡thousands ¡of ¡threads ¡ in ¡flight ¡at ¡once. ¡If ¡a ¡parMcular ¡ thread ¡is ¡waiMng ¡for ¡a ¡load ¡from ¡ memory, ¡the ¡GPU ¡can ¡switch ¡to ¡ another ¡thread ¡with ¡no ¡delay.

 GPUs ¡have ¡no ¡cost ¡in ¡switching ¡

  • threads. ¡GPUs ¡typically ¡switch ¡

threads ¡every ¡clock.

CPU ¡vs. ¡GPU

5

Friday, March 26, 2010

slide-13
SLIDE 13

26.03.2010

Mohammad Al-Turany, Hades Meeting

CPU GPU

CPU ¡vs. ¡GPU

6

Friday, March 26, 2010

slide-14
SLIDE 14

26.03.2010

Mohammad Al-Turany, Hades Meeting

CPU GPU

 CPUs ¡use ¡SIMD ¡(single ¡

instrucMon, ¡mulMple ¡data) ¡units ¡ for ¡vector ¡processing. ¡

 GPUs ¡employ ¡SIMT ¡(single ¡

instrucMon ¡mulMple ¡thread) ¡for ¡ scalar ¡thread ¡processing. ¡SIMT ¡ does ¡not ¡require ¡the ¡ programmer ¡to ¡organize ¡the ¡ data ¡into ¡vectors, ¡and ¡it ¡permits ¡ arbitrary ¡branching ¡behavior ¡for ¡ threads.

CPU ¡vs. ¡GPU

6

Friday, March 26, 2010

slide-15
SLIDE 15

26.03.2010

Mohammad Al-Turany, Hades Meeting

CUDA GPGPU

CUDA ¡vs ¡GPGPU

7

Friday, March 26, 2010

slide-16
SLIDE 16

26.03.2010

Mohammad Al-Turany, Hades Meeting

CUDA GPGPU

Trick the GPU into general-purpose computing by casting problem as graphics

  • Turn data into images ("texture

maps")

  • Turn algorithms into image

synthesis ("rendering passes") Drawback:

  • Tough learning curve
  • potentially high overhead of

graphics API

  • highly constrained memory layout

& access model

CUDA ¡vs ¡GPGPU

7

Friday, March 26, 2010

slide-17
SLIDE 17

26.03.2010

Mohammad Al-Turany, Hades Meeting

CUDA GPGPU

 work ¡with ¡familiar ¡programming ¡

concepts ¡(C ¡language) ¡while ¡developing ¡ soXware ¡that ¡can ¡run ¡on ¡a ¡GPU Trick the GPU into general-purpose computing by casting problem as graphics

  • Turn data into images ("texture

maps")

  • Turn algorithms into image

synthesis ("rendering passes") Drawback:

  • Tough learning curve
  • potentially high overhead of

graphics API

  • highly constrained memory layout

& access model

CUDA ¡vs ¡GPGPU

7

Friday, March 26, 2010

slide-18
SLIDE 18

26.03.2010

Mohammad Al-Turany, Hades Meeting

CUDA GPGPU

 work ¡with ¡familiar ¡programming ¡

concepts ¡(C ¡language) ¡while ¡developing ¡ soXware ¡that ¡can ¡run ¡on ¡a ¡GPU

 CUDA ¡compile ¡the ¡code ¡directly ¡to ¡the ¡

hardware ¡(GPU ¡assembly ¡language, ¡for ¡ instance), ¡thereby ¡providing ¡great ¡

  • performance. ¡

Trick the GPU into general-purpose computing by casting problem as graphics

  • Turn data into images ("texture

maps")

  • Turn algorithms into image

synthesis ("rendering passes") Drawback:

  • Tough learning curve
  • potentially high overhead of

graphics API

  • highly constrained memory layout

& access model

CUDA ¡vs ¡GPGPU

7

Friday, March 26, 2010

slide-19
SLIDE 19

26.03.2010

Mohammad Al-Turany, Hades Meeting

CUDA: ¡ ¡Features

 Standard ¡C ¡language ¡for ¡parallel ¡applicaMon ¡development ¡

  • n ¡the ¡GPU

 Standard ¡numerical ¡libraries ¡for ¡FFT ¡(Fast ¡Fourier ¡

Transform) ¡and ¡BLAS ¡(Basic ¡Linear ¡Algebra ¡SubrouMnes)

 Dedicated ¡CUDA ¡driver ¡for ¡compuMng ¡with ¡fast ¡data ¡

transfer ¡path ¡between ¡GPU ¡and ¡CPU

8

Friday, March 26, 2010

slide-20
SLIDE 20

26.03.2010

Mohammad Al-Turany, Hades Meeting

Why ¡CUDA?

9

Friday, March 26, 2010

slide-21
SLIDE 21

26.03.2010

Mohammad Al-Turany, Hades Meeting

Why ¡CUDA?

9

 CUDA ¡development ¡tools ¡work ¡alongside ¡the ¡convenMonal ¡C/C++ ¡

compiler, ¡so ¡one ¡can ¡mix ¡GPU ¡code ¡with ¡general-­‑purpose ¡code ¡for ¡ the ¡host ¡CPU.

Friday, March 26, 2010

slide-22
SLIDE 22

26.03.2010

Mohammad Al-Turany, Hades Meeting

Why ¡CUDA?

9

 CUDA ¡development ¡tools ¡work ¡alongside ¡the ¡convenMonal ¡C/C++ ¡

compiler, ¡so ¡one ¡can ¡mix ¡GPU ¡code ¡with ¡general-­‑purpose ¡code ¡for ¡ the ¡host ¡CPU.

 CUDA ¡AutomaMcally ¡Manages ¡Threads:

 It ¡does ¡NOT ¡require ¡explicit ¡management ¡for ¡threads ¡in ¡the ¡convenMonal ¡

sense, ¡which ¡greatly ¡simplifies ¡the ¡programming ¡model. ¡ ¡

Friday, March 26, 2010

slide-23
SLIDE 23

26.03.2010

Mohammad Al-Turany, Hades Meeting

Why ¡CUDA?

9

 CUDA ¡development ¡tools ¡work ¡alongside ¡the ¡convenMonal ¡C/C++ ¡

compiler, ¡so ¡one ¡can ¡mix ¡GPU ¡code ¡with ¡general-­‑purpose ¡code ¡for ¡ the ¡host ¡CPU.

 CUDA ¡AutomaMcally ¡Manages ¡Threads:

 It ¡does ¡NOT ¡require ¡explicit ¡management ¡for ¡threads ¡in ¡the ¡convenMonal ¡

sense, ¡which ¡greatly ¡simplifies ¡the ¡programming ¡model. ¡ ¡  Stable, ¡available ¡(for ¡free), ¡documented ¡and ¡supported ¡for ¡

windows, ¡Linux ¡and ¡Mac ¡OS

Friday, March 26, 2010

slide-24
SLIDE 24

26.03.2010

Mohammad Al-Turany, Hades Meeting

Why ¡CUDA?

9

 CUDA ¡development ¡tools ¡work ¡alongside ¡the ¡convenMonal ¡C/C++ ¡

compiler, ¡so ¡one ¡can ¡mix ¡GPU ¡code ¡with ¡general-­‑purpose ¡code ¡for ¡ the ¡host ¡CPU.

 CUDA ¡AutomaMcally ¡Manages ¡Threads:

 It ¡does ¡NOT ¡require ¡explicit ¡management ¡for ¡threads ¡in ¡the ¡convenMonal ¡

sense, ¡which ¡greatly ¡simplifies ¡the ¡programming ¡model. ¡ ¡  Stable, ¡available ¡(for ¡free), ¡documented ¡and ¡supported ¡for ¡

windows, ¡Linux ¡and ¡Mac ¡OS

 Low ¡learning ¡curve:

 Just ¡a ¡few ¡extensions ¡to ¡C ¡  No ¡knowledge ¡of ¡graphics ¡is ¡required ¡

Friday, March 26, 2010

slide-25
SLIDE 25

26.03.2010

Mohammad Al-Turany, Hades Meeting

Cuda ¡(2.3) ¡Toolkit

10

 NVCC ¡ ¡C ¡compiler  CUDA ¡FFT ¡and ¡BLAS ¡libraries ¡for ¡the ¡GPU

 CUDA-­‑gdb ¡hardware ¡debugger ¡  CUDA ¡Visual ¡Profiler ¡

 CUDA ¡run.me ¡driver ¡(also ¡available ¡in ¡the ¡

standard ¡NVIDIA ¡GPU ¡driver)

 CUDA ¡programming ¡manual

Friday, March 26, 2010

slide-26
SLIDE 26

26.03.2010

Mohammad Al-Turany, Hades Meeting

CUDA ¡in ¡FairRoot

11

 FindCuda.cmake ¡ ¡(Abe ¡Stephens ¡SCI ¡InsMtute)

 Integrate ¡CUDA ¡into ¡FairRoot ¡very ¡smoothly

 CMake ¡create ¡shared ¡libraries ¡for ¡CUDA ¡part  FairCuda ¡is ¡a ¡class ¡which ¡wraps ¡CUDA ¡implemented ¡ ¡

funcMons ¡so ¡that ¡they ¡can ¡be ¡used ¡directly ¡from ¡ROOT ¡ CINT ¡or ¡compiled ¡code

Friday, March 26, 2010

slide-27
SLIDE 27

26.03.2010

Mohammad Al-Turany, Hades Meeting

ReconstrucMon ¡chain ¡ ¡

12

Hits Track Finder Track candidates Track Fitter Tracks Task CPU ....... .......

Friday, March 26, 2010

slide-28
SLIDE 28

26.03.2010

Mohammad Al-Turany, Hades Meeting

ReconstrucMon ¡chain ¡ ¡

12

Hits Track Finder Track candidates Track Fitter Tracks ....... .......

Friday, March 26, 2010

slide-29
SLIDE 29

26.03.2010

Mohammad Al-Turany, Hades Meeting

ReconstrucMon ¡chain ¡ ¡

12

Hits Track Finder Track candidates Track Fitter Tracks Task GPU ....... .......

Friday, March 26, 2010

slide-30
SLIDE 30

26.03.2010

Mohammad Al-Turany, Hades Meeting

CUDA ¡programming ¡model

13

  • Kernel:
  • One ¡kernel ¡is ¡executed ¡at ¡a ¡Mme ¡
  • Kernel ¡launches ¡a ¡grid ¡of ¡thread ¡blocks ¡
  • Thread ¡block:
  • A ¡batch ¡of ¡thread. ¡
  • Threads ¡in ¡a ¡block ¡cooperate ¡together, ¡

efficiently ¡share ¡data.

  • Thread/block ¡have ¡unique ¡id
  • Grid:
  • A ¡batch ¡of ¡thread ¡blocks ¡that ¡execute ¡the ¡

same ¡kernel.

  • Threads ¡in ¡different ¡blocks ¡in ¡the ¡same ¡grid ¡

cannot ¡directly ¡communicate ¡with ¡each ¡

  • ther

Friday, March 26, 2010

slide-31
SLIDE 31

26.03.2010

Mohammad Al-Turany, Hades Meeting

CUDA ¡memory ¡model

There ¡is ¡6 ¡different ¡

memory ¡regions ¡

14

Friday, March 26, 2010

slide-32
SLIDE 32

26.03.2010

Mohammad Al-Turany, Hades Meeting

Register ¡Memory

 The ¡fastest ¡form ¡of ¡memory ¡

  • n ¡the ¡mul.-­‑processor.

 Is ¡only ¡accessible ¡by ¡the ¡

thread.

 Has ¡the ¡life.me ¡of ¡the ¡

thread

15

Friday, March 26, 2010

slide-33
SLIDE 33

26.03.2010

Mohammad Al-Turany, Hades Meeting

Shared ¡Memory

 Can ¡be ¡as ¡fast ¡as ¡a ¡register ¡

when ¡there ¡are ¡no ¡bank ¡ conflicts ¡or ¡when ¡reading ¡ from ¡the ¡same ¡address.

 Accessible ¡by ¡any ¡thread ¡of ¡

the ¡block ¡from ¡which ¡it ¡was ¡ created.

 Has ¡the ¡life.me ¡of ¡the ¡block.

16

Friday, March 26, 2010

slide-34
SLIDE 34

26.03.2010

Mohammad Al-Turany, Hades Meeting

Global ¡Memory

 Poten.ally ¡150x ¡slower ¡than ¡

register ¡or ¡shared ¡memory ¡.

 Accessible ¡from ¡either ¡the ¡

host ¡or ¡device.

 Has ¡the ¡life.me ¡of ¡the ¡

applica.on.

17

Friday, March 26, 2010

slide-35
SLIDE 35

26.03.2010

Mohammad Al-Turany, Hades Meeting

Local ¡Memory

 Resides ¡in ¡global ¡memory ¡

and ¡can ¡be ¡150x ¡slower ¡than ¡ register ¡or ¡shared ¡memory

 Is ¡only ¡accessible ¡by ¡the ¡

thread

 Has ¡the ¡life.me ¡of ¡the ¡

thread.

18

Friday, March 26, 2010

slide-36
SLIDE 36

26.03.2010

Mohammad Al-Turany, Hades Meeting

Constant ¡Memory

 in DRAM  cached  per grid  read-only

19

Friday, March 26, 2010

slide-37
SLIDE 37

26.03.2010

Mohammad Al-Turany, Hades Meeting

Texture ¡Memory

 in DRAM  cached  per grid  read-only

20

Friday, March 26, 2010

slide-38
SLIDE 38

26.03.2010

Mohammad Al-Turany, Hades Meeting

Global, ¡local, ¡ texture, ¡and ¡ constant ¡memory ¡ are ¡physically ¡the ¡ same ¡memory. ¡ They ¡differ ¡only ¡in ¡ caching ¡algorithms ¡ ¡ and ¡access ¡models. ¡

21

CPU can refresh and access only: global, constant, and texture memory.

Friday, March 26, 2010

slide-39
SLIDE 39

26.03.2010

Mohammad Al-Turany, Hades Meeting

Scalability ¡in ¡CUDA

22

Friday, March 26, 2010

slide-40
SLIDE 40

26.03.2010

Mohammad Al-Turany, Hades Meeting

Comparisons ¡between ¡CPU ¡and ¡GPU ¡code! ¡

23

Tracks Candidates Tracks

Friday, March 26, 2010

slide-41
SLIDE 41

26.03.2010

Mohammad Al-Turany, Hades Meeting

Comparisons ¡between ¡CPU ¡and ¡GPU ¡code! ¡

23

Tracks Candidates Tracks

CPU Fitting

Friday, March 26, 2010

slide-42
SLIDE 42

26.03.2010

Mohammad Al-Turany, Hades Meeting

Comparisons ¡between ¡CPU ¡and ¡GPU ¡code! ¡

23

Using the GPUs include some

  • verhead in data processing which has

to be considered in the comparisons to CPU code

Tracks Candidates Tracks

CPU Fitting

Copy To C Array Copy To GPU GPU Fitting Copy To Host

Friday, March 26, 2010

slide-43
SLIDE 43

U S I N G ¡ T E X T U R E ¡ M E M O RY ¡ ¡ FO R ¡ F I E L D ¡ M A P S

Example ¡(Texture ¡Memory)

Friday, March 26, 2010

slide-44
SLIDE 44

26.03.2010

Mohammad Al-Turany, Hades Meeting

Field ¡Maps

25

Friday, March 26, 2010

slide-45
SLIDE 45

26.03.2010

Mohammad Al-Turany, Hades Meeting

Field ¡Maps

 Usually ¡a ¡three ¡dimensional ¡array ¡(XYZ, ¡Rθϕ, etc)

25

Friday, March 26, 2010

slide-46
SLIDE 46

26.03.2010

Mohammad Al-Turany, Hades Meeting

Field ¡Maps

 Usually ¡a ¡three ¡dimensional ¡array ¡(XYZ, ¡Rθϕ, etc)  Used ¡as ¡a ¡lookup ¡table ¡with ¡some ¡interpolaMon ¡ ¡

25

Friday, March 26, 2010

slide-47
SLIDE 47

26.03.2010

Mohammad Al-Turany, Hades Meeting

Field ¡Maps

 Usually ¡a ¡three ¡dimensional ¡array ¡(XYZ, ¡Rθϕ, etc)  Used ¡as ¡a ¡lookup ¡table ¡with ¡some ¡interpolaMon ¡ ¡  For ¡performance ¡and ¡mulM-­‑access ¡issues, ¡many ¡people ¡try ¡

to ¡parameterize ¡it.

25

Friday, March 26, 2010

slide-48
SLIDE 48

26.03.2010

Mohammad Al-Turany, Hades Meeting

Field ¡Maps

 Usually ¡a ¡three ¡dimensional ¡array ¡(XYZ, ¡Rθϕ, etc)  Used ¡as ¡a ¡lookup ¡table ¡with ¡some ¡interpolaMon ¡ ¡  For ¡performance ¡and ¡mulM-­‑access ¡issues, ¡many ¡people ¡try ¡

to ¡parameterize ¡it.

Drawback:

 Specific for certain maps  Hard to do with good accuracy  Not possible for all maps 25

Friday, March 26, 2010

slide-49
SLIDE 49

26.03.2010

Mohammad Al-Turany, Hades Meeting

Texture ¡Memory ¡for ¡field ¡maps

 Three ¡dimensional ¡arrays ¡can ¡be ¡bind ¡to ¡texture ¡directly  Accessible ¡from ¡all ¡threads ¡in ¡a ¡grid  Linear ¡interpolaMon ¡is ¡done ¡by ¡dedicated ¡hardware  Cashed ¡and ¡allow ¡mulMple ¡random ¡access

26

Friday, March 26, 2010

slide-50
SLIDE 50

26.03.2010

Mohammad Al-Turany, Hades Meeting

Texture ¡Memory ¡for ¡field ¡maps

 Three ¡dimensional ¡arrays ¡can ¡be ¡bind ¡to ¡texture ¡directly  Accessible ¡from ¡all ¡threads ¡in ¡a ¡grid  Linear ¡interpolaMon ¡is ¡done ¡by ¡dedicated ¡hardware  Cashed ¡and ¡allow ¡mulMple ¡random ¡access

26

Ideal ¡for ¡field ¡maps!

Friday, March 26, 2010

slide-51
SLIDE 51

26.03.2010

Mohammad Al-Turany, Hades Meeting

Using ¡Texture ¡Memory

 Host ¡(CPU) ¡code:

 Allocate/obtain ¡memory ¡(global ¡linear/pitch ¡linear, ¡or ¡CUDA ¡array)  Create ¡a ¡texture ¡reference ¡object ¡(Currently ¡must ¡be ¡at ¡file-­‑scope)  Bind ¡the ¡texture ¡reference ¡to ¡memory/array  When ¡done: ¡Unbind ¡the ¡texture ¡reference, ¡free ¡resources

 Device ¡(kernel) ¡code:

 Fetch ¡using ¡texture ¡reference ¡  Linear ¡memory ¡textures: ¡tex1Dfetch() ¡  Array ¡textures: ¡tex1D() ¡or ¡tex2D() ¡or ¡tex3D() ¡  Pitch ¡linear ¡textures: ¡tex2D()

27

Friday, March 26, 2010

slide-52
SLIDE 52

26.03.2010

Mohammad Al-Turany, Hades Meeting

Texture ¡Filtering

CudaFilterModePoint: ¡ ¡The ¡returned ¡value ¡is ¡the ¡texel ¡

(Texture ¡Element) ¡whose ¡texture ¡coordinates ¡are ¡the ¡ closest ¡to ¡the ¡input ¡texture ¡coordinates; ¡

CudaFilterModeLinear: ¡ ¡The ¡returned ¡value ¡is ¡the ¡

linear ¡interpolaMon ¡of ¡the ¡two ¡(for ¡a ¡one-­‑dimensional ¡ texture), ¡four ¡(for ¡a ¡two-­‑dimensional ¡texture), ¡or ¡eight ¡ (for ¡a ¡three-­‑dimensional ¡texture) ¡texels ¡whose ¡texture ¡ coordinates ¡are ¡the ¡closest ¡to ¡the ¡input ¡texture ¡ coordinates

28

Friday, March 26, 2010

slide-53
SLIDE 53

26.03.2010

Mohammad Al-Turany, Hades Meeting

Texture ¡Address ¡Mode

 How ¡out-­‑of-­‑range ¡texture ¡coordinates ¡are ¡handled; ¡

 Clamp: ¡ ¡ ¡Out-­‑of-­‑range ¡texture ¡coordinates ¡are ¡clamped ¡to ¡the ¡valid ¡

  • range. ¡(Values ¡below ¡0 ¡are ¡set ¡to ¡0 ¡and ¡values ¡greater ¡or ¡equal ¡to ¡N ¡

are ¡set ¡to ¡N-­‑1)

 Wrap: ¡ ¡Out-­‑of-­‑ ¡range ¡texture ¡coordinates ¡are ¡wrapped ¡to ¡the ¡valid ¡

range ¡(only ¡for ¡normalized ¡coordinates). ¡Wrap ¡addressing ¡is ¡usually ¡ used ¡when ¡the ¡texture ¡contains ¡a ¡periodic ¡signal. ¡It ¡uses ¡only ¡the ¡ fracMonal ¡part ¡of ¡the ¡texture ¡coordinate; ¡for ¡example, ¡1.25 ¡is ¡treated ¡ the ¡same ¡as ¡0.25 ¡and ¡-­‑1.25 ¡is ¡treated ¡the ¡same ¡as ¡0.75

29

Friday, March 26, 2010

slide-54
SLIDE 54

26.03.2010

Mohammad Al-Turany, Hades Meeting

Runge-­‑KuIa ¡propagator

 The ¡Geant3 ¡Runge-­‑KuIa ¡propagator ¡was ¡re-­‑wriIen ¡inside ¡ ¡

a ¡cuda ¡kernel

 ¡Runge-­‑KuIa ¡method ¡for ¡tracking ¡a ¡parMcle ¡through ¡a ¡magneMc ¡ ¡field. ¡

Uses ¡Nystroem ¡algorithm ¡(See ¡Handbook ¡Nat. ¡Bur. ¡Of ¡ ¡ ¡Standards, ¡ procedure ¡25.5.20)

 The ¡algorithm ¡it ¡self ¡is ¡hardly ¡parallelizable, ¡but ¡one ¡can ¡

propagate ¡all ¡tracks ¡in ¡an ¡event ¡in ¡parallel

 For ¡each ¡track, ¡a ¡block ¡of ¡8 ¡threads ¡is ¡created, ¡the ¡parMcle ¡

data ¡is ¡copied ¡by ¡all ¡threads ¡at ¡once, ¡then ¡one ¡thread ¡do ¡ the ¡propagaMon

30

Friday, March 26, 2010

slide-55
SLIDE 55

26.03.2010

Mohammad Al-Turany, Hades Meeting

Using ¡GPUs ¡in ¡HADES

 Field ¡Map ¡is ¡converted ¡to ¡XYZ ¡map ¡  Event ¡where ¡generated ¡with ¡0.2-­‑.0.8 ¡GeV ¡(protons)  Tracks ¡are ¡propagated ¡from ¡the ¡first ¡layer ¡in ¡the ¡MDC1 ¡to ¡

the ¡sixth ¡layer ¡in ¡MDC4

31

Friday, March 26, 2010

slide-56
SLIDE 56

Hades ¡Magnet

Friday, March 26, 2010

slide-57
SLIDE 57

6/17/09

M.Al-Turany, Panda CM, Turin

 HADES field map is saved as half sector in cylindrical

coordinates

 Each call to the map include conversion from

Cartesian to Cylindrical coordinates

 For simulation and tracking this is an overhead!

which can be removed by transforming the map ones to cartesian coordinates

 Drawback:  Size of the map is then 3 times larger (about 75 MB for one sector in

xyz)

33

HADES Field Map

Friday, March 26, 2010

slide-58
SLIDE 58

ρθZ ¡and ¡XYZ ¡MAPS ¡for ¡Hades ¡(in ¡kG)

34

Bz(r) RTZ Bz(r) XYZ By(r) RTZ By(r) XYZ Bx(r) RTZ Bx(r) XYZ Diff Bx(r) Diff By(r) Diff Bx(r) Bx(r) RTZ Bx(r) XYZ

Friday, March 26, 2010

slide-59
SLIDE 59

ρθZ ¡and ¡XYZ ¡MAPS ¡for ¡Hades ¡(in ¡kG)

34

Bz(r) RTZ Bz(r) XYZ By(r) RTZ By(r) XYZ Bx(r) RTZ Bx(r) XYZ Diff Bx(r) Diff By(r) Diff Bx(r) Integrals over the Path (T/m): Bx By Bz RTZ -0.0247085 0.0259996 -0.0012521 XYZ -0.0247093 0.0260001 -0.0012534 Diff 8E-7 5E-7 12E-7 Bx(r) RTZ Bx(r) XYZ

Friday, March 26, 2010

slide-60
SLIDE 60

35

26.03.2010

Mohammad Al-Turany, Hades Meeting

Hades ¡Detector

35

Friday, March 26, 2010

slide-61
SLIDE 61

36

26.03.2010

Mohammad Al-Turany, Hades Meeting

Timing ¡

¡ ¡ ¡unsigned ¡int ¡Mmer ¡= ¡0; ¡ ¡ ¡cuMlCheckError(cutCreateTimer(&Mmer)); ¡ ¡ ¡cuMlCheckError(cutStartTimer(Mmer)); ¡ ¡ ¡cudaMalloc((void**)&d_vecRKIn, ¡bytes*8); ¡ ¡ ¡ ¡ ¡cuMlSafeCall(cudaHostGetDevicePointer((void ¡**)&d_vecRKOut,(void ¡*)vecRKOut,0)); ¡ ¡ ¡checkCUDAError("Device ¡Pointers"); ¡ ¡ ¡cudaMemcpy ¡(d_vecRKIn, ¡ ¡ ¡ ¡vecRKIn, ¡ ¡ ¡bytes*8, ¡ ¡cudaMemcpyHostToDevice); ¡ ¡ ¡ ¡int ¡threads=8 ¡; ¡int ¡tracks=TRK; ¡ ¡ ¡dim3 ¡dimBlock(threads, ¡1); ¡ ¡ ¡dim3 ¡dimGrid(tracks,1); ¡ ¡ ¡ ¡PropagateToPlane<<< ¡dimGrid, ¡dimBlock ¡>>>(d_vecRKIn,d_vecRKOut); ¡ ¡ ¡cudaThreadSynchronize(); ¡ ¡ ¡cuMlCheckError(cutStopTimer(Mmer)); ¡ ¡ ¡prinz("Processing ¡Mme ¡on ¡GPU ¡: ¡%f ¡(ms) ¡\n", ¡cutGetTimerValue(Mmer)); ¡ ¡ ¡cuMlCheckError(cutDeleteTimer(Mmer));

36

Friday, March 26, 2010

slide-62
SLIDE 62

36

26.03.2010

Mohammad Al-Turany, Hades Meeting

Timing ¡

¡ ¡ ¡unsigned ¡int ¡Mmer ¡= ¡0; ¡ ¡ ¡cuMlCheckError(cutCreateTimer(&Mmer)); ¡ ¡ ¡cuMlCheckError(cutStartTimer(Mmer)); ¡ ¡ ¡cudaMalloc((void**)&d_vecRKIn, ¡bytes*8); ¡ ¡ ¡ ¡ ¡cuMlSafeCall(cudaHostGetDevicePointer((void ¡**)&d_vecRKOut,(void ¡*)vecRKOut,0)); ¡ ¡ ¡checkCUDAError("Device ¡Pointers"); ¡ ¡ ¡cudaMemcpy ¡(d_vecRKIn, ¡ ¡ ¡ ¡vecRKIn, ¡ ¡ ¡bytes*8, ¡ ¡cudaMemcpyHostToDevice); ¡ ¡ ¡ ¡int ¡threads=8 ¡; ¡int ¡tracks=TRK; ¡ ¡ ¡dim3 ¡dimBlock(threads, ¡1); ¡ ¡ ¡dim3 ¡dimGrid(tracks,1); ¡ ¡ ¡ ¡PropagateToPlane<<< ¡dimGrid, ¡dimBlock ¡>>>(d_vecRKIn,d_vecRKOut); ¡ ¡ ¡cudaThreadSynchronize(); ¡ ¡ ¡cuMlCheckError(cutStopTimer(Mmer)); ¡ ¡ ¡prinz("Processing ¡Mme ¡on ¡GPU ¡: ¡%f ¡(ms) ¡\n", ¡cutGetTimerValue(Mmer)); ¡ ¡ ¡cuMlCheckError(cutDeleteTimer(Mmer));

36

Allocate Memory

  • n Card

Friday, March 26, 2010

slide-63
SLIDE 63

36

26.03.2010

Mohammad Al-Turany, Hades Meeting

Timing ¡

¡ ¡ ¡unsigned ¡int ¡Mmer ¡= ¡0; ¡ ¡ ¡cuMlCheckError(cutCreateTimer(&Mmer)); ¡ ¡ ¡cuMlCheckError(cutStartTimer(Mmer)); ¡ ¡ ¡cudaMalloc((void**)&d_vecRKIn, ¡bytes*8); ¡ ¡ ¡ ¡ ¡cuMlSafeCall(cudaHostGetDevicePointer((void ¡**)&d_vecRKOut,(void ¡*)vecRKOut,0)); ¡ ¡ ¡checkCUDAError("Device ¡Pointers"); ¡ ¡ ¡cudaMemcpy ¡(d_vecRKIn, ¡ ¡ ¡ ¡vecRKIn, ¡ ¡ ¡bytes*8, ¡ ¡cudaMemcpyHostToDevice); ¡ ¡ ¡ ¡int ¡threads=8 ¡; ¡int ¡tracks=TRK; ¡ ¡ ¡dim3 ¡dimBlock(threads, ¡1); ¡ ¡ ¡dim3 ¡dimGrid(tracks,1); ¡ ¡ ¡ ¡PropagateToPlane<<< ¡dimGrid, ¡dimBlock ¡>>>(d_vecRKIn,d_vecRKOut); ¡ ¡ ¡cudaThreadSynchronize(); ¡ ¡ ¡cuMlCheckError(cutStopTimer(Mmer)); ¡ ¡ ¡prinz("Processing ¡Mme ¡on ¡GPU ¡: ¡%f ¡(ms) ¡\n", ¡cutGetTimerValue(Mmer)); ¡ ¡ ¡cuMlCheckError(cutDeleteTimer(Mmer));

36

Get pointer to pinned memory for

  • utput

Friday, March 26, 2010

slide-64
SLIDE 64

36

26.03.2010

Mohammad Al-Turany, Hades Meeting

Timing ¡

¡ ¡ ¡unsigned ¡int ¡Mmer ¡= ¡0; ¡ ¡ ¡cuMlCheckError(cutCreateTimer(&Mmer)); ¡ ¡ ¡cuMlCheckError(cutStartTimer(Mmer)); ¡ ¡ ¡cudaMalloc((void**)&d_vecRKIn, ¡bytes*8); ¡ ¡ ¡ ¡ ¡cuMlSafeCall(cudaHostGetDevicePointer((void ¡**)&d_vecRKOut,(void ¡*)vecRKOut,0)); ¡ ¡ ¡checkCUDAError("Device ¡Pointers"); ¡ ¡ ¡cudaMemcpy ¡(d_vecRKIn, ¡ ¡ ¡ ¡vecRKIn, ¡ ¡ ¡bytes*8, ¡ ¡cudaMemcpyHostToDevice); ¡ ¡ ¡ ¡int ¡threads=8 ¡; ¡int ¡tracks=TRK; ¡ ¡ ¡dim3 ¡dimBlock(threads, ¡1); ¡ ¡ ¡dim3 ¡dimGrid(tracks,1); ¡ ¡ ¡ ¡PropagateToPlane<<< ¡dimGrid, ¡dimBlock ¡>>>(d_vecRKIn,d_vecRKOut); ¡ ¡ ¡cudaThreadSynchronize(); ¡ ¡ ¡cuMlCheckError(cutStopTimer(Mmer)); ¡ ¡ ¡prinz("Processing ¡Mme ¡on ¡GPU ¡: ¡%f ¡(ms) ¡\n", ¡cutGetTimerValue(Mmer)); ¡ ¡ ¡cuMlCheckError(cutDeleteTimer(Mmer));

36

copy data to the card memory

Friday, March 26, 2010

slide-65
SLIDE 65

36

26.03.2010

Mohammad Al-Turany, Hades Meeting

Timing ¡

¡ ¡ ¡unsigned ¡int ¡Mmer ¡= ¡0; ¡ ¡ ¡cuMlCheckError(cutCreateTimer(&Mmer)); ¡ ¡ ¡cuMlCheckError(cutStartTimer(Mmer)); ¡ ¡ ¡cudaMalloc((void**)&d_vecRKIn, ¡bytes*8); ¡ ¡ ¡ ¡ ¡cuMlSafeCall(cudaHostGetDevicePointer((void ¡**)&d_vecRKOut,(void ¡*)vecRKOut,0)); ¡ ¡ ¡checkCUDAError("Device ¡Pointers"); ¡ ¡ ¡cudaMemcpy ¡(d_vecRKIn, ¡ ¡ ¡ ¡vecRKIn, ¡ ¡ ¡bytes*8, ¡ ¡cudaMemcpyHostToDevice); ¡ ¡ ¡ ¡int ¡threads=8 ¡; ¡int ¡tracks=TRK; ¡ ¡ ¡dim3 ¡dimBlock(threads, ¡1); ¡ ¡ ¡dim3 ¡dimGrid(tracks,1); ¡ ¡ ¡ ¡PropagateToPlane<<< ¡dimGrid, ¡dimBlock ¡>>>(d_vecRKIn,d_vecRKOut); ¡ ¡ ¡cudaThreadSynchronize(); ¡ ¡ ¡cuMlCheckError(cutStopTimer(Mmer)); ¡ ¡ ¡prinz("Processing ¡Mme ¡on ¡GPU ¡: ¡%f ¡(ms) ¡\n", ¡cutGetTimerValue(Mmer)); ¡ ¡ ¡cuMlCheckError(cutDeleteTimer(Mmer));

36

Launch the Kernel

Friday, March 26, 2010

slide-66
SLIDE 66

36

26.03.2010

Mohammad Al-Turany, Hades Meeting

Timing ¡

¡ ¡ ¡unsigned ¡int ¡Mmer ¡= ¡0; ¡ ¡ ¡cuMlCheckError(cutCreateTimer(&Mmer)); ¡ ¡ ¡cuMlCheckError(cutStartTimer(Mmer)); ¡ ¡ ¡cudaMalloc((void**)&d_vecRKIn, ¡bytes*8); ¡ ¡ ¡ ¡ ¡cuMlSafeCall(cudaHostGetDevicePointer((void ¡**)&d_vecRKOut,(void ¡*)vecRKOut,0)); ¡ ¡ ¡checkCUDAError("Device ¡Pointers"); ¡ ¡ ¡cudaMemcpy ¡(d_vecRKIn, ¡ ¡ ¡ ¡vecRKIn, ¡ ¡ ¡bytes*8, ¡ ¡cudaMemcpyHostToDevice); ¡ ¡ ¡ ¡int ¡threads=8 ¡; ¡int ¡tracks=TRK; ¡ ¡ ¡dim3 ¡dimBlock(threads, ¡1); ¡ ¡ ¡dim3 ¡dimGrid(tracks,1); ¡ ¡ ¡ ¡PropagateToPlane<<< ¡dimGrid, ¡dimBlock ¡>>>(d_vecRKIn,d_vecRKOut); ¡ ¡ ¡cudaThreadSynchronize(); ¡ ¡ ¡cuMlCheckError(cutStopTimer(Mmer)); ¡ ¡ ¡prinz("Processing ¡Mme ¡on ¡GPU ¡: ¡%f ¡(ms) ¡\n", ¡cutGetTimerValue(Mmer)); ¡ ¡ ¡cuMlCheckError(cutDeleteTimer(Mmer));

36

Friday, March 26, 2010

slide-67
SLIDE 67

26.03.2010

Mohammad Al-Turany, Hades Meeting

Track ¡Propaga+on ¡ (Time ¡per ¡event)

In ¡HADES ¡case ¡the ¡ number ¡of ¡Tracks ¡ here ¡should ¡be ¡taken ¡ as ¡the ¡number ¡of ¡ propagaMons ¡per ¡ events

37 Trk/Event CPU GPU emu Tesla C1060 (240)

10 1.0 0.35 0.09 50 2.8 1.54 0.18 100 5.2 2.97 0.35 200 10.0 6.15 0.42 500 22.6 16.7 0.66 700 30.3 22.4 0.74 (In ¡HADES ¡fiQng ¡each ¡Track ¡is ¡propagated ¡6 ¡ Mmes ¡for ¡each ¡iteraMon ¡in ¡the ¡fit)

Friday, March 26, 2010

slide-68
SLIDE 68

38

26.03.2010

Mohammad Al-Turany, Hades Meeting

Track ¡PropagaMon ¡( µs/propagation)

38

Time in µs needed to propagate one track from MDC1 layer1 to MDC 4 layer 6

Trk/Event CPU GPU emu Tesla C1060 (240)

10 100 35 9.0 50 56 31 3.6 100 52 30 3.5 200 50 31 2.0 500 45 33 1.3 700 43 32 1.1

Friday, March 26, 2010

slide-69
SLIDE 69

39

26.03.2010

Mohammad Al-Turany, Hades Meeting

Speedup ¡factor ¡

39

Trk/Event GPU emu Tesla 10 ¡ 2.9 11 50 1.9 15 100 1.8 15 200 1.6 24 500 1.4 34 700 1.4 41

Friday, March 26, 2010

slide-70
SLIDE 70

6/17/09

M.Al-Turany, Panda CM, Turin

Possible (?) next steps for HADES

 Optimize the block size (number of threads)  Integrate CUDA in HADES building system

(Makefiles) OR, move HADES to CMAKE!

 CUDA is integrated  Test system, with nightly and continues builds and Dashboard

(see http://fairroot.gsi.de/CDash/ )

 Re-write the fitting in CUDA

40

Friday, March 26, 2010

slide-71
SLIDE 71

U S I N G ¡ T H E ¡ P I N N E D ¡ ( PAG E D -­‑ LO C K E D ) ¡ M E M O RY ¡ TO ¡ M A K E ¡ T H E ¡ DATA ¡ AVA I L A B L E ¡ TO ¡ T H E ¡ G P U

Example ¡(Zero ¡Copy)

Friday, March 26, 2010

slide-72
SLIDE 72

26.03.2010

Mohammad Al-Turany, Hades Meeting

¡Zero ¡Copy

 Zero ¡copy ¡was ¡introduced ¡in ¡CUDA ¡Toolkit ¡2.2 ¡  It ¡enables ¡GPU ¡threads ¡to ¡directly ¡access ¡host ¡memory, ¡

and ¡it ¡requires ¡mapped ¡pinned ¡(non-­‑pageable) ¡memory

 Zero ¡copy ¡can ¡be ¡used ¡in ¡place ¡of ¡streams ¡because ¡kernel-­‑

  • riginated ¡data ¡transfers ¡automaMcally ¡overlap ¡kernel ¡

execuMon ¡without ¡the ¡overhead ¡of ¡seQng ¡up ¡and ¡ determining ¡the ¡opMmal ¡number ¡of ¡streams

42

Friday, March 26, 2010

slide-73
SLIDE 73

26.03.2010

Mohammad Al-Turany, Hades Meeting

Pinned ¡Memory

 On ¡discrete ¡GPUs, ¡mapped ¡pinned ¡memory ¡is ¡

advantageous ¡only ¡in ¡certain ¡cases. ¡Because ¡the ¡data ¡is ¡ not ¡cached ¡on ¡the ¡GPU, ¡mapped ¡pinned ¡memory ¡should ¡ be ¡read ¡or ¡wriIen ¡only ¡once, ¡and ¡the ¡global ¡loads ¡and ¡ stores ¡that ¡read ¡and ¡write ¡the ¡memory ¡should ¡be ¡

  • coalesced. ¡

 On ¡integrated ¡GPUs, ¡mapped ¡pinned ¡memory ¡is ¡always ¡a ¡

performance ¡gain ¡because ¡it ¡avoids ¡superfluous ¡copies ¡as ¡ integrated ¡GPU ¡and ¡CPU ¡memory ¡are ¡physically ¡the ¡same. ¡

43

Friday, March 26, 2010

slide-74
SLIDE 74

26.03.2010

Mohammad Al-Turany, Hades Meeting

7.50 15.00 22.50 30.00 50 100 1000 2000

GPU GPU Zero Copy

Track ¡+ ¡vertex ¡fiQng ¡on ¡CPU ¡and ¡GPU

44

50 100 1000 2000 CPU 3.0 5.0 120 220 GPU ¡ 1.0 1.2 6.5 12.5 GPU ¡(Zero ¡Copy) 0.2 0.4 5.4 10.5

Track/Event 50 100 1000 2000 GPU ¡ 3.0 4.2 18 18 GPU ¡(Zero ¡Copy) 15 13 22 20

Time needed per event (ms) CPU Time/GPU Time

Friday, March 26, 2010

slide-75
SLIDE 75

26.03.2010

Mohammad Al-Turany, Hades Meeting

Resource ¡usage ¡in ¡this ¡Test

Qaudro ¡NVS ¡ ¡290 ¡ GeForce 8400 ¡GT GeForce 8800 ¡GT Tesla ¡C1060 Warps/MulMprocessor

24 24 24 32

Occupancy

33% 33% 33% 25%

AcMve ¡Threads

128 256 896 1920

¡ ¡Limited ¡by ¡Max ¡Warps ¡/ ¡ ¡MulMprocessor

8 8 8 8

45

Friday, March 26, 2010

slide-76
SLIDE 76

26.03.2010

Mohammad Al-Turany, Hades Meeting

Resource ¡usage ¡in ¡this ¡Test

Qaudro ¡NVS ¡ ¡290 ¡ GeForce 8400 ¡GT GeForce 8800 ¡GT Tesla ¡C1060 Warps/MulMprocessor

24 24 24 32

Occupancy

33% 33% 33% 25%

AcMve ¡Threads

128 256 896 1920

¡ ¡Limited ¡by ¡Max ¡Warps ¡/ ¡ ¡MulMprocessor

8 8 8 8

45

AcMve ¡threads ¡= ¡Warps ¡x ¡32 ¡x ¡ mulMprocessor ¡x ¡occupancy ¡

AcMve ¡threads ¡in ¡Tesla ¡= ¡ 8x32x30x0.25 ¡= 1920 ¡

Friday, March 26, 2010

slide-77
SLIDE 77

6/17/09

M.Al-Turany, Panda CM, Turin

Parallelization on CPU/GPU (PANDA track fitting)

46

Friday, March 26, 2010

slide-78
SLIDE 78

6/17/09

M.Al-Turany, Panda CM, Turin

Parallelization on CPU/GPU (PANDA track fitting)

46

  • No. of

Process Track/ Event 50 (Float) 2000 (Float) 1 CPU 1.7 E4 Track/s 9.1 E2 Track/s 1 CPU + GPU (T (Tesla) 5.0 E4 Track/s 6.3 E5 Track/s 4 CPU + GPU (T (Tesla) 1.2 E5 Track/s 2.2 E6 Track/s

Friday, March 26, 2010

slide-79
SLIDE 79

26.03.2010

Mohammad Al-Turany, Hades Meeting

Summary ¡

47

Friday, March 26, 2010

slide-80
SLIDE 80

26.03.2010

Mohammad Al-Turany, Hades Meeting

Summary ¡

47

 Cuda ¡is ¡an ¡easy ¡to ¡learn ¡and ¡to ¡use ¡tool.

Friday, March 26, 2010

slide-81
SLIDE 81

26.03.2010

Mohammad Al-Turany, Hades Meeting

Summary ¡

47

 Cuda ¡is ¡an ¡easy ¡to ¡learn ¡and ¡to ¡use ¡tool.  Cuda ¡allows ¡heterogeneous ¡programming.

Friday, March 26, 2010

slide-82
SLIDE 82

26.03.2010

Mohammad Al-Turany, Hades Meeting

Summary ¡

47

 Cuda ¡is ¡an ¡easy ¡to ¡learn ¡and ¡to ¡use ¡tool.  Cuda ¡allows ¡heterogeneous ¡programming.  Depending ¡on ¡the ¡use ¡case ¡one ¡can ¡win ¡factors ¡in ¡performance ¡

compared ¡to ¡CPU

Friday, March 26, 2010

slide-83
SLIDE 83

26.03.2010

Mohammad Al-Turany, Hades Meeting

Summary ¡

47

 Cuda ¡is ¡an ¡easy ¡to ¡learn ¡and ¡to ¡use ¡tool.  Cuda ¡allows ¡heterogeneous ¡programming.  Depending ¡on ¡the ¡use ¡case ¡one ¡can ¡win ¡factors ¡in ¡performance ¡

compared ¡to ¡CPU

 Texture ¡memory ¡can ¡be ¡used ¡to ¡solve ¡problems ¡that ¡require ¡

lookup ¡tables ¡effecMvely

Friday, March 26, 2010

slide-84
SLIDE 84

26.03.2010

Mohammad Al-Turany, Hades Meeting

Summary ¡

47

 Cuda ¡is ¡an ¡easy ¡to ¡learn ¡and ¡to ¡use ¡tool.  Cuda ¡allows ¡heterogeneous ¡programming.  Depending ¡on ¡the ¡use ¡case ¡one ¡can ¡win ¡factors ¡in ¡performance ¡

compared ¡to ¡CPU

 Texture ¡memory ¡can ¡be ¡used ¡to ¡solve ¡problems ¡that ¡require ¡

lookup ¡tables ¡effecMvely

 Pinned ¡Memory ¡simplify ¡some ¡problems, ¡gives ¡also ¡beIer ¡

  • performance. ¡

Friday, March 26, 2010

slide-85
SLIDE 85

26.03.2010

Mohammad Al-Turany, Hades Meeting

Summary ¡

47

 Cuda ¡is ¡an ¡easy ¡to ¡learn ¡and ¡to ¡use ¡tool.  Cuda ¡allows ¡heterogeneous ¡programming.  Depending ¡on ¡the ¡use ¡case ¡one ¡can ¡win ¡factors ¡in ¡performance ¡

compared ¡to ¡CPU

 Texture ¡memory ¡can ¡be ¡used ¡to ¡solve ¡problems ¡that ¡require ¡

lookup ¡tables ¡effecMvely

 Pinned ¡Memory ¡simplify ¡some ¡problems, ¡gives ¡also ¡beIer ¡

  • performance. ¡

 The ¡results ¡for ¡HADES ¡are ¡preliminary, ¡and ¡sMll ¡a ¡lot ¡of ¡space ¡for ¡

improvement!

Friday, March 26, 2010

slide-86
SLIDE 86

Backup ¡Slides

Friday, March 26, 2010

slide-87
SLIDE 87

FERMI ¡

NVIDIA’s ¡Next ¡Genera.on ¡CUDA ¡ Architecture

Friday, March 26, 2010

slide-88
SLIDE 88

26.03.2010

Mohammad Al-Turany, Hades Meeting

Features:

Support ¡a ¡true ¡cache ¡ hierarchy ¡in ¡combinaMon ¡ with ¡on-­‑chip ¡shared ¡ memory ¡ Improves ¡bandwidth ¡and ¡ reduces ¡latency ¡through ¡ L1 ¡cache’s ¡configurable ¡ shared ¡memory Fast, ¡coherent ¡data ¡ sharing ¡across ¡the ¡GPU ¡ through ¡unified ¡L2 ¡cache

50

http://www.behardware.com/art/imprimer/772/

Fermi Tesla

Friday, March 26, 2010

slide-89
SLIDE 89

26.03.2010

Mohammad Al-Turany, Hades Meeting

NVIDIA ¡GigaThread™ ¡ Engine ¡ Increased ¡efficiency ¡with ¡ concurrent ¡kernel ¡execuMon Dedicated, ¡bi-­‑direcMonal ¡ data ¡transfer ¡engines Intelligently ¡manage ¡tens ¡of ¡ thousands ¡of ¡threads

51

http://www.behardware.com/art/imprimer/772/

Friday, March 26, 2010

slide-90
SLIDE 90

26.03.2010

Mohammad Al-Turany, Hades Meeting

ECC ¡Support

52

 First ¡GPU ¡architecture ¡to ¡support ¡ECC  Detects ¡and ¡corrects ¡errors ¡before ¡system ¡is ¡affected  Protects ¡register ¡files, ¡shared ¡memories, ¡L1 ¡and ¡L2 ¡cache, ¡

and ¡DRAM

Friday, March 26, 2010

slide-91
SLIDE 91

26.03.2010

Mohammad Al-Turany, Hades Meeting

Unified ¡address ¡space

53

Groups local, shared and global memory in the same address space. This unified address space means support for pointers and object references that are necessary for high-level languages such as C++.

http://www.behardware.com/art/imprimer/772/

Friday, March 26, 2010

slide-92
SLIDE 92

26.03.2010

Mohammad Al-Turany, Hades Meeting

CPU ¡vs ¡GPU ¡code

Double_t h2, h4, f[4]; Double_t xyzt[3], a, b, c, ph,ph2; Double_t secxs[4],secys[4],seczs[4],hxp[3]; Double_t g1, g2, g3, g4, g5, g6, ang2, dxt, dyt, dzt; Double_t est, at, bt, ct, cba; Double_t f1, f2, f3, f4, rho, tet, hnorm, hp, rho1, sint, cost; Double_t x; Double_t y; Double_t z; Double_t xt; Double_t yt; Double_t zt; Double_t maxit = 10; Double_t maxcut = 11; const Double_t hmin = 1e-4; const Double_t kdlt = 1e-3; const Double_t kdlt32 = kdlt/32.; const Double_t kthird = 1./3.; …… __shared__ float4 field; float h2, h4, f[4]; float xyzt[3], a, b, c, ph,ph2; float secxs[4],secys[4],seczs[4],hxp[3]; float g1, g2, g3, g4, g5, g6, ang2, dxt, dyt, dzt; float est, at, bt, ct, cba; float f1, f2, f3, f4, rho, tet, hnorm, hp, rho1, sint, cost; float x; float y; float z; float xt; float yt; float zt; float maxit= 10; float maxcut= 11; float hmin = 1e-4; float kdlt = 1e-3; float kdlt32 = kdlt/32.; float kthird = 1./3.; ….

54

Friday, March 26, 2010

slide-93
SLIDE 93

26.03.2010

Mohammad Al-Turany, Hades Meeting

CPU ¡vs ¡GPU ¡code

¡do ¡{ ¡ ¡ ¡ ¡ rest ¡ ¡= ¡step ¡-­‑ ¡tl; ¡ ¡ ¡ ¡ if ¡(TMath::Abs(h) ¡> ¡TMath::Abs(rest)) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡h ¡= ¡rest; ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ fMagField-­‑>GetFieldValue( ¡vout, ¡f); ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡f[0] ¡= ¡-­‑1.0*f[0]; ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡f[1] ¡= ¡-­‑1.0*f[1]; ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡f[2] ¡= ¡-­‑1.0*f[2]; ……….. if ¡(step ¡< ¡0.) ¡rest ¡= ¡-­‑rest; ¡ ¡ ¡ ¡ if ¡(rest ¡< ¡1.e-­‑5*TMath::Abs(step)) ¡return; ¡ ¡ } ¡while(1); ¡do ¡{ ¡ ¡ ¡ ¡ rest ¡ ¡= ¡step ¡-­‑ ¡tl; ¡ ¡ ¡ ¡ if ¡(fabs(h) ¡> ¡fabs(rest)) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡h ¡= ¡rest; ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ field=GetField(vout[0],vout[1],vout[2]); ¡ ¡ ¡ ¡ ¡f[0] ¡= ¡-­‑field.x; ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡f[1] ¡= ¡-­‑field.y; ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡f[2] ¡= ¡-­‑field.z; ……….. ¡if ¡(step ¡< ¡0.) ¡rest ¡= ¡-­‑rest; ¡ ¡ ¡ ¡if ¡(rest ¡< ¡1.e-­‑5*fabs(step)) ¡return; ¡ ¡ } ¡while(1);

55

Friday, March 26, 2010

slide-94
SLIDE 94

26.03.2010

Mohammad Al-Turany, Hades Meeting

Panda ¡Detector

56

Friday, March 26, 2010

slide-95
SLIDE 95

26.03.2010

Mohammad Al-Turany, Hades Meeting

Magnet ¡and ¡Field

57

Friday, March 26, 2010

slide-96
SLIDE 96

26.03.2010

Mohammad Al-Turany, Hades Meeting

Field ¡Map

¡Field ¡map ¡grid ¡: ¡Bx, ¡By, ¡Bz

 ¡x ¡= ¡0.0 ¡to ¡ ¡ ¡ ¡ ¡ ¡ ¡158 ¡ ¡ ¡ ¡cm, ¡ ¡ ¡80 ¡ ¡ ¡ ¡points, ¡ ¡Δx ¡= ¡2.0 ¡cm  ¡y ¡= ¡0.0 ¡to ¡ ¡ ¡ ¡ ¡ ¡ ¡51 ¡ ¡ ¡ ¡ ¡ ¡cm, ¡ ¡ ¡52 ¡ ¡ ¡ ¡ ¡points, ¡ ¡Δy ¡= ¡1.0 ¡cm  ¡z ¡= ¡342.0 ¡to ¡ ¡ ¡602 ¡ ¡ ¡cm, ¡ ¡131 ¡ ¡ ¡ ¡points, ¡ ¡Δz ¡= ¡2.0 ¡cm

4-­‑fold ¡ ¡symmetry ¡

58

Friday, March 26, 2010

slide-97
SLIDE 97

26.03.2010

Mohammad Al-Turany, Hades Meeting

Cards ¡used ¡in ¡this ¡Test

Qaudro ¡NVS ¡ ¡ 290 ¡ GeForce 8400 ¡GT GeForce 8800 ¡GT Tesla ¡C1060 CUDA ¡ ¡cores

16 ¡(2 ¡x ¡8) 32 ¡(4 ¡x ¡8) 112 ¡(14 ¡x ¡8) 240 ¡(30 ¡x ¡8)

Memory ¡(MB)

¡256 128 ¡ 512 ¡ ¡4000

Frequency ¡of ¡processor ¡cores ¡ (GHz)

0.92 0.94 ¡ 1.5 1.3

Compute ¡capability ¡

1.1 1.1 1.1 1.3

Warps/MulMprocessor

24 24 24 32

  • Max. ¡No. ¡of ¡threads

1536 3072 10752 30720

Max ¡Power ¡ConsumpMon ¡(W)

21 ¡ 71 ¡ 105 ¡ 200 ¡

59

Friday, March 26, 2010

slide-98
SLIDE 98

26.03.2010

Mohammad Al-Turany, Hades Meeting

Features ¡available ¡only ¡in ¡1.3 ¡compu.ng ¡capabili.es ¡

 Support ¡for ¡atomic ¡funcMons ¡operaMng ¡in ¡shared ¡memory ¡

and ¡on ¡64-­‑bit ¡words ¡in ¡global ¡memory ¡(for ¡1.1 ¡only ¡32-­‑bit ¡ words)

 Support ¡for ¡warp ¡vote ¡funcMons  The ¡number ¡of ¡registers ¡per ¡mulMprocessor ¡is ¡16384 ¡(8192 ¡

in ¡1.1)

 The ¡maximum ¡number ¡of ¡acMve ¡warps ¡per ¡mulMprocessor ¡is ¡

32 ¡(24 ¡in ¡1.1)

 The ¡maximum ¡number ¡of ¡acMve ¡threads ¡per ¡mulMprocessor ¡

is ¡1024 ¡(768 ¡in ¡1.1)

 Support ¡for ¡double-­‑precision ¡floaMng-­‑point ¡numbers

60

Friday, March 26, 2010

slide-99
SLIDE 99

26.03.2010

Mohammad Al-Turany, Hades Meeting

Track ¡PropagaMon ¡(Mme ¡per ¡event)

Trk/ Event CPU GPU emu Quadro NVS ¡290 (16) GeForce 8400GT (32) GeForce 8800 ¡GT (112) Tesla C1060 (240)

10 ¡ 2.4 1.9 0.9 0.8 0.7 0.4 50 11 7 2.5 1.8 1.0 0.4 100 21 16 4.4 2.9 1.7 0.5 200 42 25 8.9 5.6 2.9 0.9 500 104 86 23 13.2 5.6 1.3 1000 210 177 42 25.7 10.1 1.9 2000 412 356 82 52.2 19.5 3.0 5000 1054 886 200 125 50.0 6.0

61

Time in ms needed to propagate all tracks in event

Friday, March 26, 2010

slide-100
SLIDE 100

26.03.2010

Mohammad Al-Turany, Hades Meeting

Track ¡PropagaMon ¡(Mme ¡per ¡track)

Trk/ Event CPU GPU emu Quadro NVS ¡290 (16) GeForce 8400GT (32) GeForce 8800 ¡GT (112) Tesla C1060 (240)

10 ¡ 240 190 90 80 70 40 50 220 140 50 36 20 8.0 100 210 160 44 29 17 5.0 200 210 125 45 28 15 4.3 500 208 172 46 26 11 2.6 1000 210 177 42 26 10 1.9 2000 206 178 41 26 10 1.5 5000 211 177 40 25 10 1.2

62

Time in µs needed to propagate one track 1.5 m in a dipole field

Friday, March 26, 2010

slide-101
SLIDE 101

26.03.2010

Mohammad Al-Turany, Hades Meeting

Time ¡needed ¡to ¡analyze ¡one ¡event ¡in ¡ms

0.1 1.0 10.0 100.0 1000.0 10000.0 10 100 1000 10000 CPU GPU-­‑EMU NVS ¡290 8400 ¡GT 8800 ¡GT Tesla

63

Time (ms) Tracks/Event

Friday, March 26, 2010

slide-102
SLIDE 102

26.03.2010

Mohammad Al-Turany, Hades Meeting

Speedup ¡on ¡different ¡cards

0E+00 5E+01 1E+02 2E+02 2E+02 10 5000

64

Trk/Event GPU emu NVS ¡ 290 8400 GT 8800 ¡ GT Tesla

10 ¡ 1.30 3 3 3.5 6 50 1.60 4.4 6 11 28 100 1.30 4.8 7.3 12.3 47 200 1.70 4.8 7.5 14.5 49 500 1.20 4.5 7.9 18.5 80 1000 1.20 5 8.1 21 111 2000 1.10 5 8 21 137 5000 1.20 5 8.4 21 175 CPU/GPU time Track/Event

GPU-­‑EMU NVS ¡290 8400 ¡GT 8800 ¡GT Tesla

Friday, March 26, 2010

slide-103
SLIDE 103

26.03.2010

Mohammad Al-Turany, Hades Meeting

EmulaMon ¡Mode

¡ ¡ ¡ ¡When ¡running ¡an ¡applicaMon ¡in ¡device ¡emulaMon ¡mode, ¡the ¡ programming ¡model ¡is ¡emulated ¡by ¡the ¡runMme. ¡For ¡each ¡thread ¡ in ¡a ¡thread ¡block, ¡the ¡runMme ¡creates ¡a ¡thread ¡on ¡the ¡host. ¡The ¡ programmer ¡needs ¡to ¡make ¡sure ¡that:

 The ¡host ¡is ¡able ¡to ¡run ¡up ¡to ¡the ¡maximum ¡number ¡of ¡threads ¡per ¡block, ¡

plus ¡one ¡for ¡the ¡master ¡thread.

 Enough ¡memory ¡is ¡available ¡to ¡run ¡all ¡threads, ¡knowing ¡that ¡each ¡thread ¡

gets ¡256 ¡KB ¡of ¡stack. ¡

65

Friday, March 26, 2010

slide-104
SLIDE 104

26.03.2010

Mohammad Al-Turany, Hades Meeting

EmulaMon ¡Mode

 In ¡this ¡example ¡we ¡have ¡8 ¡threads ¡per ¡block

 Data ¡is ¡copied ¡from ¡global ¡(or ¡Host) ¡Memory ¡by ¡8 ¡threads  One ¡thread ¡perform ¡the ¡propagaMon

 On ¡4 ¡core ¡machine ¡the ¡system ¡can ¡start ¡9 ¡threads ¡  In ¡the ¡CPU ¡naMve ¡code ¡each ¡Mme ¡one ¡get ¡the ¡field ¡value ¡

we ¡have ¡to ¡check ¡for ¡the ¡boundary, ¡but ¡the ¡GPU ¡code ¡do ¡ not ¡need ¡this ¡check

 This ¡explain ¡the ¡speed ¡up ¡in ¡emulaMon ¡mode ¡against ¡the ¡naMve ¡CPU ¡

code.

66

Friday, March 26, 2010