MIT OpenCourseWare http://ocw.mit.edu 6.189 Multicore Programming Primer, January (IAP) 2007 Please use the following citation format: Bill Thies, 6.189 Multicore Programming Primer, January (IAP) 2007. (Massachusetts Institute of Technology: MIT OpenCourseWare). http://ocw.mit.edu (accessed MM DD, YYYY). License: Creative Commons Attribution-Noncommercial-Share Alike. Note: Please use the actual date you accessed this material in your citation. For more information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms 6.189 IAP 2007 Lecture 8 The StreamIt Language Bill Thies, MIT. 1 6.189 IAP 2007 MIT Languages Have Not Kept Up Images by MIT OpenCourseWare. C von-Neumann machine Modern architecture ● Two choices: ● Develop cool architecture with complicated, ad-hoc language language Bend over backwards to support old languages like C/C++ Images by MIT OpenCourseWare. Bill Thies, MIT. 2 6.189 IAP 2007 MIT Why a New Language? For uniprocessors, C was: •Portable •High Performance •Composable •Malleable •Maintainable 512 256 128 64 32 # of cores 16 8 4 Pico Pi cochip chip PC102 Cisco CSR-1 Intel Tflops Raw Raw 4004 8080 8086 286 386 486 Boardcom 1480 Pentium 8008 1970 Bill Thies, MIT. 1975 1980 1985 1990 3 Razza Ra a XLR Niagara 2 1 Ambric Ambric AM2045 AM 2045 Caviium Cav um Octeon Cell Cell Opteron 4P Xeon Xe on MP Xbox360 Xbox36 0 PA-8800 Opteron Tanglewood Power4 PExtreme PExtrem e Power6 Yonah P2 P3 Itanium P4 Athlon Itanium 2 1995 2000 2005 20?? 6.189 IAP 2007 MIT Why a New Language? 512 Pico Pi cochip chip PC102 Uniprocessors: 128 C is the common 64 machine language 256 Cisco CSR-1 Intel Tflops 32 # of cores 16 Raw Raw Razza Ra a XLR Niagara 8 Boardcom 1480 4 2 1 4004 8080 8086 286 386 486 Pentium 8008 1970 Bill Thies, MIT. 1975 1980 1985 1990 4 Ambric Ambric AM2045 AM 2045 Caviium Cav um Octeon Cell Cell Opteron 4P Xeon Xe on MP Xbox360 Xbox36 0 PA-8800 Opteron Tanglewood Power4 PExtreme PExtrem e Power6 Yonah P2 P3 Itanium P4 Athlon Itanium 2 1995 2000 2005 20?? 6.189 IAP 2007 MIT Why a New Language? What is the common machine language for multicores? 512 256 128 Picochip Picochip PC102 Ambric Ambric AM2045 Cisco Cisco CSR-1 Intel Tflops 64 32 # of cores 16 Raw Ra w Niagara 8 Boardcom B oardcom 1480 4 2 1 Raza Raza XLR 4004 8080 8086 286 386 486 Pentium 8008 1970 Bill Thies, MIT. 1975 1980 1985 1990 5 Cavium Cavium Octeon Octeon Cell Opteron 4P Xeon MP Xbox360 Xbox360 PA-8800 PA -8800 Opteron Tanglewood Power4 PExtreme Power6 Yonah P2 P3 Itanium P4 Athlon Itanium 2 1995 2000 2005 20?? 6.189 IAP 2007 MIT Common Machine Languages Uniprocessors: Multicores: Common Properties Common Properties Single flow of control Multiple flows of control Single memory image Multiple local memories Differences: Differences: Register File Number and capabilities of cores ISA Communication Model Functional Units Synchronization Model von-Neumann languages represent the common properties and abstract away the differences Need common machine language(s) for multicores Bill Thies, MIT. 6 6.189 IAP 2007 MIT Streaming as a Common Machine Language AtoD ● For programs based on streams of data Audio, video, DSP, networking, and cryptographic processing kernels Examples: HDTV editing, radar tracking, microphone arrays, cell phone base stations, graphics ● Several attractive properties Regular and repeating computation Independent filters with explicit communication Task, data, and pipeline parallelism Bill Thies, MIT. 7 FMDemod Scatter LPF1 LPF2 LPF3 HPF1 HPF2 HPF3 Gather Adder Speaker 6.189 IAP 2007 MIT Streaming Models of Computation ● Many different ways to represent streaming Do senders/receivers block? How much buffering is allowed on channels? Is computation deterministic? Can you avoid deadlock? ● Three common models: 1. Kahn Process Networks 2. Synchronous Dataflow 3. Communicating Sequential Processes Bill Thies, MIT. 8 6.189 IAP 2007 MIT Streaming Models of Computation Communication Buffering Pattern Notes Kahn process networks (KPN) Data-dependent, but deterministic Conceptually unbounded - UNIX pipes - Ambric (startup) Synchronous dataflow (SDF) Static Fixed by compiler - Static scheduling - Deadlock freedom Communicating Sequential Processes (CSP) Data-dependent, allows nondeterminism None - Rich synchronization (Rendesvouz) primitives - Occam language SDF CSP KPN space of program behaviors Bill Thies, MIT. 9 6.189 IAP 2007 MIT The StreamIt Language ● A high-level, architecture-independent language for streaming applications Improves programmer productivity (vs. Java, C) Offers scalable performance on multicores ● Based on synchronous dataflow, with dynamic extensions Compiler determines execution order of filters Many aggressive optimizations possible Bill Thies, MIT. 10 6.189 IAP 2007 MIT The StreamIt Project ● Applications StreamIt Program DES and Serpent [PLDI 05] MPEG-2 [IPDPS 06] SAR, DSP benchmarks, JPEG, … Front-end ● Programmability StreamIt Language (CC 02) Teleport Messaging (PPOPP 05) Programming Environment in Eclipse (P-PHEC 05) Annotated Java ● Domain Specific Optimizations Linear Analysis and Optimization (PLDI 03) Optimizations for bit streaming (PLDI 05) Linear State Space Analysis (CASES 05) Simulator (Java Library) Stream-Aware Optimizations ● Architecture Specific Optimizations Compiling for Communication-Exposed Architectures (ASPLOS 02) Phased Scheduling (LCTES 03) Cache Aware Optimization (LCTES 05) Load-Balanced Rendering (Graphics Hardware 05) Bill Thies, MIT. 11 Uniprocessor backend Cluster backend Raw backend IBM X10 backend C/C++ MPI-like C/C++ C per tile + msg code Streaming X10 runtime 6.189 IAP 2007 MIT Example: A Simple Counter void->void pipeline Counter() { add IntSource(); add IntPrinter(); Counter IntSource } void->int filter IntSource() { int x; init { x = 0; } work push 1 { push (x++); } IntPrinter % strc Counter.str –o counter % ./counter –i 4 0 1 2 3 } int->void filter IntPrinter() { work pop 1 { print(pop()); } } Bill Thies, MIT. 12 6.189 IAP 2007 MIT Representing Streams ● Conventional wisdom: streams are graphs Graphs have no simple textual representation Graphs are difficult to analyze and optimize ● Insight: stream programs have structure unstructured Bill Thies, MIT. structured 13 6.189 IAP 2007 MIT Structured Streams filter pipeline may be any StreamIt language construct splitjoin splitter ● Each structure is singleinput, single-output ● Hierarchical and composable parallel computation joiner feedback loop joiner Bill Thies, MIT. splitter 14 6.189 IAP 2007 MIT Filter Example: Low Pass Filter float->float filter LowPassFilter (int N, float freq) { float[N] weights; init { weights = calcWeights(freq); N } } work peek N push 1 pop 1 { float result = 0; for (int i=0; i<weights.length; i++) { result += weights[i] * peek(i); } push(result); pop(); } Bill Thies, MIT. 15 filter 6.189 IAP 2007 MIT Low Pass Filter in C void FIR( int* src, int* dest, int* srcIndex, int* destIndex, int srcBufferSize, int destBufferSize, int N) { ● FIR functionality obscured by buffer management details ● Programmer must commit to a particular buffer implementation strategy float result = 0.0; for (int i = 0; i < N; i++) { result += weights[i] * src[(*srcIndex + i) % srcBufferSize]; } dest[*destIndex] = result; *srcIndex = (*srcIndex + 1) % srcBufferSize; *destIndex = (*destIndex + 1) % destBufferSize; } Bill Thies, MIT. 16 6.189 IAP 2007 MIT Pipeline Example: Band Pass Filter float→float pipeline BandPassFilter (int N, float low, float high) { add LowPassFilter(N, low); add HighPassFilter(N, high); LowPassFilter HighPassFilter } Bill Thies, MIT. 17 6.189 IAP 2007 MIT SplitJoin Example: Equalizer float→float pipeline Equalizer (int N, float lo, float hi) { Equalizer duplicate add splitjoin { split duplicate; for (int i=0; i<N; i++) BPF BPF BPF add BandPassFilter(64, lo + i*(hi - lo)/N); join roundrobin(1); } roundrobin add Adder(N); } Adder Bill Thies, MIT. 18 6.189 IAP 2007 MIT Building Larger Programs: FMRadio void->void pipeline FMRadio(int N, float lo, float hi) { add AtoD(); add FMDemod(); FMDemod add splitjoin { split duplicate; for (int i=0; i<N; i++) { add pipeline { Duplicate } add LowPassFilter(lo + i*(hi - lo)/N); LPF1 LPF2 LPF3 add HighPassFilter(lo + i*(hi - lo)/N); HPF1 HPF2 HPF3 } join roundrobin(); } add Adder(); RoundRobin Adder add Speaker(); } AtoD Bill Thies, MIT. Speaker 19 6.189 IAP 2007 MIT The Beauty of Streaming “Some programs are elegant, some are exquisite, some are sparkling. My claim is that it is possible to write grand programs, noble programs, truly magnificient ones!” — Don Knuth, ACM Turing Award Lecture Image removed due to copyright restrictions. Bill Thies, MIT. 20 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(N) 21 join roundrobin(N) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(N) 22 join roundrobin(N) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(N) 23 join roundrobin(N) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(N) 24 join roundrobin(N) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(N) 25 join roundrobin(N) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(N) 26 join roundrobin(N) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(N) 27 join roundrobin(N) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(N) 28 join roundrobin(N) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(N) 29 join roundrobin(N) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(N) 30 join roundrobin(N) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(N) 31 join roundrobin(N) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(N) 32 join roundrobin(N) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(N) 33 join roundrobin(N) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(N) 34 join roundrobin(N) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 35 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 36 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 37 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 38 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 39 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 40 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 41 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 42 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 43 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 44 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 45 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 46 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 47 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 48 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 49 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 50 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 51 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 52 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 53 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 54 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 55 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 56 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 57 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 58 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 59 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 60 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(1) 61 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(2) 62 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(2) 63 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(2) 64 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(2) 65 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(2) 66 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(2) 67 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(2) 68 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(2) 69 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate Bill Thies, MIT. split roundrobin(2) 70 join roundrobin(1) 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate split roundrobin(2) join roundrobin(1,2,3) Bill Thies, MIT. 71 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate split roundrobin(2) join roundrobin(1,2,3) Bill Thies, MIT. 72 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate split roundrobin(2) join roundrobin(1,2,3) Bill Thies, MIT. 73 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate split roundrobin(2) join roundrobin(1,2,3) Bill Thies, MIT. 74 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate split roundrobin(2) join roundrobin(1,2,3) Bill Thies, MIT. 75 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate split roundrobin(2) join roundrobin(1,2,3) Bill Thies, MIT. 76 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate split roundrobin(2) join roundrobin(1,2,3) Bill Thies, MIT. 77 6.189 IAP 2007 MIT SplitJoins are Beautiful split duplicate split roundrobin(2) join roundrobin(1,2,3) Bill Thies, MIT. 78 6.189 IAP 2007 MIT Matrix Transpose N M Transpose M N Bill Thies, MIT. 79 6.189 IAP 2007 MIT Matrix Transpose N M roundrobin(?) ? roundrobin(?) M N Bill Thies, MIT. 80 6.189 IAP 2007 MIT Matrix Transpose N M roundrobin(?) ? roundrobin(?) M N Bill Thies, MIT. 81 6.189 IAP 2007 MIT Matrix Transpose N M roundrobin(1) N roundrobin(M) M N Bill Thies, MIT. 82 6.189 IAP 2007 MIT Matrix Transpose N M roundrobin(1) N roundrobin(M) M N Bill Thies, MIT. 83 6.189 IAP 2007 MIT Matrix Transpose N M roundrobin(1) N roundrobin(M) float->float splitjoin Transpose (int M, int N) { split roundrobin(1); for (int i = 0; i<N; i++) { add Identity<float>; } join roundrobin(M); } M N Bill Thies, MIT. 84 6.189 IAP 2007 MIT Bit-reversed ordering ● Many FFT algorithms require a bit-reversal stage ● If item is at index n (with binary digits b0 b1 … bk), then it is transferred to reversed index bk … b1 b0 ● For 3-digit binary numbers: 00001111 00110011 01010101 00001111 00110011 01010101 Bill Thies, MIT. 85 6.189 IAP 2007 MIT Bit-reversed ordering ● Many FFT algorithms require a bit-reversal stage ● If item is at index n (with binary digits b0 b1 … bk), then it is transferred to reversed index bk … b1 b0 ● For 3-digit binary numbers: 00001111 00110011 01010101 RR(w1) 00001111 00110011 01010101 Bill Thies, MIT. RR(w1) RR(w1) RR(w2) RR(w2) RR(w3) 86 6.189 IAP 2007 MIT Bit-reversed ordering ● Many FFT algorithms require a bit-reversal stage ● If item is at index n (with binary digits b0 b1 … bk), then it is transferred to reversed index bk … b1 b0 ● For 3-digit binary numbers: 00001111 00110011 01010101 RR(1) 00001111 00110011 01010101 Bill Thies, MIT. RR(1) RR(1) RR(2) RR(2) RR(4) 87 6.189 IAP 2007 MIT Bit-reversed ordering complex->complex pipeline BitReverse (int N) { if (N==2) { add Identity<complex>; rr 1 1 } else { rr 1 1 1 add splitjoin { 2 split roundrobin(1); 2 2 rr add BitReverse(N/2); 4 4 rr add BitReverse(N/2); join roundrobin(N/2); } } } Bill Thies, MIT. 88 1 rr 1 1 rr 1 1 2 2 rr rr rr rr 1 1 1 2 2 4 8 rr rr 4 8 6.189 IAP 2007 MIT rr rr 1 2 N-Element Merge Sort int->int pipeline MergeSort (int N) { if (N==2) { add Sort(N); } else { add splitjoin { split roundrobin(N/2); add MergeSort(N/2); add MergeSort(N/2); join roundrobin(N/2); } } add Merge(N); } Bill Thies, MIT. 89 N N/2 N/8 Sort N/4 N/4 N/4 N/8 N/2 N/8 N/8 Sort Merge N/8 N/8 Sort Sort Sort Merge N/4 Sort Sort Merge Merge N/8 N/8 Sort Merge Merge Merge 6.189 IAP 2007 MIT N-Element Merge Sort (3-level) N N/2 N/2 N/4 N/4 N/4 N/4 N/8 N/8 N/8 N/8 N/8 N/8 N/8 N/8 Sort Sort Sort Sort Sort Sort Sort Sort Merge Merge Merge Merge Merge Merge Merge Bill Thies, MIT. 90 6.189 IAP 2007 MIT Bitonic Sort Courtesy of William Thies. Used with permission. Bill Thies, MIT. 91 6.189 IAP 2007 MIT FFT Courtesy of William Thies. Used with permission. Bill Thies, MIT. 92 6.189 IAP 2007 MIT Block Matrix Multiply Courtesy of William Thies. Used with permission. Bill Thies, MIT. 93 6.189 IAP 2007 MIT Filterbank Courtesy of William Thies. Used with permission. Bill Thies, MIT. 94 6.189 IAP 2007 MIT FM Radio with Equalizer Courtesy of William Thies. Used with permission. Bill Thies, MIT. 95 6.189 IAP 2007 MIT Radar-Array Front End Courtesy of William Thies. Used with permission. Bill Thies, MIT. 96 6.189 IAP 2007 MIT MP3 Decoder Courtesy of William Thies. Used with permission. Bill Thies, MIT. 97 6.189 IAP 2007 MIT Case Study: MPEG-2 Decoder in StreamIt Bill Thies, MIT. 98 6.189 IAP 2007 MIT MPEG-2 Decoder in StreamIt MPEG bit stream picture type add VLD(QC, PT1, PT2); VLD quantization coefficients split roundrobin(N∗B, V); splitter <QC> <PT1, PT2> add splitjoin { macroblocks, motion vectors frequency encoded macroblocks differentially coded motion vectors add pipeline { add ZigZag(B); add IQuantization(B) to QC; add IDCT(B); add Saturation(B); } add pipeline { add MotionVectorDecode(); add Repeat(V, N); } ZigZag Motion Vector Decode <QC> IQuantization IDCT Repeat Saturation spatially encoded macroblocks motion vectors join roundrobin(B, V); joiner } Y add splitjoin { split roundrobin(4∗(B+V), B+V, B+V); splitter Cb Cr add MotionCompensation(4∗(B+V)) to PT1; for (int i = 0; i < 2; i++) { add pipeline { add MotionCompensation(B+V) to PT1; add ChannelUpsample(B); } } Motion Compensation Motion Compensation Motion Compensation <PT1> reference <PT1> reference <PT1> reference picture picture picture Channel Upsample Channel Upsample joiner recovered picture join roundrobin(1, 1, 1); } <PT2> Picture Reorder add PictureReorder(3∗W∗H) to PT2; add ColorSpaceConversion(3∗W∗H); Color Space Conversion Bill Thies, MIT. output to player 99 6.189 IAP 2007 MIT Teleport Messaging in MPEG-2 VLD picture type IQ splitter Y Motion Compensation MC Cr Cb Motion Compensation Motion Compensation Channel Upsample Channel Upsample MC MC joiner recovered picture Order Bill Thies, MIT. 100 6.189 IAP 2007 MIT Messaging Equivalent in C The MPEG Bitstream File Parsing Decode Macroblock ZigZagUnordering Decode Block Inverse Quantization Global Variable Space Decode Picture Saturate Decode Motion Vectors Motion Compensation IDCT Motion Compensation For Single Channel Frame Reordering Output Video Bill Thies, MIT. 101 6.189 IAP 2007 MIT MPEG-2 Implementation ● Fully-functional MPEG-2 decoder and encoder ● Developed by 1 programmer in 8 weeks ● 2257 lines of code Vs. 3477 lines of C code in MPEG-2 reference ● 48 static streams, 643 instantiated filters Bill Thies, MIT. 102 6.189 IAP 2007 MIT Conclusions ● StreamIt language preserves program structure Natural for programmers ● Parallelism and communication naturally exposed Compiler managed buffers, and portable parallelization technology ● StreamIt increases programmer productivity, enables parallel performance Bill Thies, MIT. 103 6.189 IAP 2007 MIT