Halide (programming language): Difference between revisions

Content deleted Content added
Added {{refimprove}} tag to article (TW)
Citation bot (talk | contribs)
Alter: title, template type. Add: chapter-url-access, chapter-url, chapter, authors 1-1. Removed or converted URL. Removed parameters. Some additions/deletions were parameter name changes. | Use this bot. Report bugs. | Suggested by Headbomb | #UCB_toolbar
 
(26 intermediate revisions by 16 users not shown)
Line 1:
{{Short description|Computer programming language designed for digital image processing}}
{{refimprove|date=March 2018}}
{{Infobox programming language
| name = Halide
| logo =
| logo caption =
| paradigm paradigms = [[Functional programming|functional]], [[Parallel programming model|parallel]]
| file_ext =
| designer = Jonathan Ragan-Kelley and <br/>Andrew Adams
| paradigm = [[Functional programming|functional]], [[Parallel programming model|parallel]]
| developer = [[Massachusetts Institute of Technology|MIT]], (with help from [[Stanford University|Stanford]], and[[Google]], [[Adobe Systems|Adobe]])
| year = 2012
| released = {{Start date and age|2012}}
| designer = Jonathan Ragan-Kelley and Andrew Adams
| latest release version =
| developer = [[Massachusetts Institute of Technology|MIT]], (with help from [[Stanford University|Stanford]] and [[Adobe Systems|Adobe]])
| latest release date =
| latest_release_version =
| latest test version =
| latest_release_date =
| latest test date =
| latest_test_version =
| typing = [[Static typing|static]]
| latest_test_date =
| implementations =
| typing = [[Static typing|static]]
| dialects =
| implementations =
| programming language = [[C++]]
| dialects =
| operating_system operating system = Mac OS X (10.6 through 10.8)[[macOS]], mainstream [[Linux]] distributions, [[Windows]]
| influenced_by =
| file ext =
| influenced =
| programming_language license = [[C++MIT License]]
| website = http://{{URL|halide-lang.org/}}
| operating_system = Mac OS X (10.6 through 10.8), mainstream Linux distributions, Windows
| wikibooks =
| license =
| influenced by =
| website = http://halide-lang.org/
| influenced =
| wikibooks =
}}
{{Portal|Free and open-source software}}
'''Halide''' is a computer [[programming language]] designed for writing [[digital image processing]] code that takes advantage of [[memory locality]], [[Array programming|vectorized computation]] and multi-core [[central processing unit]]s (CPU) and [[graphics processing unit]]s (GPU). Halide is implemented as an internal [[___domain-specific language]] (DSL) in [[C++]]. Halide was announced by MIT in 2012<ref>{{Cite web |last=Hardesty |first=Larry |date=2012-08-02 |title=Writing graphics software gets much easier |url=https://news.mit.edu/2012/better-programming-language-for-image-processing-0802 |access-date=2025-06-30 |website=MIT News {{!}} Massachusetts Institute of Technology |language=en}}</ref> and released in 2013.<ref>{{Cite book |last1=Ragan-Kelley |first1=Jonathan |last2=Barnes |first2=Connelly |last3=Adams |first3=Andrew |last4=Paris |first4=Sylvain |last5=Durand |first5=Frédo |last6=Amarasinghe |first6=Saman |chapter=Halide: A language and compiler for optimizing parallelism, locality, and recomputation in image processing pipelines |date=2013-06-16 |title=Proceedings of the 34th ACM SIGPLAN Conference on Programming Language Design and Implementation |chapter-url=https://dl.acm.org/doi/10.1145/2491956.2462176 |series=PLDI '13 |___location=New York, NY, USA |publisher=Association for Computing Machinery |pages=519–530 |doi=10.1145/2491956.2462176 |isbn=978-1-4503-2014-6|chapter-url-access=subscription }}</ref>
 
==Purpose==
'''Halide''' is a computer [[programming language]] designed for writing [[digital image processing]] code that takes advantage of memory locality, vectorized computation and multi-core CPUs and GPUs.<ref name="refsite1"/> Halide is implemented as an internal [[Domain-specific language|DSL]] in C++.
The main innovation Halide brings is the separation of the [[algorithm]] being implemented from its [[scheduling (computing)|execution schedule]], i.e. code specifying the [[loop (computing)|loop]] [[nesting (computing)|nesting]], [[parallelization]], [[loop unrolling]] and [[vector processor|vector instruction]].<ref>{{Cite journal |last1=Ragan-Kelley |first1=Jonathan |last2=Adams |first2=Andrew |last3=Sharlet |first3=Dillon |last4=Barnes |first4=Connelly |last5=Paris |first5=Sylvain |last6=Levoy |first6=Marc |last7=Amarasinghe |first7=Saman |last8=Durand |first8=Frédo |date=2017-12-27 |title=Halide: decoupling algorithms from schedules for high-performance image processing |url=https://dl.acm.org/doi/10.1145/3150211 |journal=Commun. ACM |volume=61 |issue=1 |pages=106–115 |doi=10.1145/3150211 |issn=0001-0782}}</ref> 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.<ref>{{Cite web |last=Hinkel |first=Lauren |date=2024-05-03 |title=Creating bespoke programming languages for efficient visual AI systems |url=https://news.mit.edu/2024/creating-bespoke-programming-languages-efficient-visual-ai-systems-0503 |access-date=2025-06-30 |website=MIT News {{!}} Massachusetts Institute of Technology |language=en |quote=Ragan-Kelley notes that programmers can opt for “very painstaking, very unproductive, and very unsafe low-level code,” which could introduce bugs, or “more safe, more productive, higher-level programming interfaces,” that lack the ability to make fine adjustments in a compiler about how the program is run, and usually deliver lower performance. So, his team is trying to find a middle ground. “We're trying to figure out how to provide control for the key issues that human performance engineers want to be able to control,” says Ragan-Kelley, “so, we're trying to build a new class of languages that we call user-schedulable languages that give safer and higher-level handles to control what the compiler does or control how the program is optimized.”}}</ref> With Halide, changing the schedule does not require any changes to the algorithm, allowing the programmer to experiment with scheduling.<ref name=":0">{{Cite journal |last1=Adams |first1=Andrew |last2=Ma |first2=Karima |last3=Anderson |first3=Luke |last4=Baghdadi |first4=Riyadh |last5=Li |first5=Tzu-Mao |last6=Gharbi |first6=Michaël |last7=Steiner |first7=Benoit |last8=Johnson |first8=Steven |last9=Fatahalian |first9=Kayvon |last10=Durand |first10=Frédo |last11=Ragan-Kelley |first11=Jonathan |date=2019-07-12 |title=Learning to optimize halide with tree search and random programs |url=https://dl.acm.org/doi/10.1145/3306346.3322967 |journal=ACM Trans. Graph. |volume=38 |issue=4 |pages=121:1–121:12 |doi=10.1145/3306346.3322967 |issn=0730-0301|url-access=subscription }}</ref><ref>{{Cite web |last=Gottschlich |first=Justin |date=22 November 2019 |title=Machine Programming: What Lies Ahead? |url=https://knowledge.wharton.upenn.edu/article/ai-machine-learning/ |access-date=2025-06-30 |website=Knowledge at Wharton |language=en-US}}</ref>
 
== Scheduled blur function ==
The main innovation Halide brings is the separation of the [[algorithm]] being implemented from its [[Scheduling (computing)|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.
The following function defines and sets the schedule for a 3×3 [[box blur|box filter]] defined as a series of two 3×1 passes, allowing the blur algorithm to remain independent of the execution schedule.<ref name=":1">{{Cite book |last1=Hennessy |first1=John L. |title=Computer architecture: a quantitative approach |last2=Patterson |first2=David A. |date=2019 |publisher=Morgan Kaufmann Publishers |isbn=978-0-12-811905-1 |edition=6th |___location=Cambridge, MA |pages=582}}</ref>
 
<sourcesyntaxhighlight lang="cpp">
== Sample source code ==
The following function defines and sets the schedule for a 3x3 [[Box blur|box filter]] defined as a series of two 3x1 passes:
<source lang="cpp">
Func blur_3x3(Func input) {
Func blur_x, blur_y;
Line 47 ⟶ 48:
return blur_y;
}
</syntaxhighlight>
</source>
 
==Uses and development==
Halide was developed primarily at MIT's CSAIL lab. Both Google and Adobe have been involved in Halide research.<ref name=":0" /> Google uses Halide in Pixel 2's [[Pixel Visual Core]].<ref>{{cite web |last=Quach |first=Katyanna |date=22 October 2017 |title=Google and Intel cook AI chips, neural network exchanges – and more |url=https://www.theregister.co.uk/2017/10/22/ai_roundup/ |website=[[The Register]] |publisher=Situation Publishing}}</ref><ref name=":1" /> Adobe Photoshop also uses Halide.<ref>{{Cite web |title=Inside Halide, the open source language engineers use to make imaging tools faster |url=https://research.adobe.com/news/inside-halide-the-open-source-language |access-date=2025-06-30 |website=Adobe Research |language=en-US}}</ref>
 
== See also ==
Line 55 ⟶ 59:
 
== References ==
{{Reflist|30em|refs=}}
<!--- After listing your sources please cite them using inline citations and place them after the information they cite. Please see http://en.wikipedia.org/wiki/Wikipedia:REFB for instructions on how to add citations. --->
<ref name="refsite1">{{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 |accessdate=20 September 2013}}</ref>
}}
 
== External links ==
* [http://halide-lang.org/{{Official http://website|halide-lang.org/]}}
* {{GitHub|halide/Halide}}
* [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 }}&nbsp;{{small|(8,259&nbsp;KB)}}
 
[[Category:Image processing]]