Top Banner
A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric Rabbah and Saman Amarasinghe Massachusetts Institute of Technology IBM PL Day May 21, 2004
58

A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Jan 18, 2018

Download

Documents

Crystal Rich

Properties of Stream Programs A large (possibly infinite) amount of data –Limited lifetime of each data item –Little processing of each data item Computation: apply multiple filters to data –Each filter takes an input stream, does some processing, and produces an output stream –Filters are independent and self-contained A regular, static communication pattern –Filter graph is relatively constant –A lot of opportunities for compiler optimizations
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

A Compiler Infrastructure for Stream Programs

Bill Thies

Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric Rabbah and Saman Amarasinghe

Massachusetts Institute of Technology

IBM PL DayMay 21, 2004

Page 2: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Streaming Application Domain

• Based on audio, video, or data stream• Increasingly prevalent and important

– Embedded systems•Cell phones, handheld computers

– Desktop applications•Streaming media Real-time encryption•Software radio Graphics packages

– High-performance servers•Software routers (Example: Click)•Cell phone base stations•HDTV editing consoles

Page 3: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Properties of Stream Programs

• A large (possibly infinite) amount of data– Limited lifetime of each data item– Little processing of each data item

• Computation: apply multiple filters to data– Each filter takes an input stream, does some

processing, and produces an output stream– Filters are independent and self-contained

• A regular, static communication pattern– Filter graph is relatively constant– A lot of opportunities for compiler optimizations

Page 4: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

The StreamIt Project• Goals:

– Provide a high-level stream programming model – Invent new compiler technology for streams

• Contributions:– Language Design, Structured Streams, Buffer

Management (CC 2002)– Exploiting Wire-Exposed Architectures (ASPLOS

2002, ISCA 2004)– Scheduling of Static Dataflow Graphs (LCTES 2003)– Domain Specific Optimizations (PLDI 2003)– Public release: Fall 2003

Page 5: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Outline• Introduction• StreamIt Language• Domain-specific Optimizations• Targeting Parallel Architectures• Public Release• Conclusions

Page 6: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Outline• Introduction• StreamIt Language• Domain-specific Optimizations• Targeting Parallel Architectures• Public Release• Conclusions

Page 7: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Model of Computation• Synchronous Dataflow [Lee 1992]

– Graph of independent filters– Communicate via channels– Static I/O rates

A/D

Duplicate

LED

Detect

LED

Detect

LED

Detect

LED

Detect

Band pass

Freq band detector

Page 8: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Filter Example: LowPassFilter

filter

float->float filter LowPassFilter (int N, float freq) { float[N] weights;

init { weights = calcWeights(N, freq); }

work peek N pop 1 push 1 { float result = 0; for (int i=0; i<weights.length; i++) { result += weights[i] * peek(i); } push(result); pop(); }}

Page 9: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

N

filter

Filter Example: LowPassFilterfloat->float filter LowPassFilter (int N, float freq) { float[N] weights;

init { weights = calcWeights(N, freq); }

work peek N pop 1 push 1 { float result = 0; for (int i=0; i<weights.length; i++) { result += weights[i] * peek(i); } push(result); pop(); }}

Page 10: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

N

filter

Filter Example: LowPassFilterfloat->float filter LowPassFilter (int N, float freq) { float[N] weights;

init { weights = calcWeights(N, freq); }

work peek N pop 1 push 1 { float result = 0; for (int i=0; i<weights.length; i++) { result += weights[i] * peek(i); } push(result); pop(); }}

Page 11: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Filter Example: LowPassFilter

N

filter

float->float filter LowPassFilter (int N, float freq) { float[N] weights;

init { weights = calcWeights(N, freq); }

work peek N pop 1 push 1 { float result = 0; for (int i=0; i<weights.length; i++) { result += weights[i] * peek(i); } push(result); pop(); }}

Page 12: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Composing Filters: Structured Streams

• Hierarchical structures:– Pipeline

– SplitJoin

– Feedback Loop

• Basic programmable unit: Filter

Page 13: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Duplicate

LED

Detect

LED

Detect

LED

Detect

LED

Detect

Freq Band Detector in StreamIt

A/D

Band pass

