Methodology for mapping image processing algorithms on massively - - PowerPoint PPT Presentation

methodology for mapping image processing algorithms on
SMART_READER_LITE
LIVE PREVIEW

Methodology for mapping image processing algorithms on massively - - PowerPoint PPT Presentation

Methodology for mapping image processing algorithms on massively parallel processors An NVIDIA GPU specific approach Florian Gouin Corinne Ancourt firstname.name@mines-paristech.fr MINES ParisTech PSL Research University, Paris Centre de


slide-1
SLIDE 1

Methodology for mapping image processing algorithms on massively parallel processors

An NVIDIA GPU specific approach

Florian Gouin Corinne Ancourt firstname.name@mines-paristech.fr

MINES ParisTech – PSL Research University, Paris Centre de Recherche en Informatique

22/06/2017

French community of compilation – 12th meeting – Saint Germain au Mont d’Or

slide-2
SLIDE 2

Context and motivation Application case Mapping methodology Experiments Conclusion Motivation

Image processing domain

Figure: Image processing examples

2/28

slide-3
SLIDE 3

Context and motivation Application case Mapping methodology Experiments Conclusion Motivation

Image processing domain

General tendances for today and tomorrow: Data source volume is growing exponentially Data sources tend to be multiplied Available computing time tends to be shorter for real time processing Image processing algorithms are even more complex

3/28

slide-4
SLIDE 4

Context and motivation Application case Mapping methodology Experiments Conclusion Motivation

Architectural evolution

Figure: NVIDIA Kepler processor – 192

cores architecture

Figure: Processor frequency wall

SISD MISD SIMD MIMD SIMT Instructions Data

Figure: Flynn’s taxonomy

4/28

slide-5
SLIDE 5

Context and motivation Application case Mapping methodology Experiments Conclusion Motivation

Why do we need a methodology?

Parallel thinking is not trivial. The following methodology has been elaborated to provide: an assistance for GPU developpers, an improvement of software production for industries, a support for other domain engineers, an assistance to optimise software for a specific GPU architecture. Tools and compilers results can be limited in some cases: dynamic control code intensive function calls pointers arithmetic

  • bject oriented languages

...

5/28

slide-6
SLIDE 6

Context and motivation Application case Mapping methodology Experiments Conclusion

Content

1

Application case

6/28

slide-7
SLIDE 7

Context and motivation Application case Mapping methodology Experiments Conclusion

Content

1

Application case

2

Mapping methodology

6/28

slide-8
SLIDE 8

Context and motivation Application case Mapping methodology Experiments Conclusion

Content

1

Application case

2

Mapping methodology

3

Experiments

6/28

slide-9
SLIDE 9

Context and motivation Application case Mapping methodology Experiments Conclusion

Content

1

Application case

2

Mapping methodology

3

Experiments

4

Conclusion

6/28

slide-10
SLIDE 10

Context and motivation Application case Mapping methodology Experiments Conclusion Optical Flow algorithms

Optical Flow: definition

Principle: Motion quantification of each pixel taken from two distinct pictures. Image processing application: spatial characterization temporal characterization Examples of applications: Motion estimation Image stabilization Image segmentation Moving object tracking SLAM algorithms ...

7/28

slide-11
SLIDE 11

Context and motivation Application case Mapping methodology Experiments Conclusion Optical Flow algorithms

Optical Flow: industrial application example

Figure: Example of motion flow analysis. Tesla Motor Company automatic drive.

8/28

slide-12
SLIDE 12

Context and motivation Application case Mapping methodology Experiments Conclusion SimpleFlow algorithm

Algorithm data

The SimpleFlow1 algorithm is available in the OpenCV extensions. Approximatively 600 lines of code Sequential algorithm Dynamic control code Approximative runtime for a couple of 2 million pixels images:

200s on a NVIDIA Jetson TX1

ARM Cortex A57(1.9GHz) + A53(1.3GHz)

50s on a desktop computer

Intel Core I7 4770S (8 logical cores at 3.1GHz)

Ideal runtime: 40ms

Language and library: C++ with the OpenCV library

1Michael W. Tao et al. “SimpleFlow: A Non-iterative, Sublinear Optical

Flow Algorithm”. In: Computer Graphics Forum (Eurographics 2012) 31.2 (May 2012). url: http://graphics.berkeley.edu/papers/Tao-SAN-2012-05/.

