Pascal Aubry

CEA, LIST Embedded Real-Time System Lab 91191 Gif-sur-Yvette Cedex, France [email protected] [email protected]

In this paper, we present linear programming-based sufficient conditions, some of them polynomialtime, to establish the liveness and memory boundedness of general dataflow process networks. Furthermore, this approach can be used to obtain safe upper bounds on the size of the channel buffers of such a network.

1

Introduction

With the frequency version of Moore’s law coming to an end, a new generation of massively multi-core microprocessors is emerging. This has triggered a regain of interest for the so-called dataflow programming models in which one expresses computation-intensive applications as networks of concurrent tasks interacting through (and only through) unidirectional FIFO channels. Our main result is a linear programming model (Sect. 2) of the states of a general Dataflow Process Network (DPN), in the sense of Lee & Parks [1], which allows to obtain a polynomial-time sufficient condition for both liveness (in a sense which is defined in Sect. 3) and memory boundedness (Sect. 4). Furthermore, this approach can be turned into a safe buffer dimensioning method.

2 2.1

Modelling system states Notations and general assumptions

Let T and F respectively denote the set of tasks and channels. (0) (0) To each task t ∈ T , we associate a state-transition graph Gt = ({vt } ∪ Vt , {τt } ∪ At ) (parallel (0) (0) arcs and loops are allowed), where vt denotes the initial state of task t and where τt denotes the initial transition of that task, this transition being unique and unconditional. Also, given t ∈ T , Pt ⊆ F (respectively Ct ⊆ F) denotes the set of channels in which t produces (respectively consumes) data. Note that we have Pt ∩ Ct = 0. / Also note that for each t,t 0 ∈ T 2 , t 6= t 0 , we have Pt ∩ Pt 0 = 0/ as well as Ct ∩Ct 0 = 0. / Let t ∈ T , τ ∈ At and f ∈ Pt (respectively f ∈ Ct ), qpτ f (respectively qcτ f ) denotes the amount of data produced (respectively consumed) in channel f by task t when transition τ is executed. An additional constraint is that, ∀t ∈ T , ∀τ ∈ At ,

∑ qpτ f + ∑ qpτ f > 0,

f ∈Pt

(1)

f ∈Ct

thereby excluding the existence of transitions having no effect on any of the channels. Bliudze, Bruni, Grohmann, Silva (Eds.): Third Interaction and Concurrency Experience (ICE 2010) EPTCS 38, 2010, pp. 115–119, doi:10.4204/EPTCS.38.11

c R. Sirdey & P. Aubry

This work is licensed under the Creative Commons Attribution License.

116

A linear programming approach to general DPN verification and dimensioning

Given f ∈ F, p f and c f respectively denote the tasks which produce and consume data in channel f . Also, d f denote the capacity of the buffer associated to channel f (depending on the problem at hand d f can be either given or unknown, as we shall later see). In the sequel, it is further assumed without loss of generality that the network graph, the directed graph having the tasks as vertices and the channels as arcs, is (simply) connected.

2.2

Variables and linear constraints (0)

For all τ ∈ t∈T {τt } ∪ At , we introduce a variable denoted by nτ ∈ Z+ which indicates the number of times transition τ has been executed. In order for the nτ to represent admissible system states, a number of (linear) constraints must be satisfied. (0) Initialization constraints. Let t ∈ T , initial transition τt must have been executed once and only once, thus, nτ (0) = 1. t Conservation constraints. Let t ∈ T and v ∈ Vt . We then have the following constraint: S

∑

nτ − 1 ≤

τ∈ω − (v)

∑

nτ ≤

τ∈ω + (v)

∑

nτ .

τ∈ω − (v)

Such a constraint simply reflects the fact that for the nτ ’s to represent an admissible system state, vertex v must have been left as many times it has been entered or as many times minus one (in which case it defines the current state of t). If ∑τ∈ω + (v) nτ = ∑τ∈ω − (v) nτ − 1, then the system state described by the nτ ’s is such that task t is in state v. For convenience, let γv = ∑τ∈ω − (v) nτ − ∑τ∈ω + (v) nτ meaning that γv = 0 if task t is not in state v and (0) 1 otherwise. Remark that state vt is duly excluded from the previous sums as this state is by definition left once and never entered. Unicity constraints. Furthermore, for the system state described by the nτ ’s to be admissible, each (0) task must be in one and only one state. That is, for each t ∈ T , if ∑v∈Vt γv = 1. Again, note that vt is duly excluded from the previous sum. Consistency constraints. Let f ∈ F, let qp f = ∑τ∈A p nτ qpτ f and qc f = ∑τ∈Ac nτ qcτ f respectively f f denote the amount of data so far produced and consumed on channel f (for convenience). For the nτ ’s to describe a valid system state, we must have qp f ≥ qc f . Capacity constraints. Also, for each f ∈ F, we must have qp f − qc f ≤ d f .