void->void pipeline FrequencyBand { float sFreq = 4000; float cFreq = 500/(sFreq*2*pi); float wFreq = 100/(sFreq*2*pi);

add D2ASource(sFreq);

add BandPassFilter(100, cFreq-wFreq, cFreq+wFreq);

add splitjoin {

split duplicate; for (int i=0; i<4; i++) { add pipeline { add Detect (i/4);

add LED (i); } } join roundrobin(0); } }}

Page 14: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Radar-Array Front End

Page 15: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Filterbank

Page 16: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

FM Radio with Equalizer

Page 17: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Bitonic Sort

Page 18: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

FFT

Page 19: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Block Matrix Multiply

Page 20: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

MP3 Decoder

Page 21: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Outline• Introduction• StreamIt Language• Domain-specific Optimizations• Targeting Parallel Architectures• Public Release• Conclusions

Page 22: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Conventional DSP Design Flow

DSP Optimizations

Rewrite the program

Design the Datapaths(no control flow)

Architecture-specificOptimizations(performance,

power, code size)

Spec. (data-flow diagram)

Coefficient Tables

C/Assembly Code

Signal Processing Expert in Matlab

Software Engineerin C and Assembly

Page 23: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Any Design Modifications?• Center frequency from 500 Hz to 1200

Hz?– According to TI,

in the conventional design-flow:• Redesign filter in MATLAB• Cut-and-paste values to EXCEL• Recalculate the coefficients • Update assembly

Source: Application Report SPRA414Texas Instruments, 1999

A/D

Duplicate

LED

Detect

LED

Detect

LED

Detect

LED

Detect

Band pass

Page 24: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Ideal DSP Design Flow

DSP Optimizations

High-Level Program(dataflow + control)

Architecture-SpecificOptimizations

C/Assembly Code

Application-Level Design

Compiler

Application Programmer

Challenge: maintaining performance

Page 25: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Our Focus: Linear Filters• Most common target of DSP

optimizations• FIR filters• Compressors• Expanders• DFT/DCT

• Optimizations:1. Combining Adjacent Nodes2. Translating to Frequency Domain3. Selecting the Best Transformations

Output is weighted sum of inputs

Page 26: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Extracting Linear Representation

work peek N pop 1 push 1 { float sum = 0; for (int i=0; i<N; i++) { sum += h[i]*peek(i); } push(sum); pop();}

LinearDataflowAnalysis A, b

y= x A + b

x

Page 27: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

1) Combining Linear Filters

• Pipelines and splitjoins can be collapsed• Example: pipeline

Filter 1

Filter 2

x

y

z

y = x A

z = y B

CombinedFilter z = x Cz = x A B

C

Page 28: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Combination Example

321

B

654A

6 multsoutput

1 multsoutput

Filter 1

Filter 2

C = [ 32 ]CombinedFilter

Page 29: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Floating-Point Operations Reduction

-40%

-20%

0%

20%

40%

60%

80%

100%

Benchmark

Flop

s R

emov

ed (%

)

linear

0.3%

Page 30: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

2) From Time to Frequency Domain

• Convolutions can be done cheaply in the Frequency Domain

• Painful to do by hand• Blocking• Coefficient calculations• Startup

Xi*Wn-iΣ

X F(x)

Y X .* H

y F -1(Y)

FFT

VVM

IFFT• Multiple outputs • Interfacing with FFT library• Verification

Page 31: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Floating-Point Operations Reduction

-40%

-20%

0%

20%

40%

60%

80%

100%

Benchmark

Flop

s R

emov

ed (%

)

linear

freq

-140%

0.3%

Page 32: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

3) When to Apply Transformations?

• Estimate minimal cost for each structure:• Linear combination• Frequency translation• No transformation

• If hierarchical, consider all rectangular groupings of children

• Overlapping sub-problems allows efficient dynamic programming search

Page 33: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Radar (Transformation Selection)

Splitter

Sink

RR

Mag

Detect

Duplicate

Mag

Detect

Mag

Detect

BeamFrm

BeamFrm

BeamFrm

BeamFrm

Filter Filter Filter Filter

Mag

Detect

RR

Splitter(null)

Input Input Input Input Input Input Input Input Input Input Input Input

Dec Dec Dec Dec Dec Dec Dec Dec Dec Dec Dec Dec