9/28

slide-13
SLIDE 13

Context and motivation Application case Mapping methodology Experiments Conclusion SimpleFlow algorithm

Simplified CallGraph

dist removeOcclusions zeros wd exp wc crossBilateralFilter copyMakeBorder split multiply sum calcConfidence cvRound min calcOpticalFlowSingleScaleSF upscaleOpticalFlow resize calcIrregularityMat max selectPointsToRecalcFlow extrapolateValueInRect extrapolateFlow buildPyramidWithResizeMethod calcOpticalFlowSF

  • nes

GaussianBlur mixChannels

Figure: Simplified call graph. function is simpleflow one, function is

  • penCV one and function comes from the C++ std library

10/28

slide-14
SLIDE 14

Context and motivation Application case Mapping methodology Experiments Conclusion SimpleFlow algorithm

Application example

Figure: Image 1 (t) Figure: X coordinate pixel motions Figure: Image 2 (t + δ) Figure: Y coordinate pixel motions

11/28

slide-15
SLIDE 15

Context and motivation Application case Mapping methodology Experiments Conclusion Overview - Macroscopic scale source code

code analyses code analyses loop nest transformations for SIMT architectures loop optimisations GPU specialisation GPU mapping

CPU+GPU source code 12/28

slide-16
SLIDE 16

Context and motivation Application case Mapping methodology Experiments Conclusion Code analyses source code

code analyses code analyses loop nest transformations for SIMT architectures loop optimisations GPU specialisation GPU mapping

CPU+GPU source code 13/28

slide-17
SLIDE 17

Context and motivation Application case Mapping methodology Experiments Conclusion Code analyses

parallel loops sequential loops application source code executable file Global runtime Function runtime Loop runtime Loop mining Dependance analysis Array accesses analysis Loop iteration analysis Block identification Loop Detection Function call detection Array detection Branch detection compilation profiling

14/28

slide-18
SLIDE 18

Context and motivation Application case Mapping methodology Experiments Conclusion loop nest transformations for SIMT architectures source code

code analyses code analyses loop nest transformations for SIMT architectures loop optimisations GPU specialisation GPU mapping

CPU+GPU source code 15/28

slide-19
SLIDE 19

Context and motivation Application case Mapping methodology Experiments Conclusion loop nest transformations for SIMT architectures

parallel loops sequential loops GPU loop identification

16/28

slide-20
SLIDE 20

Context and motivation Application case Mapping methodology Experiments Conclusion loop nest transformations for SIMT architectures

parallel loops sequential loops GPU loop identification GPU loop pattern

GPU loop pattern

// // // //or ↓ //or ↓ //or ↓ b0 b1 b2 t0 t1 t2

1 ≤ #b ≤ 3 0 ≤ #t ≤ 3

b l

  • c

k s t h r e a d s 16/28

slide-21
SLIDE 21

Context and motivation Application case Mapping methodology Experiments Conclusion loop nest transformations for SIMT architectures

parallel loops sequential loops GPU loop identification GPU loop pattern GPU loop size

GPU loop pattern

// // // //or ↓ //or ↓ //or ↓ b0 b1 b2 t0 t1 t2

1 ≤ #b ≤ 3 0 ≤ #t ≤ 3

b l

  • c

k s t h r e a d s

GPU loop size

  

b = b0 × b1 × b2 b0 < 2147483647 b1 < 65535 b2 < 65535 b ≫ t

      

t = t0 × t1 × t2 t < 1024 t0 < 1024 t1 < 1024 t2 < 64 t%32 = t > 4 × 32 16/28

slide-22
SLIDE 22

Context and motivation Application case Mapping methodology Experiments Conclusion loop nest transformations for SIMT architectures

parallel loops sequential loops GPU loop identification GPU loop pattern GPU loop size GPU memory size

GPU loop pattern

// // // //or ↓ //or ↓ //or ↓ b0 b1 b2 t0 t1 t2

1 ≤ #b ≤ 3 0 ≤ #t ≤ 3

b l

  • c

k s t h r e a d s

GPU loop size

  

b = b0 × b1 × b2 b0 < 2147483647 b1 < 65535 b2 < 65535 b ≫ t

      

t = t0 × t1 × t2 t < 1024 t0 < 1024 t1 < 1024 t2 < 64 t%32 = t > 4 × 32

