diderot a parallel domain-specific language for image...

57
Diderot A parallel domain-specific language for image analysis John Reppy University of Chicago September 6, 2010

Upload: others

Post on 06-Sep-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

DiderotA parallel domain-specific language

for image analysis

John Reppy

University of Chicago

September 6, 2010

Page 2: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Introduction

Diderot

Diderot is a cross-discipline project involvingI Scientific visualizationI Programming languages

We are trying to use ideas from programming languages to improve the stateof the art in image-analysis and visualization.

Joint work with Gordon Kindlmann and Lamont Samuels.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 2

Page 3: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Image analysis

Why image analysis is important

Physical object Image data Computationalrepresentation

Imaging Visualization

Analysis

Scientists need tools to extract structure from many kinds of image data.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 3

Page 4: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Image analysis

Image analysis and visualization

I We are interested in a class of algorithms that compute a geometricproperties of some object from imaging data.

I These algorithms compute over a continuous field that is reconstructedfrom discrete data.

Continuous fieldDiscrete image data

September 6, 2010 Diderot A parallel domain-specific language for image analysis 4

Page 5: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Image analysis

Image analysis and visualization (continued ...)

Examples includeI Direct volume rendering (requires

reconstruction, derivatives)I Fiber tractography (requires tensor

fields)I Particle systems

September 6, 2010 Diderot A parallel domain-specific language for image analysis 5

Page 6: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Image analysis

Image analysis and visualization (continued ...)

Examples includeI Direct volume rendering (requires

reconstruction, derivatives)I Fiber tractography (requires tensor

fields)I Particle systems

September 6, 2010 Diderot A parallel domain-specific language for image analysis 5

Page 7: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Image analysis

Image analysis and visualization (continued ...)

Examples includeI Direct volume rendering (requires

reconstruction, derivatives)I Fiber tractography (requires tensor

fields)I Particle systems

September 6, 2010 Diderot A parallel domain-specific language for image analysis 5

Page 8: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Image analysis

Image analysis and visualization (continued ...)

Examples includeI Direct volume rendering (requires

reconstruction, derivatives)I Fiber tractography (requires tensor

fields)I Particle systems

September 6, 2010 Diderot A parallel domain-specific language for image analysis 5

Page 9: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Image analysis

We want domain-specific support for image analysis

We have three design goals:I Provide a high-level mathematical programming model that abstracts

away from discrete image data and the target architecture.I Use domain knowledge to get good performance on a range of parallel

platforms.I Make it possible for scientists to develop their own image analyses and

visualizations (“Matlab” for image analysis).

September 6, 2010 Diderot A parallel domain-specific language for image analysis 6

Page 10: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Image analysis

We want domain-specific support for image analysis

We have three design goals:I Provide a high-level mathematical programming model that abstracts

away from discrete image data and the target architecture.I Use domain knowledge to get good performance on a range of parallel

platforms.I Make it possible for scientists to develop their own image analyses and

visualizations (“Matlab” for image analysis).

September 6, 2010 Diderot A parallel domain-specific language for image analysis 6

Page 11: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Image analysis

We want domain-specific support for image analysis

We have three design goals:I Provide a high-level mathematical programming model that abstracts

away from discrete image data and the target architecture.I Use domain knowledge to get good performance on a range of parallel

platforms.I Make it possible for scientists to develop their own image analyses and

visualizations (“Matlab” for image analysis).

September 6, 2010 Diderot A parallel domain-specific language for image analysis 6

Page 12: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Image analysis

We want domain-specific support for image analysis

We have three design goals:I Provide a high-level mathematical programming model that abstracts

away from discrete image data and the target architecture.I Use domain knowledge to get good performance on a range of parallel

platforms.I Make it possible for scientists to develop their own image analyses and

visualizations (“Matlab” for image analysis).

September 6, 2010 Diderot A parallel domain-specific language for image analysis 6

Page 13: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Approaches

Approaches to domain-specific programming

There are three common approaches to supporting domain-specificprogramming:

