Requirements on the Execution of Kahn Process Networks Marc Geilen and Twan Basten 11 April 2003 /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.) Nodes compute (continuous) functions on streams
/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 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 Blocking read operations
/e Realizations of KPNs Functions: sequential (determinate) programs, e.g. C++ or Java 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 Implementation Requirements When is an implementation of a KPN good?
/e Implementation Requirements Boundedness
/e Implementation Requirements Completeness: infinite execution vs. chain of strings
/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
/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) 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 small 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