Dec Dec Dec Dec Dec Dec Dec Dec Dec Dec Dec Dec

Cfilt Cfilt Cfilt Cfilt Cfilt Cfilt Cfilt Cfilt Cfilt Cfilt Cfilt Cfilt

CFilt2

CFilt2

CFilt2

CFilt2

CFilt2

CFilt2

CFilt2

CFilt2

CFilt2

CFilt2

CFilt2

CFilt2

Page 34: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

RR

RR

RR

Radar (Transformation Selection)

Splitter

Sink

RR

Filter

Mag

Detect

Filter

Mag

Detect

Filter

Mag

Detect

Duplicate

BeamFrm

BeamFrm

BeamFrm

BeamFrm

Filter

Mag

Detect

Splitter(null)

Input Input Input Input Input Input Input Input Input Input Input Input

Page 35: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

RR

RR

Radar (Transformation Selection)

Splitter

Sink

RR

Filter

Mag

Detect

Filter

Mag

Detect

Filter

Mag

Detect

RR

Duplicate

BeamFrm

BeamFrm

BeamFrm

BeamFrm

Filter

Mag

Detect

Splitter(null)

Input Input Input Input Input Input Input Input Input Input Input Input

Page 36: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Radar (Transformation Selection)

RR

RR

Splitter

Sink

RR

Filter

Mag

Detect

Filter

Mag

Detect

Filter

Mag

Detect

Filter

Mag

Detect

Splitter(null)

Input Input Input Input Input Input Input Input Input Input Input Input

half as many FLOPS

Splitter

Sink

RR

Mag

Duplicate

Mag Mag Mag

RR

Splitter(null)

Input Input Input Input Input Input Input Input Input Input Input Input

Maximal Combination andShifting to Frequency Domain

Using TransformationSelection

2.4 times as many FLOPS

Page 37: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Floating-Point Operations Reduction

-40%

-20%

0%

20%

40%

60%

80%

100%

FIR

RateConve

rt

Targe

tDete

ct

FMRadio

Radar

FilterB

ank

Vocode

r

Oversa

mpleDToA

Benchmark

Flop

s Re

mov

ed (%

)

linear

freq

autosel

-140%

0.3%

Page 38: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Outline• Introduction• StreamIt Language• Domain-specific Optimizations• Targeting Parallel Architectures• Public Release• Conclusions

Page 39: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Compiling to the Raw Architecture

Page 40: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Compiling to the Raw Architecture

1. Partitioning: adjust granularity of graph

Page 41: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Compiling to the Raw Architecture

1. Partitioning: adjust granularity of graph

2. Layout: assign filters to tiles

Page 42: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

1. Partitioning: adjust granularity of graph

2. Layout: assign filters to tiles3. Scheduling: route items across

network

Compiling to the Raw Architecture

Page 43: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Scalability ResultsFIR

0.0

8.0

16.0

24.0

32.0

0 2 4 6 8 10 12 14 16

Tiles

Thro

ughp

ut

Filterbank

0.0

8.0

16.0

24.0

32.0

0 2 4 6 8 10 12 14 16

Tiles

Thro

ughp

ut

Radar

0.0

8.0

16.0

24.0

32.0

0 2 4 6 8 10 12 14 16

Tiles

Thro

ughp

ut

FMRadio

0.0

8.0

16.0

24.0

32.0

0 2 4 6 8 10 12 14 16

Tiles

Thro

ughp

ut

Bitonic Sort

0.0

8.0

16.0

24.0

32.0

0 2 4 6 8 10 12 14 16

Tiles

Thro

ughp

ut

FFT

0.0

8.0

16.0

24.0

32.0

0 2 4 6 8 10 12 14 16

Tiles

Thro

ughp

ut

Page 44: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Raw vs. Pentium III16-Tile Raw vs. Pentium III

0

2

4

6

8

10

12

14

16

18

FIR Filterbank Radar FMRadio Bitonic Sort FFT

Spee

dup

(cyc

les)

Page 45: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Outline• Introduction• StreamIt Language• Domain-specific Optimizations• Targeting Parallel Architectures• Public Release• Conclusions

Page 46: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

StreamIt Compiler Infrastructure

• Built on Kopi Java compiler (GNU license)– StreamIt frontend is on MIT license

