AnyDSL

AnyDSL

AnyDSL - A Partial Evaluation Framework for Programming High-Performance Libraries

AnyDSL is a framework for domain-specific libraries (DSLs). These are implemented in our language Impala. In order to achieve high-performance, Impala partially evaluates any abstractions these libraries might impose. Partial evaluation and other optimizations are performed on AnyDSL’s intermediate representation Thorin.

AnyDSL Architecture

AnyDSL Architecture

Embedding of DSLs in Impala

When developing a DSL, people from different areas come together:

AnyDSL allows a separation of these concerns using

Application Developer

fn main() {
    let img = load("dragon.png");
    let blurred = gaussian_blur(img);
}

DSL Designer

fn gaussian_blur(field: Field) -> Field {
    let stencil: Stencil = { /* ... */ };
    let mut out: Field   = { /* ... */ };

    for x, y in @iterate(out) {
        out.data(x, y) = apply_stencil(x, y, field, stencil);
    }

    out
}

Machine Expert

fn iterate(field: Field, body: fn(int, int) -> ()) -> () {
    let grid  = (field.cols, field.rows, 1);
    let block = (128, 1, 1);

    with nvvm(grid, block) {
        let x = nvvm_tid_x() + nvvm_ntid_x() * nvvm_ctaid_x();
        let y = nvvm_tid_y() + nvvm_ntid_y() * nvvm_ctaid_y();
        body(x, y);
    }
}

Selected Results

Stincilla: https://github.com/anydsl/stincilla

Stincilla is a DSL for stencil codes. We used the Gaussian blur filter as example and compared against the implementations in OpenCV 3.0 as reference. Thereby, we achieved the following results:

RaTrace: https://github.com/anydsl/traversal

RaTrace is a DSL for ray traversal.