33
on Kahn process networks and reactive process networks Marc Geilen and Twan Basten Eindhoven University of Technology Department of Electrical Engineering Design Methodology for Electronic Systems [email protected]

on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

on Kahn process networks and reactive process networks

Marc Geilen and Twan BastenEindhoven University of TechnologyDepartment of Electrical Engineering

Design Methodology for Electronic Systems

[email protected]

Page 2: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

application domain

Kahn Process Networks (KPN)

automata /state machinesReactive Process Networks (RPN)

Synchronous Data Flow (SDF)

Page 3: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

dataflow MoCs• use (C)SDF where possible(presentations Sander Stuijk, Bart Theelen)

• use KPN for data-dependent streaming• dynamic generation and reconfiguration of process networks

• interaction with non-streaming parts of anapplication

Page 4: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

Kahn Process Networks

Page 5: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

Kahn Process Networks

[Kahn 1974]

processes communicating via unbounded fifo queues

•reads block on empty queues•writes may never block•no global variables

Page 6: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

denotational semanticsprocesses: functions from input strings to

output stringsfifos: connect functions, hold (window on)

strings

compositionalityif functions are continuous, then a network is also a continuous function

fixpoint semanticscontinuous function of a network is the leastfixpoint of a set of fixpoint equations

Page 7: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

strengths & weaknesses• compositionality• determinacy (execution order and timing)• explicit concurrency• explicit communication• captures data-dependent streaming behavior• high abstraction level• needs run-time resource management• cannot capture asynchronous reactive behaviour• undecidable, e.g., minimal buffer sizes

(‘Turing complete’)

Page 8: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

implementing KPNs

Page 9: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

realizations of KPNs

• functions: sequential programs e.g. C(++) or Java

f• read and write operations

Page 10: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

realizations of KPNs

• functions: sequential programs e.g. C(++) or Java while(true) do read(a, n); write(b, 2*n);od

• arcs: FIFO queuesstore tokens that are written but not yet read

• read and write operations

Page 11: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

implementations of KPNs• usually follow Thomas Parks’ scheduling approach (YAPI, Ptolemy II, among others)

• bounded FIFOs combine aspects of data- and demand driven execution

Page 12: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

implementations of KPNs• FIFO bounds balance memory usage and context switching

• risk for artificial deadlocks• run-time management of FIFO bounds

e e

f f

f

r

r

ww

w

Page 13: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

requirements [Parks, ESOP03]

boundednessfifo bounds may not grow indefinitely if a bounded execution exists

completenessprogress must be made on all outputs as prescribed by the denotational semantics

Page 14: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

scheduling KPNstraditional execution model [Parks, 95] does not (always) follow Kahn’s semantics [ESOP03]

e e

f f

f

e e

f f

f

Page 15: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

improved KPN scheduler• a scheduler that is correct for every KPN

cannot exist! [ESOP03]• a scheduling algorithm has been defined which is correct for every bounded and “effective” KPN it is executed in bounded memory by our scheduler and produces the complete output

• prototype implementation in YAPI and by other (Olson and Evans, 2005)

Page 16: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

improved KPN scheduler

1. schedule enabled processes (in any fair way)2. until (local) deadlock occurs 3. resolve deadlock if artificial by increasing

smallest full FIFO

Page 17: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

Reactive Process Networks

Page 18: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

reactive behaviour and dataflow

• indeterminate behaviour• non-functional input-output relations• Brock-Ackerman anomaly• ‘select’ primitive in YAPI• predictability

Page 19: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

i o

the basic idea...

c

gf

jh c

ba

e

c

gf

jh c

ba

e

Page 20: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

3d videomode changeparameters / user interact ion parameters /user interact ion

object -based renderingscene graph & physics sg

nrObj f i lter & overlay

mode change

fr

control

dynamic stream processing

streaming kernels

scene graphs framesadd/ remove object renderers ...

3d videomode changeparameters / user interact ion parameters /user interact ionmode change

control

example

Page 21: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

reconfiguration of streams• PN computes functions on data streams• conceptually, the response is immediate• computation of the results takes time and is pipelined in practice

• how to reconfigure with data in the pipeline?

oi o=f(i)

Page 22: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

reconfiguration of streams• reconfiguration should not have an effect onthe outcome of the computation for input thathas already been consumed

• reconfiguration should take place at ‘quiescent’ points

• but flushing the pipeline may be unaffordable

Page 23: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

compositionality• event handling encapsulated in a streamingcomponent

• functional behaviour?• this would lead to excessive synchronisation• not enforced by the model

Page 24: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

semantics of RPN• denotational semantics as input/output relation doesn’t work (well) for indeterminate dataflow

• hence, we built an operational semanticsas a Labelled Transition System using SOS rules

• hierarchical and compositional

Page 25: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

interface

streaming input channels

event input channels

streaming output channels

reconfiguration cannotchange the interface of a componentstreaming output channels are usedto send events

Page 26: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

configurations

sg fr

nrObj

sg fr

network structurelocal process states

channel contents

Page 27: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

transitions

• reading tokens from streaming inputs• writing tokens to streaming outputs• reading tokens from event inputs, followedby a corresponding reconfiguration

transitions from one configuration to the nextcaused by:

Page 28: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

operational semantics

Page 29: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

operational semantics

Page 30: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

prioritizing events

?

theory: both options straightforwardpractice: choice

consumption of data allowed when events are present ?

Page 31: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

f r !f r1 sg?sg3 sg?sg4f r !f r1 f r !f r1

sg?sg3 sg?sg4f r !f r2 f r !f r2 f r !f r2

sg?sg3 sg?sg4f r !f r3 f r !f r3

sg?sg5f r !f r 1

sg?sg5f r !f r 2

sg?sg5f r !f r 3

sg?sg4 sg?sg5f r !f r4 f r !f r 4

sg?sg5f r !f r5

f r !f r1sg?sg1 sg?sg2sg?sg2 sg?sg1fr!fr1 sg?sg2fr!fr2 sg?sg3fr!fr3 sg?sg4fr!fr4 sg?sg5fr!fr5

sg?sg1sg?sg2f r !f r1f r !f r2sg?sg3f r !f r3sg?sg4sg?sg5f r !f r4f r !f r5

f r !f r1 sg?sg3 sg?sg4f r !f r1 f r !f r1

sg?sg3 sg?sg4f r !f r2 f r !f r2 f r !f r2

sg?sg3 sg?sg4f r !f r3 f r !f r3

sg?sg5f r !f r 1

sg?sg5f r !f r 2

sg?sg5f r !f r 3

sg?sg4 sg?sg5f r !f r4 f r !f r 4

sg?sg5f r !f r5

f r !f r1sg?sg1 sg?sg2sg?sg2

operational semantics

maximal

Page 32: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

prototype implementation• based on YAPI, C++ implementation of KPN• adds event input ports• arriving events trigger functions• runtime system ensures flushing of the component before calling event handler

• events have priority over consumption of new input data

Page 33: on Kahn process networks and reactive process networks · reactive process networks Marc Geilen and TwanBasten ... pipelinedin practice • howto reconfigurewithdata in the pipeline?

open issues, future work• case studies (ease of modelling, expressivity)• distribution• additional control over reconfiguration points• timing prediction

– reconfiguration/reaction times for events• restricted modelsreactive BDF, reactive (C)SDF