Topic B (Cont’d) Dataflow Model of Computation

Slides:



Advertisements
Similar presentations
School of EECS, Peking University “Advanced Compiler Techniques” (Fall 2011) Parallelism & Locality Optimization.
Advertisements

Intermediate Code Generation
Programming Languages and Paradigms
Architecture-dependent optimizations Functional units, delay slots and dependency analysis.
1 Compiler Construction Intermediate Code Generation.
Expressions and Statements. 2 Contents Side effects: expressions and statements Expression notations Expression evaluation orders Conditional statements.
1 Programming Languages (CS 550) Lecture Summary Functional Programming and Operational Semantics for Scheme Jeremy R. Johnson.
The Assembly Language Level
Principles of programming languages 4: Parameter passing, Scope rules Department of Information Science and Engineering Isao Sasano.
DATAFLOW ARHITEKTURE. Dataflow Processors - Motivation In basic processor pipelining hazards limit performance –Structural hazards –Data hazards due to.
Program Representations. Representing programs Goals.
Representing programs Goals. Representing programs Primary goals –analysis is easy and effective just a few cases to handle directly link related things.
CSCI 8150 Advanced Computer Architecture Hwang, Chapter 2 Program and Network Properties 2.3 Program Flow Mechanisms.
CSC321: Programming Languages1 Programming Languages Tucker and Noonan Chapter 9: Functions 9.1 Basic Terminology 9.2 Function Call and Return 9.3 Parameters.
Chapter 1 Algorithm Analysis
Computer Architecture Computational Models Ola Flygt V ä xj ö University
Imperative Programming
CMPE 511 DATA FLOW MACHINES Mustafa Emre ERKOÇ 11/12/2003.
CS321 Functional Programming 2 © JAS Implementation using the Data Flow Approach In a conventional control flow system a program is a set of operations.
High Performance Architectures Dataflow Part 3. 2 Dataflow Processors Recall from Basic Processor Pipelining: Hazards limit performance  Structural hazards.
Software Overview. Why review software? Software is the set of instructions that tells hardware what to do The reason for hardware is to execute a program.
Array Dependence Analysis COMP 621 Special Topics By Nurudeen Lameed
Computer Science Department Data Structure & Algorithms Lecture 8 Recursion.
1 Multithreaded Architectures Lecture 3 of 4 Supercomputing ’93 Tutorial Friday, November 19, 1993 Portland, Oregon Rishiyur S. Nikhil Digital Equipment.
Functional Programming With examples in F#. Pure Functional Programming Functional programming involves evaluating expressions rather than executing commands.
Semantics. Semantics is a precise definition of the meaning of a syntactically and type-wise correct program. Ideas of meaning: –Operational Semantics.
Different parallel processing architectures Module 2.
Chapter 7 Dataflow Architecture. 7.1 Dataflow Models  A dataflow program: the sequence of operations is not specified, but depends upon the need and.
March 4, 2008http://csg.csail.mit.edu/arvindDF3-1 Dynamic Dataflow Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology.
Autumn 2006CSE P548 - Dataflow Machines1 Von Neumann Execution Model Fetch: send PC to memory transfer instruction from memory to CPU increment PC Decode.
Computer Architecture: Dataflow (Part I) Prof. Onur Mutlu Carnegie Mellon University.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Functional Programming
CS314 – Section 5 Recitation 9
Operational Semantics of Scheme
Chapter 8: Recursion Data Structures in Java: From Abstract Data Types to the Java Collections Framework by Simon Gray.
Run-Time Environments Chapter 7
Chapter 10 Programming Fundamentals with JavaScript
Functions.
Dataflow Machines CMPE 511
System Software Unit-1 (Language Processors) A TOY Compiler
Data Structure Interview Question and Answers
Chapter 2 - Introduction to C Programming
Prof. Onur Mutlu Carnegie Mellon University
CS 326 Programming Languages, Concepts and Implementation
Fall 2012 Parallel Computer Architecture Lecture 22: Dataflow I
Principles of programming languages 4: Parameter passing, Scope rules
September 4, 1997 Programming Languages (CS 550) Lecture 6 Summary Operational Semantics of Scheme using Substitution Jeremy R. Johnson TexPoint fonts.
Closures and Streams cs784(Prasad) L11Clos
Chapter 2 - Introduction to C Programming
Java Review: Reference Types
Chapter 10 Programming Fundamentals with JavaScript
Chap. 8 :: Subroutines and Control Abstraction
Chap. 8 :: Subroutines and Control Abstraction
Control Flow Chapter 6.
Chapter 6 Intermediate-Code Generation
Lecture 15 (Notes by P. N. Hilfinger and R. Bodik)
The University of Adelaide, School of Computer Science
UNIT V Run Time Environments.
Languages and Compilers (SProg og Oversættere)
CS510 Operating System Foundations
Course Overview PART I: overview material PART II: inside a compiler
Dataflow Model of Computation (From Dataflow to Multithreading)
Loop-Level Parallelism
How does the CPU work? CPU’s program counter (PC) register has address i of the first instruction Control circuits “fetch” the contents of the location.
Well-behaved Dataflow Graphs
CSE P 501 – Compilers SSA Hal Perkins Autumn /31/2019
Samira Khan University of Virginia Jan 23, 2019
Advanced Computer Architecture Dataflow Processing
Prof. Onur Mutlu Carnegie Mellon University
Presentation transcript:

