Halide (programming language)
Halide | |
---|---|
Paradigms | functional, parallel |
Designed by | Jonathan Ragan-Kelley Andrew Adams |
Developer | MIT, (with help from Stanford, Google, Adobe) |
First appeared | 2012 |
Typing discipline | static |
Implementation language | C++ |
OS | macOS, mainstream Linux distributions, Windows |
License | MIT License |
Website | halide-lang |
Halide is a computer programming language designed for writing digital image processing code that takes advantage of memory locality, vectorized computation and multi-core central processing units (CPU) and graphics processing units (GPU).[1] Halide is implemented as an internal domain-specific language (DSL) in C++. Halide was announced by MIT in 2012[2] and released in 2013.[3]
Language
The main innovation Halide brings is the separation of the algorithm being implemented from its execution schedule, i.e. code specifying the loop nesting, parallelization, loop unrolling and vector instruction.[4] These two are usually interleaved together and experimenting with changing the schedule requires the programmer to rewrite large portions of the algorithm with every change. With Halide, changing the schedule does not require any changes to the algorithm and this allows the programmer to experiment with scheduling and finding the most efficient one.[5]
Sample source code
The following function defines and sets the schedule for a 3×3 box filter defined as a series of two 3×1 passes:
Func blur_3x3(Func input) {
Func blur_x, blur_y;
Var x, y, xi, yi;
// The algorithm - no storage or order
blur_x(x, y) = (input(x-1, y) + input(x, y) + input(x+1, y))/3;
blur_y(x, y) = (blur_x(x, y-1) + blur_x(x, y) + blur_x(x, y+1))/3;
// The schedule - defines order, locality; implies storage
blur_y.tile(x, y, xi, yi, 256, 32)
.vectorize(xi, 8).parallel(y);
blur_x.compute_at(blur_y, x).vectorize(x, 8);
return blur_y;
}
Use
Google used Halide and TensorFlow for its Pixel 2 Pixel Visual Core.[6] Adobe Photoshop also uses Halide.[7] Both Google and Adobe have been involved in Halide research.[8]
See also
References
- ^ "Halide: New Language For Image Processing". 2012. Retrieved 20 September 2013.
- ^ Hardesty, Larry (2012-08-02). "Writing graphics software gets much easier". MIT News | Massachusetts Institute of Technology. Retrieved 2025-06-30.
- ^ Ragan-Kelley, Jonathan; Barnes, Connelly; Adams, Andrew; Paris, Sylvain; Durand, Frédo; Amarasinghe, Saman (2013-06-16). "Halide: a language and compiler for optimizing parallelism, locality, and recomputation in image processing pipelines". Proceedings of the 34th ACM SIGPLAN Conference on Programming Language Design and Implementation. PLDI '13. New York, NY, USA: Association for Computing Machinery: 519–530. doi:10.1145/2491956.2462176. ISBN 978-1-4503-2014-6.
- ^ Ragan-Kelley, Jonathan; Adams, Andrew; Sharlet, Dillon; Barnes, Connelly; Paris, Sylvain; Levoy, Marc; Amarasinghe, Saman; Durand, Frédo (2017-12-27). "Halide: decoupling algorithms from schedules for high-performance image processing". Commun. ACM. 61 (1): 106–115. doi:10.1145/3150211. ISSN 0001-0782.
- ^ Adams, Andrew; Ma, Karima; Anderson, Luke; Baghdadi, Riyadh; Li, Tzu-Mao; Gharbi, Michaël; Steiner, Benoit; Johnson, Steven; Fatahalian, Kayvon; Durand, Frédo; Ragan-Kelley, Jonathan (2019-07-12). "Learning to optimize halide with tree search and random programs". ACM Trans. Graph. 38 (4): 121:1–121:12. doi:10.1145/3306346.3322967. ISSN 0730-0301.
- ^ "Google and Intel cook AI chips, neural network exchanges – and more". The Register. Situation Publishing.
- ^ "Photoshop freezing at startup on Halide Bottlenecks". 2020. Retrieved 27 April 2020.
- ^ "Learning to Optimize Halide with Tree Search and Random Programs" (PDF). 2019. Retrieved 1 July 2019.