efficient image processing with halide
TRANSCRIPT
![Page 1: Efficient Image Processing with Halide](https://reader033.vdocuments.us/reader033/viewer/2022042700/5597a53d1a28ab26618b4599/html5/thumbnails/1.jpg)
Efficient Image Processing with Halide Presented by Adrián Palacios
![Page 2: Efficient Image Processing with Halide](https://reader033.vdocuments.us/reader033/viewer/2022042700/5597a53d1a28ab26618b4599/html5/thumbnails/2.jpg)
Introduction
• Image processing is a topic where optimization matters.
• But optimization for multiple platforms is hard and expensive.
• We want tools for obtaining high-performance code regardless of the platform.
• Halide is a tool that aims to solve this problem.
![Page 3: Efficient Image Processing with Halide](https://reader033.vdocuments.us/reader033/viewer/2022042700/5597a53d1a28ab26618b4599/html5/thumbnails/3.jpg)
Data-parallel and IP languages
• Data-parallel languages: • CUDA and OpenCL propose a SIMD
programming model for multi-core CPUs and GPUs.
• Implementations can be very efficient at the cost of losing portability.
• IP languages: • MATLAB and other suites release kernel
languages.
• But individual kernels are not enough.
![Page 4: Efficient Image Processing with Halide](https://reader033.vdocuments.us/reader033/viewer/2022042700/5597a53d1a28ab26618b4599/html5/thumbnails/4.jpg)
Concretely, the problem is…
![Page 5: Efficient Image Processing with Halide](https://reader033.vdocuments.us/reader033/viewer/2022042700/5597a53d1a28ab26618b4599/html5/thumbnails/5.jpg)
And the solution is…
![Page 6: Efficient Image Processing with Halide](https://reader033.vdocuments.us/reader033/viewer/2022042700/5597a53d1a28ab26618b4599/html5/thumbnails/6.jpg)
The Halide language
• Halide is a functional programming language (“à la Haskell”) for IP.
• It makes a distinction between the algorithm and the schedule:
• The algorithm is what should be done.
• The schedule is how it should be done.
• Optimization is achieved by:
• Using LLVM for generating simple code.
• Using architecture-specific compilers for generating vectorized and parallel code.
![Page 7: Efficient Image Processing with Halide](https://reader033.vdocuments.us/reader033/viewer/2022042700/5597a53d1a28ab26618b4599/html5/thumbnails/7.jpg)
Evaluation of Halide
• Halide’s execution time is measured against: • ImageMagick.
• MATLAB.
• Mathematica.
• OpenCV 2.
• Two test images: • A normal sized image (512x512).
• A big sized image (6400x4800).
• For two methods: • RGB to grayscale.
• Gaussian blur.
![Page 8: Efficient Image Processing with Halide](https://reader033.vdocuments.us/reader033/viewer/2022042700/5597a53d1a28ab26618b4599/html5/thumbnails/8.jpg)
RGB to grayscale
![Page 9: Efficient Image Processing with Halide](https://reader033.vdocuments.us/reader033/viewer/2022042700/5597a53d1a28ab26618b4599/html5/thumbnails/9.jpg)
RGB to grayscale results Normal sized image Time (ms) Time / Halide Time (%)
Halide 8.486 1.000
ImageMagick 64.000 7.542
MATLAB 10.359 1.221
Mathematica 13.000 1.532
OpenCV 2 0.577 0.067
Big sized image Time (ms) Time / Halide Time (%)
Halide 188.829 1.000
ImageMagick 1748 9.257
MATLAB 192.501 1.019
Mathematica 1586 8.399
OpenCV 2 76.626 0.405
![Page 10: Efficient Image Processing with Halide](https://reader033.vdocuments.us/reader033/viewer/2022042700/5597a53d1a28ab26618b4599/html5/thumbnails/10.jpg)
Gaussian blur
![Page 11: Efficient Image Processing with Halide](https://reader033.vdocuments.us/reader033/viewer/2022042700/5597a53d1a28ab26618b4599/html5/thumbnails/11.jpg)
Gaussian blur results Normal sized image Time (ms) Time / Halide Time (%)
Halide 2.674 1.000
ImageMagick 304.000 113.687
MATLAB 2.834 1.059
Mathematica 117.003 43.755
OpenCV 2 1.076 0.402
Big sized image Time (ms) Time / Halide Time (%)
Halide 219.274 1.000
ImageMagick 12265 55.935
MATLAB 277.388 1.265
Mathematica 199203 908.466
OpenCV 2 191.875 0.875
![Page 12: Efficient Image Processing with Halide](https://reader033.vdocuments.us/reader033/viewer/2022042700/5597a53d1a28ab26618b4599/html5/thumbnails/12.jpg)
Conclusions
• Halide beats each other tool (except OpenCV 2).
• There’s a lot of room for improvement.
• Programming with Halide is hard-to-learn, easy-to-master.
![Page 13: Efficient Image Processing with Halide](https://reader033.vdocuments.us/reader033/viewer/2022042700/5597a53d1a28ab26618b4599/html5/thumbnails/13.jpg)
Questions?
• Halide’s repository at Github:
• https://github.com/halide/Halide