Topic B (Cont’d) Dataflow Model of Computation Guang R. Gao ACM Fellow and IEEE Fellow Endowed Distinguished Professor Electrical & Computer Engineering University of Delaware ggao@capsl.udel.edu 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Outline Parallel Program Execution Models Dataflow Models of Computation Dataflow Graphs and Properties Three Dataflow Models Static Recursive Program Graph Dynamic Dataflow Architectures and Evolution of Multithreading 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Dataflow Models Static Dataflow Model Recursive Program Graphs Tagged Token Dataflow Model Also known as dynamic 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Static Dataflow Model “...for any actor to be enabled, there must be no tokens on any of its output arcs...” So-called: at most “one-token-per-arc” rule 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Conditional Expression y p if (p(y)){ f(x,y); } else{ g(y); T T F FIFO f g T F 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Example Power Function long power(int x, int n){ int y = 1; for(int i = n; i > 0; --i) y *= x; return y; } y = xn 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Power Function y = xn * -1 x 1 n T F T F T F x y f f i f i>0 T T T return y = xn 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Power Function y = 23 * -1 2 1 3 T F T F T F x y f f i f i>0 T T T return y = 23 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Power Function y = 23 * -1 T F T F T F 2 1 3 3 i>0 T T T F return 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Power Function y = 23 * -1 T F T F T F t t t i>0 1 3 2 t t t T T T return y = 23 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Power Function y = 23 * -1 T F T F T F t t t i>0 T T T F 3 2 2 1 return y = 23 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Power Function y = 23 * -1 T F T F T F t 2 t i>0 2 2 T T T F return 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Power Function y = 23 * -1 T F T F T F 2 2 2 i>0 2 T T T F return 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Power Function y = 23 * -1 T F T F T F t t t i>0 2 2 2 t t t T T T return y = 23 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Power Function y = 23 * -1 T F T F T F t t t i>0 T T T F 2 2 2 2 return y = 23 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Power Function y = 23 * -1 T F T F T F t t 2 i>0 4 1 T T T F return 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Power Function y = 23 * -1 T F T F T F 1 1 4 i>0 2 T T T F return 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Power Function y = 23 * -1 T F T F T F t t t i>0 4 1 2 t t t T T T return y = 23 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Power Function y = 23 * -1 T F T F T F t t t i>0 T T T F 1 2 2 4 return y = 23 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Power Function y = 23 * -1 T F T F T F t t 2 i>0 8 T T T F return T T T F * -1 return y = 23 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Power Function y = 23 * -1 T F T F T F 8 i>0 2 T T T F return 8 i>0 2 T T T F * -1 return y = 23 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Power Function y = 23 * -1 T F T F T F f f f i>0 f 2 8 f f T T T F 2 8 f f T T T F * -1 return y = 23 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Power Function y = 23 * -1 T F T F T F f f f i>0 T T T F 8 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

DFG Vector Addition for(i = 0; i < N; ++i) c[i] = a[i] + b[i]; a b NULL N T F T F T F T F T F < T T T F T T +1 Select Select Assign for(i = 0; i < N; ++i) c[i] = a[i] + b[i]; + c 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Static Dataflow Model Features One-token-per-arc Deterministic merge Conditional/iteration construction Consecutive iterations of a loop appear to be only subjected to sequential execution (?) A dataflow graph  activity templates Opcode of the represented instruction Operand slots for holding operand values Destination address fields Token  value + destination 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Static Dataflow Model Features Deficiencies: Due to acknowledgment tokens, the token traffic is doubled. Lack of support for programming constructs that are essential to modern programming language no procedure calls, no recursion. Advantage: simple model 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

MIT Static Dataflow Processor Architecture and Program Activity Templates Operation units Update unit queue Fetch unit Activity store + a b * Z = (a + b) * (c - d) z - c Gao and Theobald: The Static Dataflow Enable Memory Chip (fall, 1984) d 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Instructions in a Static Dataflow Architecture mult2 2 3 a c sub 2 3 ac-bd mult2 opcode 2 3 b d EC RC Destination list operand1 operand2 mult2 2 3 a d plus 2 3 ad+bc result arc mult2 2 3 b c signal arc 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Dataflow Software Pipelining X[I] Y[I] U[I] V[I] T[i] * for I in [1, n] H[i] = a * X[i] + Y[i] G[i] = b * U[i] + V[i] Z[i]= T[i] * H[i] + S[i] * G[i] end for + * H[i] b * + Z[i] G[i] + * S[i] 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Recursive Program Graphs Outlaw iterations : Graph must be acyclic One-token-per-arc-per-invocation Iteration is expressed in terms of a tail recursion 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Tail Function Application Tail-procedure application a procedure application that occurs as the last statement in another procedure; Tail-function application is a function application (appears in the body expression) whose result value is also returned as the value of the entire functions Consider the role of stack 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Normal Recursive long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } Tail Recursive 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 F T Hand Simulate fact(3) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 3 1 n==0 F T Hand Simulate fact(3) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 3 n 1 n==0 3 F T Hand Simulate fact(3) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 3 F F T Hand Simulate fact(3) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 3 F T F F Hand Simulate fact(3) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 F T 3 Hand Simulate fact(3) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 F T Hand Simulate fact(3) 3 -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact 3 * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 F T Hand Simulate fact(3) -1 2 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact 3 * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 2 1 n==0 F T 3 * fact(2) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 2 n 1 n==0 2 F T 3 * fact(2) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 2 F F T 3 * fact(2) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 2 F T F F 3 * fact(2) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 F T 2 3 * fact(2) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 F T 3 * fact(2) 2 -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact 2 * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 F T 3 * fact(2) -1 1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact 2 * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 1 n==0 F T 3 * fact(2 * fact(1)) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n 1 n==0 1 F T 3 * fact(2 * fact(1)) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 1 F F T 3 * fact(2 * fact(1)) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 1 F T F F 3 * fact(2 * fact(1)) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 F T 1 3 * fact(2 * fact(1)) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 F T 3 * fact(2 * fact(1)) 1 -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact 1 * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 F T 3 * fact(2 * fact(1)) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact 1 * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 F T 3 * fact(2 * fact(1 * fact(0))) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version n 1 n==0 F T 3 * fact(2 * fact(1 * fact(0))) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 T F T 3 * fact(2 * fact(1 * fact(0))) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 F T T T 3 * fact(2 * fact(1 * fact(0))) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 3 * fact(2 * fact(1 * fact(0))) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 1 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 F T 3 * fact(2 * fact(1 * 1)) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact 1 1 * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 F T 3 * fact(2 * fact(1 * 1)) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 1 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 F T 3 * fact(2 * 1) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact 2 1 * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 F T 3 * fact(2 * 1) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 2 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 F T 3 * 2 -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact 3 2 * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 F T 3 * 2 -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 6 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version 1 n==0 F T 6 -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 6 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Can you see where is the problem ?? 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version p long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 F F T -1 * Apply fact_1 Call fact_1(3,1) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version 3 1 long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 F F T -1 * Apply fact_1 fact_1(3,1) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version 3 n 1 long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 3 F F T -1 * Apply fact_1 fact_1(3,1) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version 1 long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 3 F F T F F -1 * Apply fact_1 fact_1(3,1) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version p long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 F F T 3 1 -1 * Apply fact_1 fact_1(3,1) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version p long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 F F T 3 3 1 -1 * Apply fact_1 fact_1(3,1) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version p long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 F F T -1 * 2 Apply fact_1 3 fact_1(3,1) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version 2 3 long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 F F T -1 * Apply fact_1 Call fact_1(2,3) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version 2 n 3 long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 2 F F T -1 * Apply fact_1 fact_1(2,3) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version 3 long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 2 F F T F F -1 * Apply fact_1 fact_1(2,3) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version p long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 F F T 2 3 -1 * Apply fact_1 fact_1(2,3) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version p long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 F F T 2 2 3 -1 * Apply fact_1 fact_1(2,3) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version p long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 F F T -1 * 1 Apply fact_1 6 Call fact_1 (1,6) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version 1 6 long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 F F T -1 * Apply fact_1 fact_1(1,6) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version 1 n 6 long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 1 F F T -1 * Apply fact_1 fact_1(1,6) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version 6 long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 1 F F T F F -1 * Apply fact_1 fact_1(1,6) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version p long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 F F T 1 6 -1 * Apply fact_1 fact_1(1,6) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version p long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 F F T 1 1 6 -1 * Apply fact_1 fact_1(1,6) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version p long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 F F T -1 * Apply fact_1 6 fact_1(1,6) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version 6 long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 F F T -1 * Apply fact_1 Call fact(0,6) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version n 6 long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 F F T -1 * Apply fact_1 fact_1(0,6) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version 6 long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 F F T T T -1 * Apply fact_1 fact_1(0,6) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version p long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 F F T -1 * Apply fact_1 fact_1(0,6) returns 6 6 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version p long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 F F T -1 * Apply fact_1 fact_1(1,6) returns 6 6 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version p long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 F F T -1 * Apply fact_1 fact_1(3,1) returns 6 6 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Tail Recursion Version p long fact_1(n, p){ if(n == 0) return p; else return fact_1(n-1, n*p); } n==0 F F T -1 * Apply fact_1 6 6 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Recursive Program Graph Features Acyclic One-token-per-link-in-lifetime Tags No deterministic merge needed Recursion is expressed by runtime copying No matching is needed (why?) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