1. Libraries; e.g., VTK/ITK, OpenCV, Teem, ...

2. Embedded domain-specific languages (EDSL); e.g., many Haskellexamples, Ct (C++), Delite (Scala), ...

3. Domain-specific languages (DSL); e.g., R, Renderman, TEX, ...

September 6, 2010 Diderot A parallel domain-specific language for image analysis 7

Page 14: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Approaches

Approaches to domain-specific programming

There are three common approaches to supporting domain-specificprogramming:

1. Libraries; e.g., VTK/ITK, OpenCV, Teem, ...

2. Embedded domain-specific languages (EDSL); e.g., many Haskellexamples, Ct (C++), Delite (Scala), ...

3. Domain-specific languages (DSL); e.g., R, Renderman, TEX, ...

September 6, 2010 Diderot A parallel domain-specific language for image analysis 7

Page 15: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Approaches

Approaches to domain-specific programming

There are three common approaches to supporting domain-specificprogramming:

1. Libraries; e.g., VTK/ITK, OpenCV, Teem, ...

2. Embedded domain-specific languages (EDSL); e.g., many Haskellexamples, Ct (C++), Delite (Scala), ...

3. Domain-specific languages (DSL); e.g., R, Renderman, TEX, ...

September 6, 2010 Diderot A parallel domain-specific language for image analysis 7

Page 16: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Approaches

Approaches to domain-specific programming

There are three common approaches to supporting domain-specificprogramming:

1. Libraries; e.g., VTK/ITK, OpenCV, Teem, ...

2. Embedded domain-specific languages (EDSL); e.g., many Haskellexamples, Ct (C++), Delite (Scala), ...

3. Domain-specific languages (DSL); e.g., R, Renderman, TEX, ...

September 6, 2010 Diderot A parallel domain-specific language for image analysis 7

Page 17: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Approaches

Comparing approaches

Impl. ClientNotation Optimization Parallelism Effort Effort

Library - 0 - + -

EDSL - + + 0 0

DSL + + + - +

September 6, 2010 Diderot A parallel domain-specific language for image analysis 8

Page 18: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Approaches

Comparing approaches

Impl. ClientNotation Optimization Parallelism Effort Effort

Library - 0 - + -

EDSL - + + 0 0

DSL + + + - +

In our case, Diderot is a small language, so the extra implementation effortover an EDSL is small (front-end is 2,600 lines of SML code).

September 6, 2010 Diderot A parallel domain-specific language for image analysis 8

Page 19: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Programming model

Diderot programming model

I The Diderot programming model is based on a collection of mostlyautonomous actors that are embedded in a continuous tensor field.

I Actors compute in a bulk-synchronous style.I Diderot abstracts away from details such as the image-data format, the

representation of reals (float vs double), and the target machine (e.g.,CPU vs GPU).

September 6, 2010 Diderot A parallel domain-specific language for image analysis 9

Page 20: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Programming model

Diderot programming model

I The Diderot programming model is based on a collection of mostlyautonomous actors that are embedded in a continuous tensor field.

I Actors compute in a bulk-synchronous style.I Diderot abstracts away from details such as the image-data format, the

representation of reals (float vs double), and the target machine (e.g.,CPU vs GPU).

September 6, 2010 Diderot A parallel domain-specific language for image analysis 9

Page 21: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Programming model

Diderot programming model

I The Diderot programming model is based on a collection of mostlyautonomous actors that are embedded in a continuous tensor field.

I Actors compute in a bulk-synchronous style.I Diderot abstracts away from details such as the image-data format, the

representation of reals (float vs double), and the target machine (e.g.,CPU vs GPU).

September 6, 2010 Diderot A parallel domain-specific language for image analysis 9

Page 22: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Programming model

Value types

Diderot has several types of values, including booleans, integers, and strings.The most important type of values are tensors.

shape

tensor[d1, . . . , dn]

This type describes an n-order tensor, where n ≥ 0 and the di > 1.We provide type aliases for common shapes; e.g.,