GPU memory size

Global memoryfootprint < GPUmemory 16/28

slide-23
SLIDE 23

Context and motivation Application case Mapping methodology Experiments Conclusion loop nest transformations for SIMT architectures

parallel loops sequential loops GPU loop identification GPU loop pattern GPU loop size GPU memory size GPU loop nests

GPU loop pattern

// // // //or ↓ //or ↓ //or ↓ b0 b1 b2 t0 t1 t2

1 ≤ #b ≤ 3 0 ≤ #t ≤ 3

b l

  • c

k s t h r e a d s

GPU loop size

  

b = b0 × b1 × b2 b0 < 2147483647 b1 < 65535 b2 < 65535 b ≫ t

      

t = t0 × t1 × t2 t < 1024 t0 < 1024 t1 < 1024 t2 < 64 t%32 = t > 4 × 32

GPU memory size

Global memoryfootprint < GPUmemory 16/28

slide-24
SLIDE 24

Context and motivation Application case Mapping methodology Experiments Conclusion loop nest transformations for SIMT architectures

parallel loops sequential loops GPU loop identification GPU loop pattern GPU loop size GPU memory size GPU loop nests Fusion Fission Tiling InterchangeSplitting Coalescing Strip mining Parallel reduction

X X X X X X X X X X X X

16/28

slide-25
SLIDE 25

Context and motivation Application case Mapping methodology Experiments Conclusion loop nest transformations for SIMT architectures

parallel loops sequential loops GPU loop identification GPU loop pattern GPU loop size GPU memory size GPU loop nests Fusion Fission Tiling InterchangeSplitting Coalescing Strip mining Parallel reduction

X X X X X X X X X X X X

CPU loop nests

16/28

slide-26
SLIDE 26

Context and motivation Application case Mapping methodology Experiments Conclusion Local – global optimisations source code

code analyses code analyses loop nest transformations for SIMT architectures loop optimisations GPU specialisation GPU mapping

CPU+GPU source code 17/28

slide-27
SLIDE 27

Context and motivation Application case Mapping methodology Experiments Conclusion Local – global optimisations

Intra GPU loop nest optimisation

GPU loop nest GPU loop nest Optimisation loop fusion analysis fusion optimisation loop fusion

no yes

GPU loop pattern

// // // //or ↓ //or ↓ //or ↓ b0 b1 b2 t0 t1 t2

I n t r a G P U l

  • p

n e s t

1 ≤ #b ≤ 3 0 ≤ #t ≤ 3

b l

  • c

k s t h r e a d s 18/28

slide-28
SLIDE 28

Context and motivation Application case Mapping methodology Experiments Conclusion Local – global optimisations

Inter GPU loop nest optimisation

GPU loop nest GPU loop nest Optimisation Micro-compilation analysis Kernel optimisation kernel fusion kernel fission

no yes

GPU loop pattern

Inter GPU loop nests

// // // //or ↓ //or ↓ //or ↓ b0 b1 b2 t0 t1 t2 b l

  • c

k s t h r e a d s // // // //or ↓ //or ↓ //or ↓ b0 b1 b2 t0 t1 t2 b l

  • c

k s t h r e a d s 19/28

slide-29
SLIDE 29

Context and motivation Application case Mapping methodology Experiments Conclusion Local – global optimisations

Inter GPU loop nest optimisation

GPU loop nest GPU loop nest Optimisation Micro-compilation analysis Kernel optimisation kernel fusion kernel fission

no yes

GPU loop nest Inter GPU loops block motion Space iteration densification Functions inlining Cuda kernel function outlining Kernel pre-compilation Pseudo assembly code analysis Arithmetic Intensity # Registers

19/28

slide-30
SLIDE 30

Context and motivation Application case Mapping methodology Experiments Conclusion GPU specialisation source code

code analyses code analyses loop nest transformations for SIMT architectures loop optimisations GPU specialisation GPU mapping

CPU+GPU source code 20/28

slide-31
SLIDE 31

Context and motivation Application case Mapping methodology Experiments Conclusion GPU specialisation

GPU loop nest GPU mapping Array access linearisation CPU/GPU comm. identification

  • Comm. placement

21/28

slide-32
SLIDE 32

Context and motivation Application case Mapping methodology Experiments Conclusion GPU specialisation

GPU loop nest GPU mapping Array access linearisation Optimisation Array accesses analysis Array transformation Array to Texture/Surface transformation

