Halide (programming language)
{{More citations needed|date=March 2018}}
{{Infobox programming language
| name = Halide
| logo =
| logo caption =
| paradigms = functional, parallel
| designer = Jonathan Ragan-Kelley
Andrew Adams
| developer = MIT, (with help from Stanford, Google, Adobe)
| released = {{Start date and age|2012}}
| latest release version =
| latest release date =
| latest test version =
| latest test date =
| typing = static
| implementations =
| dialects =
| programming language = C++
| operating system = macOS, mainstream Linux distributions, Windows
| file ext =
| license = MIT License
| website = {{URL|halide-lang.org}}
| wikibooks =
| influenced by =
| influenced =
}}
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).{{cite web |url=http://www.i-programmer.info/news/192-photography-a-imaging/4588-halide-new-language-for-image-processing.html | title=Halide: New Language For Image Processing |year=2012 |access-date=20 September 2013}} Halide is implemented as an internal domain-specific language (DSL) in C++.
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. 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.
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.{{cite web|url=https://www.theregister.co.uk/2017/10/22/ai_roundup/|title=Google and Intel cook AI chips, neural network exchanges – and more|publisher=Situation Publishing|website=The Register}} Adobe Photoshop also uses Halide.{{cite web |url=https://community.adobe.com/t5/photoshop/photoshop-freezing-at-startup-on-halide-bottlenecks/td-p/11085284?page=1 | title=Photoshop freezing at startup on Halide Bottlenecks |year=2020 |accessdate=27 April 2020}} Both Google and Adobe have been involved in Halide research.{{cite web |url=https://halide-lang.org/papers/halide_autoscheduler_2019.pdf | title=Learning to Optimize Halide with Tree Search and Random Programs |year=2019 |accessdate=1 July 2019}}
See also
References
{{Reflist}}
External links
- {{Official website|halide-lang.org}}
- [http://people.csail.mit.edu/jrk/halide12 Decoupling Algorithms from Schedules for Easy Optimization of Image Processing Pipelines]
- {{cite web |url= http://people.csail.mit.edu/jrk/halide-pldi13.pdf |title=Halide: A Language and Compiler for Optimizing Parallelism, Locality, and Recomputation in Image Processing Pipelines}} (8,259 KB)