real = tensor[]vec3 = tensor[3]

We also normalize tensor[1] to tensor[], etc.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 10

Page 23: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Programming model

Image types

Images are used to represent the data sets that we are analyzing, as well asother array data, such as transfer functions.

shape

image(d)[d1, . . . , dn]

dimension

where d > 0, n ≥ 0, and the di > 1.The image type abstracts away from the on-disk representation of the data.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 11

Page 24: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Programming model

Kernel types

Kernels are used to reconstruct continuous fields from images.

kernel#k

levels of continuity

where k ≥ 0.We currently restrict ourselves to separable, piecewise polynomial kernelfunctions with rational coefficients.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 12

Page 25: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Programming model

Field types

Fields are an abstract representation of functions from some vector space totensors.

shape

field#k(d)[d1, . . . , dn]

dimension

levels of continuity

where k ≥ 0, d > 0, and the di > 1.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 13

Page 26: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Programming model

Typechecking

The typing rules keep track of the dimensions, shapes, etc.For example, here is the rule for convolution

Γ ` V : image(d)[σ] Γ ` h : kernel#kΓ ` V~h : field#k(d)[σ]

and for differentiation

Γ ` F : field#k(d)[σ] k > 0 k′ = k − 1Γ ` ∇F : field#k′(d)[σ, d]

September 6, 2010 Diderot A parallel domain-specific language for image analysis 14

Page 27: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Programming model

Probing tensor fields

I The key operation in Diderot is probing a continuous field to discover itsvalue at some position.

I A Diderot programmer might write code like the following

(∇ (img ~ bspln3))@pos

which probes a field at position pos, where the field is the first derivativeof the field reconstructed by applying the convolution kernel bspln3 tothe image data img.

I The typing rule for probing a field is

Γ ` F : field#k(d)[σ] Γ ` p : tensor[d]

Γ ` F@p : tensor[σ]

September 6, 2010 Diderot A parallel domain-specific language for image analysis 15

Page 28: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Programming model

Probing tensor fields

I The key operation in Diderot is probing a continuous field to discover itsvalue at some position.

I A Diderot programmer might write code like the following

(∇ (img ~ bspln3))@pos

which probes a field at position pos, where the field is the first derivativeof the field reconstructed by applying the convolution kernel bspln3 tothe image data img.

I The typing rule for probing a field is

Γ ` F : field#k(d)[σ] Γ ` p : tensor[d]

Γ ` F@p : tensor[σ]

September 6, 2010 Diderot A parallel domain-specific language for image analysis 15

Page 29: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Programming model

Probing tensor fields

I The key operation in Diderot is probing a continuous field to discover itsvalue at some position.

I A Diderot programmer might write code like the following

(∇ (img ~ bspln3))@pos

which probes a field at position pos, where the field is the first derivativeof the field reconstructed by applying the convolution kernel bspln3 tothe image data img.

I The typing rule for probing a field is

Γ ` F : field#k(d)[σ] Γ ` p : tensor[d]