A Quiz: y = x ^ n ? 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

A Recursive Version of Power (not tail recursive) x x n x > 0 T T Function Rec-Power (x, n : integer returns integer) Returns If n = 0 then 1 else x * rec-power (x, n - 1) endif endfun -1 n apply rec-power 1 * 20 Note: tail-recursive = iterations: i.e. the states of the computation are captured explicitly by the set of iteration variables. 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

The power function as a recursive program graph 1 apply (Rec) x n y X F T T > 0 Rec -1 function Rec (x,y,n) if n = 0 then y else Rec (x, x*y, n-1) endif end function Rec (x,1,n) 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Dynamic Dataflow Static Dataflow Dynamic Dataflow Only one token per arc Problems with Function calls, nested loops and data structures A signal is needed to allow the parent’s operator to fire Dynamic Dataflow No limitations on number of tokens per arc Tokens have tags – new firing rules and tag matching The MIT tagged token dataflow model 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

The Token in Dynamic Dataflow Token  Tag + Value [v, <u, s>, d] v : Value u : activation instance s : destination actor d : operand slot Different from Static Dataflow that it needs the tag <u,s> 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Dynamic Dataflow Loops and function calls Should be executed in parallel as instances of the same graph Arc  a container with different token that have different tags A node can fire as soon that all tokens with identical tags are presented in its input arcs 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Tags and Colors Concept of colors In a tag <u,s> - which is the color ? When a new color is generated ? When an old color is revovered ? 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version – Dynamic Dataflow 1 n==0 F T fact(3) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Factorial The Normal Version – Dynamic Dataflow 3 1 n==0 F T fact(3) -1 long fact(n){ if(n == 0) return 1; else return n * fact(n-1); } Apply fact * 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Example of Dynamic Dataflow Example A Example B 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

