Transcript

Requirements on the Requirements on the

Execution of Kahn Process Execution of Kahn Process

NetworksNetworksMarc GeilenMarc Geilen and Twan and Twan BastenBasten11 April 200311 April 2003

/e

/e

Overview

1. Introduction: Kahn Process Networks

2. Implementing KPNs

3. Execution of KPNs

4. An Improved Scheduling Algorithm

5. Conclusions

/e

1. Introduction: Kahn Process Networks

/e

Kahn Process Networks

• Arcs carry (possibly infinite) streams

of tokens

(audio samples, video frames, etc.)

a=®1®2®3

b=¯1̄ 2

f b=f(a)

• Nodes compute (continuous) functions

on streams

f

h g

i

/e

Kahn Process Networks

• Good for multimedia and signal processing

applications

E.g., JPEG/MPEG decoding, image/video processing

• Explicit parallelism and communication

• No synchronization between processes required

• Programming paradigm for modern multi-processor

architectures

MIT’s RAW, Philips’ SpaceCake

/e

KPN Semantics

• Arcs connecting functions

• Set of equations

f

h g

i

a

b=f(a)

c=h(b,e)

f=j (c)

e=i(d)

d=g(b,e)

• Continuous functions:

unique least solution

• Semantics of KPN: least fixed-point

• Yields new continuous function:

Compositionality

/e

2. Implementing KPNs

/e

Realizations of KPNs

• Functions: sequential (determinate)

programs, e.g. C++ or Java

fwhile(true) do read(a, n); write(b, 2*n);od

• Blocking read operations

/e

Realizations of KPNs

• Functions: sequential (determinate)

programs, e.g. C++ or Java

while(true) do read(a, n); write(b, 2*n);od

• Arcs: FIFO queues

Store tokens that are written but not

yet read

• Blocking read operations

/e

Realizations of KPNs

• Determinacy

Output is independent of scheduling order

• Compositionality

Hierarchically, recursively, …

• The Kahn Principle

Operational model with fair execution and

unbounded channels realizes the formal semantics

/e

SchedulerMemory

Implementation RequirementsWhen is an implementation of a KPN good?

/e

Implementation RequirementsBoundedness

SchedulerMemory

/e

Implementation RequirementsCompleteness: infinite execution vs. chain of strings

SchedulerMemory

a1a2

b1b2b3

c1

d1

a1a2a3

b1b2b3b4

c1c2

d1d2

a1a2a3a4a5...

b1b2b3b4b5...

c1c2c3...

d1d2...

/e

3. Execution of KPNs

/e

Implementations of KPNs

• FIFO bounds balance memory usage and context switching

• (Minimal) FIFO bounds are undecidable

Run-time management

• Often follow [Thomas Parks ’95] scheduling approach

YAPI, Jade/Pagis, Ptolemy II among others

• Bounded FIFOs combine aspects of data- and demand

driven execution

/e

Implementations of KPNs

• Blocking on full FIFO: artificial deadlocks

• Causal chains

er

re

wf

ee

r re

e er r

r

ee

f

er r

w

r

e

f

e

f

er

w

r

w

r

f

e

f

e

f

e

w

r

w

r

w

r

f

e

ff

e

f

e

w

w

r

w

r

w

r

/e

Implementations of KPNs

• Execution thread per process

POSIX threads, Java threads, …

• Artificial deadlock detection and resolution strategies

• Often: global deadlock detection

Low priority thread

/e

Implementations of KPNs

• Parks’ algorithm yields

infinite computation, but

possibly not complete

• Local deadlocks may

remain undetected

(fairness is violated)

e e

f f

f

e e

f f

f

• Deadlocks are cyclic causal

chains

/e

4. An Improved Scheduling Algorithm

/e

Improved Scheduling Algorithm• Deadlocks cannot be avoided by scheduling

• Artificial deadlock occurs (only) if FIFO bounds are

too small

• (At least) one of the full FIFOs on a deadlock cycle

must be too smalle e

f f

f

• Increase size of the

smallest full FIFO

/e

Improved Scheduling Algorithm

1. Schedule enabled processes (in a fair way)

2. Until deadlock occurs (cyclic causal chain)

3. Resolve deadlock by increasing the smallest full

FIFO

/e

Correctness

• Operational (LTS) semantics of KPNs (see paper)

Equivalent to KPN semantics by the Kahn Principle

• Operational semantics of realizations of KPNs

bounded channels

• Show that both implement the same function

/e

Correctness

The new scheduling algorithm realizes the the

formal semantics of Kahn Process Networks:

Every bounded and effective KPN is executed in

bounded memory by our scheduler and produces

the complete output.

/e

Correctness

• Prerequisites:

Boundedness: there exists a fair execution with

finite FIFO bounds

Effectiveness: every token that is produced on

some channels is eventually also consumed

• Both prerequisites are necessary

/e

Local deadlock detection

• Deadlock detection becomes more involved

• Need not be done at every step of the execution

• May be possible to do this concurrently

/e

Conclusions

• Studied implementation requirements for KPNs:

boundedness and completeness

• Widely used implementation of KPNs does not

schedule all KPNs correctly

• We have presented an improved scheduling

algorithm that resolves the problem for a large

class of KPNs

• And proved its correctness (in the paper)

/e

Future Work

• An implementation of the improved

scheduling algorithm is being made for YAPI

• Efficiency of scheduling. Optimal bounds,

efficient deadlock detection

• Hierarchical or distributed implementations

Distributed deadlock detection


Top Related