Γ ` F@p : tensor[σ]

September 6, 2010 Diderot A parallel domain-specific language for image analysis 15

Page 30: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Programming model

Diderot program structure

A Diderot program has three parts:

1. Global definitions, including inputs.

2. Actor definitions, which are the computational agents.

3. Initialization, which defines an initial collection of actors.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 16

Page 31: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Programming model

Diderot program structure

A Diderot program has three parts:

1. Global definitions, including inputs.

2. Actor definitions, which are the computational agents.

3. Initialization, which defines an initial collection of actors.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 16

Page 32: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Programming model

Diderot program structure

A Diderot program has three parts:

1. Global definitions, including inputs.

2. Actor definitions, which are the computational agents.

3. Initialization, which defines an initial collection of actors.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 16

Page 33: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Programming model

Diderot program structure

A Diderot program has three parts:

1. Global definitions, including inputs.

2. Actor definitions, which are the computational agents.

3. Initialization, which defines an initial collection of actors.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 16

Page 34: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Programming model

Actors

I Each actor has a state, which includes its position and an updatemethod.

I Some state variables are annotated as outputs.I The execution model is bulk synchronous: at each iteration, every actor’s

state is updated independently.I The system iterates until a termination condition is met.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 17

Page 35: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Programming model

Actors

I Each actor has a state, which includes its position and an updatemethod.

I Some state variables are annotated as outputs.I The execution model is bulk synchronous: at each iteration, every actor’s

state is updated independently.I The system iterates until a termination condition is met.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 17

Page 36: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Programming model

Actors

I Each actor has a state, which includes its position and an updatemethod.

I Some state variables are annotated as outputs.I The execution model is bulk synchronous: at each iteration, every actor’s

state is updated independently.I The system iterates until a termination condition is met.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 17

Page 37: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Programming model

Actors

I Each actor has a state, which includes its position and an updatemethod.

I Some state variables are annotated as outputs.I The execution model is bulk synchronous: at each iteration, every actor’s

state is updated independently.I The system iterates until a termination condition is met.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 17

Page 38: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Programming model

Example: Maximum intensity projection

MIP is a volume rendering technique thatcomputes the maximum intensity value alongrays that are cast into the field.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 18

Page 39: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Programming model

Example: Maximum intensity projection (continued ...)

input string dataFile; // name of datasetinput real stepSz; // size of stepsinput vec3 eye; // location of eye pointinput vec3 orig; // location of pixel (0,0)input vec3 cVec; // vector between pixels horizontallyinput vec3 rVec; // vector between pixels vertically

image(3)[] img = load (dataFile);field#1(3)[] F = img ~ bspln3;

September 6, 2010 Diderot A parallel domain-specific language for image analysis 19

Page 40: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Programming model

Maximum intensity projection (continued ...)

actor RayCast (int row, int col){

vec3 pos = orig + real(row)*rVec + real(col)*cVec;vec3 dir = (pos - eye) / |pos - eye|;real t = 0.0;output real maxval = -∞;

update{

pos = pos + stepSz*dir;maxval = max (F@pos, maxval);if (t > 20)

stabilize;t = t + stepSz;

}}

initially [ RayCast(r, c) | r in 0..199, c in 0..199 ];

September 6, 2010 Diderot A parallel domain-specific language for image analysis 20

Page 41: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Technical issues

Probing tensor fields

A probe gets compiled down into code that maps the real-valued coordinatesto integers that index the image data. It then samples the image values in theneighborhood of the integer coordinates to compute the result of the probe.

⊛h

Continuous fieldDiscrete image data

This process is similar to texture filtering in Graphics, but it has strongermathematical requirements.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 21

Page 42: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Technical issues

Exploiting domain knowledgeThere are many opportunities to exploit domain knowledge to gain betterperformance.

One example is the code

posi+1 = posi + stepSz ∗ dir;maxvali+1 = max(F@posi+1, maxvali);

To probe the field F, we need to map posi+1 into image space. Using domainknowledge (linear algebra), we can apply strength reduction.

posimgi+1 = M−1posi+1

= M−1(posi + stepSz ∗ dir)

= M−1posi + M−1(stepSz ∗ dir)

= posimgi + delta

September 6, 2010 Diderot A parallel domain-specific language for image analysis 22

Page 43: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Technical issues

Exploiting domain knowledgeThere are many opportunities to exploit domain knowledge to gain betterperformance.

One example is the code

posi+1 = posi + stepSz ∗ dir;maxvali+1 = max(F@posi+1, maxvali);

To probe the field F, we need to map posi+1 into image space. Using domainknowledge (linear algebra), we can apply strength reduction.

posimgi+1 = M−1posi+1

= M−1(posi + stepSz ∗ dir)

= M−1posi + M−1(stepSz ∗ dir)

= posimgi + delta

September 6, 2010 Diderot A parallel domain-specific language for image analysis 22

Page 44: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Technical issues

Exploiting domain knowledgeThere are many opportunities to exploit domain knowledge to gain betterperformance.

One example is the code

posi+1 = posi + stepSz ∗ dir;maxvali+1 = max(F@posi+1, maxvali);

To probe the field F, we need to map posi+1 into image space. Using domainknowledge (linear algebra), we can apply strength reduction.

posimgi+1 = M−1posi+1

= M−1(posi + stepSz ∗ dir)

= M−1posi + M−1(stepSz ∗ dir)

= posimgi + delta

September 6, 2010 Diderot A parallel domain-specific language for image analysis 22

Page 45: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Technical issues

Staged computation

Using staged computation (e.g., partial evaluation) to specialize the code forproperties of the image-data.

a.diderot Parser + typechecker

Expander

data.nrrd

AST

IL Optimizer IL

Code generator

a.out

September 6, 2010 Diderot A parallel domain-specific language for image analysis 23

Page 46: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Technical issues

Other issues

I Type inference and dimension polymorphism.I Compiler architecture and internal representations that support multiple

parallel targets.I Compiler and runtime techniques to automatically handle very large

images.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 24

Page 47: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Technical issues

Other issues

I Type inference and dimension polymorphism.I Compiler architecture and internal representations that support multiple

parallel targets.I Compiler and runtime techniques to automatically handle very large

images.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 24

Page 48: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Technical issues

Other issues

I Type inference and dimension polymorphism.I Compiler architecture and internal representations that support multiple

parallel targets.I Compiler and runtime techniques to automatically handle very large

images.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 24

Page 49: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Future research

Long-term goals

In the future, we would like to generalize this work in two directions:

1. Extend Diderot to other classes of algorithms (e.g., object recognition).

2. Generalize approach to other domains.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 25

Page 50: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Conclusion

Status

I First version of language design is doneI Parser and typechecker have been implementedI Working on naı̈ve code generator with limited optimization that targets

OpenCL.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 26

Page 51: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Conclusion

Status

I First version of language design is doneI Parser and typechecker have been implementedI Working on naı̈ve code generator with limited optimization that targets

OpenCL.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 26

Page 52: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Conclusion

Status

I First version of language design is doneI Parser and typechecker have been implementedI Working on naı̈ve code generator with limited optimization that targets

OpenCL.

September 6, 2010 Diderot A parallel domain-specific language for image analysis 26

Page 53: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Conclusion

Portable parallel programming

Image analysis

Video encoding

Ray tracer

Computer games

Web server

Supercomputers

Clusters

SMP/Multicore

GPU

Applications Platforms

Program

Program

The Ideal: write once, run everywhere, for any application

September 6, 2010 Diderot A parallel domain-specific language for image analysis 27

Page 54: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Conclusion

Portable parallel programming

Image analysis

Video encoding

Ray tracer

Computer games

Web server

Supercomputers

Clusters

SMP/Multicore

GPU

Applications Platforms

Program

Program

Program

Program

The Reality: write once per platform per application

September 6, 2010 Diderot A parallel domain-specific language for image analysis 27

Page 55: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Conclusion

Portable parallel programming

Image analysis

Video encoding

Ray tracer

Computer games

Web server

Supercomputers

Clusters

SMP/Multicore

GPU

Applications Platforms

Program

Program

Manticore: restrict platforms

September 6, 2010 Diderot A parallel domain-specific language for image analysis 27

Page 56: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Conclusion

Portable parallel programming

Image analysis

Video encoding

Ray tracer

Computer games

Web server

Supercomputers

Clusters

SMP/Multicore

GPU

Applications Platforms

Program

Diderot: restrict applications

September 6, 2010 Diderot A parallel domain-specific language for image analysis 27

Page 57: Diderot A parallel domain-specific language for image analysisdiderot-language.cs.uchicago.edu/papers/msrc-talk-20100906.pdf · 9/6/2010  · I Diderot abstracts away from details

Conclusion

Questions?

September 6, 2010 Diderot A parallel domain-specific language for image analysis 28