no yes

CPU/GPU comm. identification

  • Comm. placement

21/28

slide-33
SLIDE 33

Context and motivation Application case Mapping methodology Experiments Conclusion GPU specialisation

GPU loop nest GPU mapping Array access linearisation Optimisation Array accesses analysis Array transformation Array to Texture/Surface transformation

no yes

CPU/GPU comm. identification

  • Comm. placement

Optimisation Redundant comm. elimination

no yes 21/28

slide-34
SLIDE 34

Context and motivation Application case Mapping methodology Experiments Conclusion GPU specialisation

GPU loop nest GPU mapping Array access linearisation Optimisation Array accesses analysis Array transformation Array to Texture/Surface transformation

no yes

CPU/GPU comm. identification

  • Comm. placement

Optimisation Redundant comm. elimination

no yes

Concurrency Kernel concurrency placement Multi GPU MultiGPU placement GPU/GPU communications identification

yes no yes no 21/28

slide-35
SLIDE 35

Context and motivation Application case Mapping methodology Experiments Conclusion GPU mapping source code

code analyses code analyses loop nest transformations for SIMT architectures loop optimisations GPU specialisation GPU mapping

CPU+GPU source code 22/28

slide-36
SLIDE 36

Context and motivation Application case Mapping methodology Experiments Conclusion GPU mapping

Inter GPU loops block motion Space iteration densification Functions inlining Cuda kernel function outlining Compilation CPU+GPU source code

23/28

slide-37
SLIDE 37

Context and motivation Application case Mapping methodology Experiments Conclusion Summary source code

code analyses loop nest transformations for SIMT architectures loop optimisations GPU specialisation GPU mapping

CPU+GPU source code 24/28

slide-38
SLIDE 38

Context and motivation Application case Mapping methodology Experiments Conclusion Summary source code

code analyses loop nest transformations for SIMT architectures loop optimisations GPU specialisation GPU mapping Kernel validation

CPU+GPU source code runtimes 24/28

slide-39
SLIDE 39

Context and motivation Application case Mapping methodology Experiments Conclusion Summary source code

code analyses loop nest transformations for SIMT architectures loop optimisations GPU specialisation GPU mapping

CPU+GPU source code

Intel Parallel Studio Pluto++ Pluto++ PIPS PIPS PIPS PPCG

24/28

slide-40
SLIDE 40

Context and motivation Application case Mapping methodology Experiments Conclusion

Validation

Methodology features: loop transformations applied:

strip mining, fusion, interchange, parallel reduction, tiling

intra/inter GPU loop nest fusion kernel concurrency, multiGPU multidimensional array to texture/surface transformation CPU/GPU redundant communication elimination CPU/GPU asynchonous communications

25/28

slide-41
SLIDE 41

Context and motivation Application case Mapping methodology Experiments Conclusion

Validation

Two applications benched: Threewise, a local variance computation algorithm

Time complexity: O(N2) → O(N log N) Runtime: [3000ms, 100ms] → 27ms Preserved output results

SimpleFlow algorithm

Global runtime: 50s → 6s Preserved output results

26/28

slide-42
SLIDE 42

Context and motivation Application case Mapping methodology Experiments Conclusion

Contributions

Methodology for GPU

with an optional architectural specialisation, not domain specific (image processing), based on arithmetic intensity metric (roofline model), not language/API specific, industrial application oriented.

Methodology validation:

Threewise, a local variance computation algorithm SimpleFlow algorithm

Criteria developped for methodology driving Optimisation of a GPU parallel reduction pattern2 Micro-compilation analysis developped Many frameworks have been evaluated:

Intel Parallel Studio, PIPS, PPCG, Pluto, ...

2Florian Gouin, Corinne Ancourt, and Christophe Guettier. “Threewise: a

local variance algorithm for GPU”. . In: 19th IEEE International Conference on Computational Science and Engineering (CSE 2016). 2016, pp. 257–262.

27/28

slide-43
SLIDE 43

Context and motivation Application case Mapping methodology Experiments Conclusion

Perspectives

1 Automatize the methodology 2 Benchmark (validation) 3 Extend to signal processing applications 4 Extend to other GPGPU architectures (AMD) 5 Extend to other parallel architectures (Intel Xeon Phi, Kalray

MPPA, ...)

28/28