3 3.1

(2)

Modelling undesirable system properties Strong and weak blockedness

In a given system state, a task t ∈ T is strongly blocked when it is in a state v in which no outgoing transition can be executed. Consider the following sets of constaints, for each τ = (v, v0 ) ∈ At , (3) γv ≤ 0, qp f − qc f ≤ qcτ f − 1, for each f ∈ Ct , (4) qc − qp ≤ qp − d − 1, for each f ∈ Pt . (5) f f f τf

R. Sirdey & P. Aubry

117

Then, strong blockedness means that for each τ = (v, v0 ) ∈ At either constraint (3) or at least one the constraints of type (4) or at least one of the constraints of type (5) is satistifed for task t. In a given system state, a task t ∈ T is weakly blocked when it is in a state v in which not all outgoing transitions can be executed. Consider the following sets of constraints, for each t ∈ T and for each v ∈ Vt , (6) γv ≤ 0, 0 qp f − qc f ≤ qcτ f − 1, for each τ = (v, v ) ∈ At and for each f ∈ Ct , (7) qc − qp ≤ qp − d − 1, 0 for each τ = (v, v ) ∈ A and for each f ∈ P . (8) f

f

τf

f

t

t

Then, weak blockedness signifies that for each t ∈ T and for each v ∈ Vt either constraint (6) or at least one the constraints of type (7) or at least one of the constraints of type (8) is satistifed for task t. The above strong blockedness property is suitable to model non deterministic tasks whereas the weak blockedness property allows modelling deterministic ones (enforcing the fact that, when the task is in a given state, all outgoing transitions are feasible so as to guarantee that the next transition the task has to do is possible).

3.2

Sufficient liveness conditions

Although the definitions of the strong and weak blockedness properties involves disjunctive constraints, these can be linearized using standard linear programming modelling techniques (see e.g., [2]). Thus, given a DPN and a dimensioning d ∈ Z|F| we have shown how to formulate an integer linear system of inequalities, (9) {x ∈ Zn : Ax ≤ b(d)} which inconsistency, i.e. {x : Ax ≤ b(d), x ∈ Zn } = 0, / is sufficient to establish the liveness of the network. A fortiori, the inconsistency of the continuous relaxation of that system, {x : Ax ≤ b(d), x ∈ Rn } = 0, / provides a polynomial-time (weaker) sufficient condition to establish that property.

4 4.1

Memory boundedness of a DPN Monotony with respect to dimensioning

As shown by Lee & Parks [1] the DPN formalism is equivalent to the well-known Kahn Process Networks (KPN) formalism. Thus, DPN also exhibit the determinism property exhibited by KPN whereby, for a given input, the data circulating on the channels does not depend on the execution trace. This very convenient property allows, still for a given input, to derive general network properties from properties exhibited by particular traces of execution. The KPN formalism assumes blocking reads and non blocking writes, which may induce an infinite memory requirement on some channels. However, a KPN K subject to capacity constraints on its channels can straightforwardly be turned into another KPN K(d) (d ∈ Z+n ): all is needed is to emulate a blocking write with a blocking read e.g., to mirror each channel f by an opposite channel f 0 initially provided with d f data and to require that each write, respectively read, operation on f be mirrored by a equivalent read, respectively write, operation on f 0 . Of course, the properties of KPN K with respect to the data circulating on the channels are not preserved by this transformation and, in particular, K(d) may not be deadlock-free despite of the fact that K is. In essence, the liveness property defined in the previous section ensures that, for all possible inputs, an infinite amount of data circulates on at least one channel. Assume that a KPN K(d) is live, then

118

A linear programming approach to general DPN verification and dimensioning

