CS 342 Lecture -*- Outline -*- * Parallelism from functional programs (may omit) ** Data dependencies Only sequencing needed is based on data dependencies tradeoff of space for parallelism (in functional lang's) if do updates in place, save space, introduce dependen. Show abstract syntax tree for (a+b) * (a-b) data flows up the tree, data dependencies can evaluate each subexpression in parallel! Data flow graph a b | | _______|________ | | __________|_________|_______ | | | | | | |____________ | V V | | _________ __v____v_ | + | | _ | |_________| |_________| \ / \ / \_______ ___________/ | | __v____v_ | * | |_________| ** Principles of data flow (Dennis, Arvind) 1. execute an operation when all its data are available 2. Operators absorb input tokens and produce 1 output token 3. Operators have no state 4. One one token per arc Compile program into data flow graph this graph is used to configure machine (static data flow) Then feed in (stream of) initial values, wait for results Leads to novel machine architectures Easier to detect parallelism in functional programs In imperative language, sequencing is fundamental, have to be careful doing things in parallel 1 P := X + Y; 2 Q := P / Y; 3 P := X * P; 4 RES := Q / P reuse of P leads to decrease in parallelism, vs. 1 P := X + Y; 2 Q := P / Y; 3 T := X * P; 4 RES := Q / T Other problems of imperative langauges: aliasing use of global variables modification of arguments to subroutines procedures with internal state ** Other approaches to parallelism *** make parallelism explict (Ada) -larger granularity of parallelism -writing programs may be harder *** Have compiler remove dependencies from data flow graph (hard)