Jump to content

Halide (programming language)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 2405:204:e389:a932::1e7f:20a4 (talk) at 13:44, 16 December 2017. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

agan-Kelley and Andrew Adams | developer = MIT, (with help from Stanford and Adobe) | latest_release_version = | latest_release_date = | latest_test_version = | latest_test_date = | typing = static | implementations = | dialects = | influenced_by = | influenced = | programming_language = C++ | operating_system = Mac OS X (10.6 through 10.8), mainstream Linux distributions, Windows | license = | website = http://halide-lang.org/ | wikibooks = }}

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.[1] Halide is implemented as an internal DSL in C++.

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 3x3 box filter defined as a series of two 3x1 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;
}

See also

References

  1. ^ "Halide - New Language For Image Processing". 2012. Retrieved 20 September 2013.