The Apply Operator CPEG867-2011-F-Topic-B-Dataflow-Apply-Operator 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Apply-Operator

The Apply Operator CPEG867-2011-F-Topic-B-Dataflow-Apply-Operator 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Apply-Operator

The Apply Operator CPEG867-2011-F-Topic-B-Dataflow-Apply-Operator 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Apply-Operator

The Apply Operator CPEG867-2011-F-Topic-B-Dataflow-Apply-Operator 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Apply-Operator

The Apply Operator CPEG867-2011-F-Topic-B-Dataflow-Apply-Operator 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Apply-Operator

The Apply Operator CPEG867-2011-F-Topic-B-Dataflow-Apply-Operator 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Apply-Operator

The Apply Operator CPEG867-2011-F-Topic-B-Dataflow-Apply-Operator 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Apply-Operator

Dynamic Dataflow Advantages Disadvantages More Parallelism Handle arbitrary recursion Disadvantages Implementation of the token tag matching unit Associative Memory would be ideal Not cost effective Hashing is used 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Features of Data Flow Computation Model Not history-sensitive Semantics (determinate) Parallelism 2/22/2019 \course\eleg652-98f\Topic5a.ppt

Interpreting function invocation as module substitution +2 - u v apply(F) y z X w x +2 - w x X y z (a) (b) (c) Function F Function G Function G’ Interpreting function invocation as module substitution 2/22/2019 \course\eleg652-98f\Topic5a.ppt