• High-level hierarchical IR for streams– Host of graph transformations

•Filter fusion, filter fission•Synchronization removal•Splitjoin refactoring•Graph canonicalization

• Low-level “flat graph” for backends– Eliminates structure; point-to-point

connections• Streaming benchmark suite

Page 47: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Compiler Flow

Kopi Front-End

StreamIt code

SIR Conversion

Parse Tree

SIR (unexpanded)

SIR (expanded)

Graph Expansion

Raw Backend

StreamIt Front-EndLegal Java file

Any JavaCompiler Scheduler

StreamItJava Library

Class file

UniprocessorBackend

Linear OptimizationsLinearOptimizations

C code for tilesAssembly code for switch

ANSI C code

Page 48: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Building on StreamIt• StreamIt to VIRAM [Yelick et al.]

– Automatically generate permutation instructions

• StreamBit: bit-level optimization [Bodik et al.]

• Integration with IBM Eclipse Platform

Page 49: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

StreamIt Graphical EditorStreamIt Component-Shortcuts Create Filters, Pipelines, SplitJoins, Feedback

Loops, FIFOs

Juan C. Reyes M.Eng. Thesis

Page 50: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

StreamIt Debugging Environment

StreamIt Text Editor

StreamIt Graph Zoom Panel

StreamIt Graph Components

expanded and collapsed views of basic programmable unit

communication buffer with live data

General Debugging Information

Compiler and Output Consoles

not shown: the StreamIt On-Line Help Manual

Kimberly KuoM.Eng. Thesis

Page 51: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Outline• Introduction• StreamIt Language• Domain-specific Optimizations• Targeting Parallel Architectures• Public Release• Conclusions

Page 52: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Related Work• Stream languages

– KernelC/StreamC, Brook: augment C with data-parallel kernels– Cg: allow low-level programming of graphics processors– SISAL, functional languages: expose temporal parallelism– StreamIt exposes more task parallelism, easier to analyze

• Control languages for embedded systems– LUSTRE, Esterel, etc.: can verify of safety properties– Do not expose high-bandwidth data flow for optimization

• Prototyping environments– Ptolemy, Simulink, etc.: provide graphical abstractions– StreamIt has more of a compiler focus

Page 53: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Future Work• Backend optimizations for linear filters

– Template assembly code: asymptotically optimal

• Fault-tolerance on a cluster of workstations– Automatically recover if machine fail

• Supporting dynamic events– Point-to-point control messages– Re-initialization for parts of the stream

Page 54: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Conclusions• StreamIt: compiler infrastructure for

streams– Raising the level of abstraction in stream programming– Language design for both programmer and compiler

• Public release: many opportunities for collaboration

Compiler Analysis

Language features exploited

Linear Optimizations

- peek primitive (data reuse)- atomic work function- structured streams

Backend for Raw Architecture

- exposed communication patterns- exposed parallelism- static work estimate

http://cag.csail.mit.edu/streamit

Page 55: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Extra Slides

Page 56: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

StreamIt Language SummaryFeature Programmer

BenefitCompiler Benefit

AutonomousFilters

• Encapsulation• Automatic scheduling

• Local memories• Exposes parallelism• Exposes communication

Peek

primitive

• Automatic buffer management • Exposes data reuse

StructuredStreams • Natural syntax

• Exposes symmetry• Eliminate corner cases

Scripts for GraphConstruction

• Reusable components• Easy to maintain

• Two-stage

compilation

Page 57: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

AB for any A and B?

[A]U

E

[A]U

E

[A][A]

[A]

Original Expanded

pop =

• Linear Expansion

Page 58: A Compiler Infrastructure for Stream Programs Bill Thies Joint work with Michael Gordon, Michal Karczmarek, Jasper Lin, Andrew Lamb, David Maze, Rodric.

Backend Support for Linear Filters

• Can generate custom code for linear filters– Many architectures have special support for matrix

mult.– On Raw: assembly code templates for tiles and

switch• Substitute coefficients, peek/pop/push rates

• Preliminary result: FIR on Raw– StreamIt code: 15 lines– Manually-tuned C code: 352 lines– Both achieve 99% utilization of Raw FPU’s

• Asymptotically optimal

• Current focus: integrating with general backend