a straightforward consequence of the determinism property of KPN is that any KPN K(d 0 ) such that d 0 ≥ d (i.e., ∀ f ∈ F, d 0f ≥ d f ) is also live. Indeed, the liveness of K(d) implies that, for any input α, any given trace of execution ω(α) of K(d) is such that an infinite amount of data circulates on at least one channel and since ω(α) is also a valid trace of execution of K(d 0 ), from the determinism property, all traces of execution of K(d 0 ) on α are also such that an infinite amount of data circulates on at least one channel and, thus, K(d 0 ) is live. It follows that, given a DPN, if we can find d ∈ Z|F| such that either {x : Ax ≤ b(d), x ∈ Zn } = 0/ or {x : Ax ≤ b(d), x ∈ Rn } = 0, / then for any d 0 ∈ Z|F| such that d 0 ≥ d, the DPN is live.

4.2

Verifying memory boundedness

Recall integer linear system (9), assume that d f = z (∀ f ∈ F) and consider the following Integer Linear Program zIP = Maximize z A0 y ≤ b0 , y ∈ Zn+1 , (10) where vector y is the concatenation of vector x and scalar z. This program is straightforwardly derived from system (9) by replacing d f by z in constraints (2) as well as constraints (5) or (8) (depending on which of the two applies) and by moving z to the LHS. In essence, from the monotony property derived in Sect. 4.1, any solution to the above program provides the largest value of z such that the network is not live and, thus, for any dimensionning d ∈ Z|F| such that ∀ f ∈ F, d f ≥ zIP the network is live. Three cases can then occurs. Case 1: the ILP has no solution, a degenerate case which can occur only for networks with no channels (since, due to Eq. (1), all transitions are effective). This latter case in hereafter ignored. Case 2: zIP < ∞, which is sufficient to establish that the network is live and memory bounded. Case 3: zIP = ∞ in which case we cannot conclude with respect to both liveness and memory boundedness. Furthermore, when zIP < ∞, letting d f = zIP +1 (∀ f ∈ F) gives a (presumably small) channel buffer dimensioning which guarantees liveness. Again, it is possible to consider the continuous relaxation zLP of program (10). In particular, when one wishes only to determine wether or not zIP < ∞ then it is necessary and sufficient to determine whether or not zLP < ∞ as zIP < ∞ ⇔ zLP < ∞. Indeed, a well known fact in the theory of linear and integer programming [2] states that if the integer hull PI of a rational polyhedron P (i.e., the convex hull of the integral vectors in P) is nonempty then max{cx : x ∈ P} is bounded if and only if max{cx : x ∈ PI } is bounded and, provided that 0 ∈ {y : A0 y ≤ b0 , y ∈ Zn+1 }, this result applies to program (10) and its relaxation. It follows that zLP < ∞ provides a polynomial-time sufficient condition to establish both liveness and boundedness of a DPN which is equivalent to zIP < ∞.

5

Remarks on algorithmic aspects

Although zLP can be computed in polynomial-time, it can be expected, when zLP < ∞, that the integrality gap, zLP − zIP , is often quite large. Thus, should one wishes to obtain a tight (if not the tightest) upper bound on the channel buffer dimensioning, there is a practically relevant need to either solve program (10) or at least to decrease the aforementioned integrality gap. Regarding the resolution of program (10), it should be emphasized that the polyhedron PI = {y : A0 y ≤ 0 b , y ∈ Zn+1 } (recall that the integer hull of a polyhedron is also a polyhedron) is generally not a polytope

R. Sirdey & P. Aubry

119

(since the nτ are not necessarily bounded). Therefore, in the general case, procedures which enumerate integer points inside the polyhedron, as those used in most off-the-shelf integer linear programming solvers, are doomed not to terminate. Thus, in order to guarantee termination in the present context, an (exterior) cutting plane approach must be used. As an example, Gomory’s cutting plane algorithm is guaranteed to terminate (though generally after a prohibitively long time). A more practically promising approach, consists in using specially tailored classes of inequalities derived from a polyhedral study of the geometric structure of PI so as to derive a custom cutting plane algorithm.

References [1] E. A. Lee & T. M. Parks (1995): Dataflow process networks, Proceedings of the IEEE 83(5), pp. 773-779. [2] G. L. Nemhauser and L. A. Wolsey (1999): Integer and combinatorial optimization, Wiley.