Program Flow Mechanism

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 14

Advanced Computer Architecture

Program Flow Mechanisms


Program Flow Mechanisms
There are three flow mechanism
 Control flow mechanism(used by conventional
computers)
 Data-driven mechanism(used by data-flow
computers)
 Demand-driven mechanism(used by reduction
computers)
Control flow mechanism(used
Conventional von Neumann computers use a
program counter to sequence the execution of
instruction in a program. This sequential execution
style is called control-driven.
Conventional computers are based on a control
flow mechanism by which the order of program
execution is explicitly stated in the user programs
Control flow computers use sheared memory to
hold program instructions and data objects.
A uniprocessor computers is inherently
sequential ,due to use of the control-driven
mechanism.

Control flow can be made parallel by using parallel


language constructs or parallel compiler.

Control flow machines give complete control, but


are less efficient than other approaches.
Data-driven mechanism
Dataflow computers are based on a data-driven
mechanism which allows the execution of any
instruction to be driven by data (operand)
availability. Dataflow computers emphasize a high
degree of parallelism at the fine-grain instructional
level.
Data flow machines have high potential for
parallelism and throughput and freedom from side
effects, but have high control overhead, lose time
waiting for unneeded arguments, and difficulty in
manipulating data structures.
Data Flow Features
No need for
shared memory
program counter
control sequencer
Special mechanisms are required to
detect data availability
match data tokens with instructions needing them
enable chain reaction of asynchronous instruction
execution
Control Flow vs. Data Flow
Control flow machines used shared memory for instructions
and data. Since variables are updated by many instructions,
there may be side effects on other instructions. These side
effects frequently prevent parallel processing. Single
processor systems are inherently sequential.
Instructions in dataflow machines are unordered and can
be executed as soon as their operands are available; data is
held in the instructions themselves. Data tokens are
passed from an instruction to its dependents to trigger
execution.
Demand-Driven Mechanisms
Data-driven machines select instructions for execution
based on the availability of their operands; this is
essentially a bottom-up approach.
Demand-driven machines take a top-down approach,
attempting to execute the instruction (a demander) that
yields the final result. This triggers the execution of
instructions that yield its operands, and so forth.
The demand-driven approach matches naturally with
functional programming languages (e.g. LISP and
SCHEME).
Reduction Machine Models
String-reduction model:
each demander gets a separate copy of the expression string to evaluate
each reduction step has an operator and embedded reference to
demand the corresponding operands
each operator is suspended while arguments are evaluated
Graph-reduction model:
expression graph reduced by evaluation of branches or subgraphs,
possibly in parallel, with demanders given pointers to results of
reductions.
based on sharing of pointers to arguments; traversal and reversal of
pointers continues until constant arguments are encountered.
Summary
Reduction machines have high parallelism potential, easy
manipulation of data structures, and only execute required
instructions. But they do not share objects with changing
local state, and do require time to propagate tokens.
example
Consider the following example of a arithmetic
expression :
a=[(b+1) * c – (d / e)]

The data-driven computation chooses a bottom-up


approach , starting from b+1 and d / e then
proceding to the ‘*’ operation finally to the
outermost operation.
A demand-driven computation chooses a top-
down approach by first demanding the value of
‘a’ ,which triggers the demand for evaluating the
next level expression (b+1)*c and d/e ,which in
turns triggers the demand for evaluating b+1 at
the inner most level.
The result are returned to the nested demander in
the reverse order before ‘a’ is evaluated.
A data-driven computation has been called eager
evaluation because operation are carried out
immediately after all their operands becomes
available.
a demand-driven computation corresponds to lazy
evaluation because operation are executed only
when their result are required by another
instruction.

You might also like