Parallel programming models based on concurrent MoCs have been gaining momentum in the embedded domain, especially for describing signal processing applications. The MoC theory originated from theoretical computer science, with the goal of formally describing a computing system. It was initially used to compute bounds on complexity (the “big O” notation – O (·)). In the early 80s, MoCs were used to model VLSI circuits. Later in the 90s, they started to be applied for modeling parallel applications. The formalism behind some MoCs makes it possible to analyze application properties (timing, memory consumption). This made such programming models so attractive for embedded software.
A big collection of concurrent MoCs have been proposed for embedded program- ming. The most prominent ones are Synchronous Dataflow (SDF) [155], Cyclo-Static Dataflow (CSDF) [26], Boolean Dataflow (BDF) [153], Dynamic Dataflow (DDF) [31], Process Networks (PN) and Kahn Process Networks (KPN) [125]. These programming models have in common a directed graph representation of the application, in which nodes represent computation and edges represent logical communication channels. An example of such a graph is shown in Figure 2.6a.
Apart from explicitly exposing parallelism, MoC-based programming models became attractive for two reasons. On the one hand, they are well suited for graphical program- ming, a common specification paradigm for signal processing algorithms. On the other
32 Chapter 2. Background and Problem Definition
Firing rules:
a) b)
c)
Figure 2.6: Example of three different concurrent MoCs. a) KPN model. b) SDF model.
c) DDF model.
hand, some of the properties of the underlying MoC enable tools to perform analysis and compile the specification into both software and hardware.
Models differ from each other in their execution semantics, i.e., in the way the compu- tation is triggered and how channels are accessed. In the following, some basic MoCs are defined and some of their characteristics are introduced. A more comprehensive treatment can be found in [23, 119, 152, 226].
2.5.1.1 Synchronous Dataflow (SDF)
Definition 2.40. An SDF graph is an annotated multigraph G = (V, E, W), where nodes represent computation and edges represent queues of data items or tokens. Nodes are denoted a ∈ V and are called actors. W is a set of annotations, W = {w1, . . . , w|E|} ⊂ N3.
An annotation is a triple of integers for every edge, we = (pe, ce, de). Given a channel e = (a1, a2) ∈ E, pe represents the number of tokens produced by every execution of actor a1, ce represents the number of tokens consumed in every execution of actor a2 and de
represents the number of initial tokens present on edge e. Initial tokens are also called
delays and represent data dependencies over different iterations of the graph. SDF is also
regarded as Multi-Rate Dataflow (MRDF).
Definition 2.41. A Homogeneous SDF (HSDF) is an SDF graph G = (V, E, W) with unit token production and consumption rates, i.e., ∀e ∈ E, we = (1, 1, de). Every SDF can be
turned into an HSDF [226]. HSDFs are also regarded as Single-Rate Dataflow (SRDF). The execution of an SDF is controlled by data in its edges. Every actor is executed or fired once it has enough tokens in its input channels. The amount of tokens needed for an actor to fire is determined by the second component of the edge annotation (ce). It
has been shown that it is possible to compute a static schedule for an SDF graph [155]. In traditional SDF synthesis, the graph is unrolled to obtain a DAG representation of a sequence of firings [226]. Using this procedure, the problem of mapping an SDF is turned into a DAG problem (see Section 2.2.1).
2.5.1.2 Dynamic Dataflow
Definition 2.42. A DDF graph is a directed multigraph G = (V, E, R), with R = {Ra1, . . . , Ra|V|} a family of sets, one set for every node a ∈ V. Edges have the same semantics as in the SDF model. Actors, in turn, have a more complex firing semantics determined by a set of firing rules in R. Every actor a ∈ V has a set of firing rules Ra∈ R, Ra = {Ra,1, . . . , Ra,r}.
2.5. Parallel Code Problem 33 SDF HSDF CSDF DDF KPN PN
Figure 2.7: Graphical representation of the expressiveness of different MoCs. A graph
in an inner model can also be expressed by a graph in an outer model.
which describe a sequence of tokens that has to be available at the given input queue. Parks introduced a notation for such conditions in [197]. The condition [X1, X2, . . . , Xn]
requires n tokens with values X1, X2, . . . , Xn to be available at the top of the input queue.
The conditions [∗], [∗, ∗], [∗(1), . . . , ∗(m)] require at least 1, 2 and m tokens respectively with arbitrary values to be available at the input. The symbol ⊥ represents any input sequence, including an empty queue. For an actor a to be in the ready state at least one of its firing rules need to be satisfied.
An example of a DDF graph is shown in Figure 2.6c. In this example, the actor a2 has
3 different firing rules. This actor is ready if there are at least two tokens in input i1 and
at least 1 token in input i2 (Ra2,1), or if the next token on input i2 or i1 has value 0 (Ra2,2, Ra2,3). Notice that more than one firing rule can be activated, in this case the dataflow
graph is said to be non-determinate.
2.5.1.3 Kahn Process Networks
Definition 2.43. A KPN is a directed multigraph G = (V, E). Computational nodes in V are called processes and edges represent infinite token queues or First-In First-Out (FIFO) buffers. Processes do not feature the firing semantics of actors in dataflow graphs. Instead, they are allowed to be in two states: ready or blocked. The blocked state can only be reached by reading from only one empty input channel, commonly denoted as blocking
reads semantics. A KPN is said to be determinate, i.e., the history of tokens produced on
the communication channels does not depend on the scheduling [125]. Formally, a process is modeled as a functional mapping from input streams to output streams [125, 197].
An example of a KPN is shown in Figure 2.6a. Note that the graph does not describe how processes access channels, i.e., how processes consume and produce tokens to the channels like SDF graphs do. Each process has its own control flow and may produce and consume data with arbitrary patterns that may be controlled by incoming data. This makes KPNs flexible enough to represent a wider range of applications, but at the same time, makes it difficult to analyze them. In fact, for general KPNs it is not possible to compute a static schedule, so that they are scheduled dynamically.
2.5.1.4 Comparison of MoCs
When selecting an underlying MoC for an application specification, an implicit tradeoff be- tween expressiveness and analyzability is made. Static models (e.g., SDF) are more amenable to design-time analysis. For example, the questions of termination and boundedness, i.e.,
34 Chapter 2. Background and Problem Definition
1 __PNkpn rle_dec __PNin(int A) __PNout(int B) { 2 int cnt, i; 3 while (1) { 4 __PNin(A) { cnt = A; } 5 6 __PNin(A) { 7 for (i = 0; i < cnt; ++i) 8 __PNout(B) { B = A; } 9 }}}
10 __PNchannel int src, dec;
11 __PNprocess src = Source __PNout(src); // Defined elsewhere 12 __PNprocess rle_dec = rle_dec __PNin(src) __PNout(dec);
Listing 2.1: Sample code for RLE decoding.
whether an application runs forever with bounded memory consumption, are decidable for SDFs but undecidable for BDFs, DDFs and KPNs [197]. Static models are however not general enough to represent applications with data-dependent communication patterns. With dynamic models (e.g., DDF or KPN) this kind of behavior can be modeled. As a con- sequence of this higher expressiveness, it is more difficult to reason at design time about possible runtime configurations (mapping, scheduling and buffer sizes).
Besides analyzability and expressiveness, the complexity of specifying an application using a MoC varies. This can be measured by the amount of information a programmer has to provide in the specification. In the examples in Figure 2.6 it is clear that the KPN MoC displays the lowest specification effort and DDF the highest.
The expressiveness of some MoCs is shown graphically in Figure 2.7. In addition to the models introduced in the previous section, the figure includes CSDF and PN. CSDF is an extension to SDF that allows to model several, predefined, static, cyclic behaviors [26]. PNs are KPNs without blocking reads semantics and are therefore more general. The graphical representation in Figure 2.7 shows that an application represented in an inner model can also be represented in an outer model. Every HSDF is also an SDF, every SDF is also a CSDF and so forth. It is arguable whether or not DDF applications are a subset of KPN applications, since they can be non-determinate as discussed in Section 2.5.1.2. The figure refers to determinate DDFs.
The work presented in this thesis deals with parallel applications represented as KPNs. The motivation for addressing KPNs is twofold. (1) A simpler specification increases the acceptability of the language, making the contributions more relevant. At the same time, the software productivity is improved by a simpler language. (2) A more expressive model allows to represent modern, dynamic applications. This makes the contributions applicable to a wider range of problems.