... ... ... ... The Apply Actor u1 un (a) Notation for apply u1 un V1 Vm apply ... u1 un (a) Notation for apply “F” V1 Vm apply ... u1 un V1 ... Vm (b) Firing Rule F is an (m,n) schema ... u1 un The Apply Actor 2/22/2019 \course\eleg652-98f\Topic5a.ppt

Concept of Strictness Intuitive: a mechanism that requires all arguments to be evaluated before evaluation of the body of a function may begin Formal : A function f is strict if f = nonstrict = not strict 2/22/2019 \course\eleg652-98f\Topic5a.ppt

Comment on Strict “Apply” Actor Advantage - Parallelism Call-by-value semantics Disadvantage: Lose “substitution” property or “referential transparency” property to avoid it, need strictness analysis 2/22/2019 \course\eleg652-98f\Topic5a.ppt

Referential Transparency “...The only thing that matters about an expression is its value, and any subexpression can be replaced by any other equal in value...” “...Moreover, the value of an expression is, within certain limits, the same when ever it occurs...” 2/22/2019 \course\eleg652-98f\Topic5a.ppt

“Referential Transparency” or “Property of Substitution” Let f,g be two procedures/functions such that f appears as an application inside of g; let g’ be the procedure obtained from g by substituting the text of f in place of the application; In the languages which are “ referential transparent”, the specification of the function for g will not depend on any terminating property of f, or g=g’. 2/22/2019 \course\eleg652-98f\Topic5a.ppt

Concept of Non-Strictness Lenient evaluation model Lazy evaluation model 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Outline Parallel Program Execution Models Dataflow Models of Computation Dataflow Graphs and Properties Three Dataflow Models Static Recursive Program Graph Dynamic Dataflow Architectures: Evolution of Multithreading 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

MIT Tagged Token Dataflow Architecture Processor Wait-Match Unit Waiting token memory (associative) Instruction Fetch Program memory Token Queue Execute OP Form Tokens Output To network From network Wait-Match Unit: Tokens for unary ops go straight through Tokens for binary ops: try to match incoming token and a waiting token with same instruction address and context id Success: Both tokens forwarded Fail: Incoming token  Waiting Token Mem, Bubble (no-op) forwarded

Memory Model and Dataflow What is “memory” in dataflow model ? What is “memory model” under dataflow model ? Concept of functional programming Concept of single-assignment and single-assignmen programming languages 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

The I Structures Single Assignment Rule and Complex Data structures Consume the entire data structure after each access The Concept of the I Structure Only consume the entry on a write A data repository that obeys the Single Assignment Rule Written only once, read many times Elements are associated with status bits and a queue of deferred reads 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

I-Structure Memory Extending dataflow abstract Machine model with I-Structure Memory Use a data structure before it is completely defined Incremental creating or reading of data structures 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

Dataflow The I Structures An element of a I-structure becomes defined on a write and it only happens only once At this moment all deferred reads will be satisfied Use a I-structure before it is completely defined Incremental creating or reading of data structures Lenient evaluation model - revisited 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

The I Structures: state transitions States Present: The element of an I-structure (e.g. A[i]) can be read but not written Absent: The element has been attempted to be read but the element has not been written yet (initial state) Waiting: At least one read request has been deferred Absent r w w Waiting Present r r w Error 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2

I Structures Elementary Used to create construct nodes: Allocate: reserves space for the new I-Structure I-fetch: Get the value of the new I-structure (deferred) I-store: Writes a value into the specified I structure element Used to create construct nodes: SELECT ASSIGN 09/07/2011 CPEG867-2011-F-Topic-B-Dataflow-Part2