8.4 Buffer size dimensioning
8.4.3 Minimization by the use of a model predictive control approach
As previously discussed, the problem of bounding and minimizing the buffer size configuration of a dataflow program, without impacting the performance and guaranteeing at the same time a deadlock-free execution, has been proven to be an NP-complete problem. Consequently, it requires the use of heuristic algorithms. In this section, this problem is solved using ETG transformation and treating the program like a linear-discrete event system as illustrated in Section 5.5.3. Considering an ETG with nS= |S| firings, the problem of bounding (and
execution, can defined as: minimize u(k),u(k+1),...,u(k+nS) J = nS X k b X j y(k)j subject to Equation (5.16) y(k)j≥ 0, ∀k ∈ {1, 2, . . . , nS}, ∀j ∈ {1,2,...,b} nS X i u(k)i= 1, ∀k ∈ {1, 2, . . . , nS} nS X k u(k)i= 1, ∀i ∈ {1, 2, . . . , nS} (8.35)
where y(k)jrepresents the j -th component of y(k), i.e. the number of tokens available on
the j -th buffer, the constraintPnS
i u(k)i= 1, ∀k ∈ {1, 2, . . . , nS} requires that a firing si ∈ S is
executed at each event k, while the constraintPnS
k u(k)i= 1, ∀i ∈ {1, 2, . . . , nS} requires that
a step must be fired only once (i.e. the deadlock condition is avoided because all the steps in S must be fired). In other words, executing only one firing at each event k, can also be seen as finding a topological order of S for which the sum of all the available tokens along the dataflow network is minimized during the entire execution. However, the problem defined in Equation (8.35) is an integer linear programming (ILP) problem, where the number of optimization variables and constraints can grow significantly according to the ETG size nS.
Consequently, a heuristic algorithm should be applied. For instance, find a feasible scheduling sequence of the ETG such that the buffer size is kept bounded and, if possible, minimized, guaranteeing a deadlock-free execution for all the action firings in S. When dealing with large- data graphs some well-known heuristics, such as graph-cutting or pattern recognition, can be successfully used to reduce the problem size. The heuristics that are illustrated in the following rely on both the formalism of the graph and automatic control theory to minimize the size and to find a sub-optimal solution to Problem (8.35). Model predictive control (MPC) [198, 199] is a receding horizon-control technique where at each event, an optimization problem is solved by predicting the future system behavior (i.e. see Appendix B). Bearing in mind the transformations discussed in Section 5.5.3, it is possible to define an MPC approach that makes use of the ETG, and where the prediction and control horizons are related to the graph-cut used for reducing the problem size.
Deadlock avoidance
As discussed in Section 5.3, one of the main properties of an ETG is that it is completely inde- pendent from any buffer size configuration. Moreover, an ETG can have different topological orders with different minimal buffer size requirements for admitting a deadlock-free execution. Therefore, the initial problem can be relaxed: sorting at each event k ∈ {1,2,3,...nS} only one
firing, then the optimization problem of Equation (8.35) can be solved iteratively only for a limited set of firings. Consequently, this problem can be solved using the receding horizon control technique through the use of an MPC controller. In this case, the prediction horizon
8.4. Buffer size dimensioning
Hp defines the number of firings of each ETG-cut. At each event k an ETG-cut S(k)0Hp⊆ S
is evaluated so that it contains only Hp unscheduled firings of S with the lowest available
topological order. Then, according to the procedure just described, the optimization problem can be formulated as:
minimize u(k|k),u(k+1|k),...,u(k+Hc−1|k) J (k) = Hp X i b X j y(k + i |k)j subject to y(k + j |k)i≥ 0, ∀ j , i ∈ {1, 2, . . . Hp} Hp X i u(k + j |k)i= 1, ∀ j ∈ {0, 1, 2, . . . Hc− 1} Hp X i u(k + j |k)i= 0, ∀ j ∈ {Hc, Hc+ 1, . . . Hp} (8.36)
where Hc(i.e. the control horizon) is the number of firings that can be executed (i.e. ordered)
inside S(k)0H
p. At each event k only the first selected firing defined by u(k)
∗ = u(k|k) is
executed. When firing the step defined by u(k)∗the number of tokens inside each buffer is updated accordingly. The minimal buffer size configuration can be defined as the maximal token capacity of each buffer obtained during the entire execution only when all the firings have been executed. In other words, the bounded buffer size configuration is evaluated as:
β(bi)mi n= max{y(k)i, ∀k ∈ {1,2,3,...,nS}} (8.37)
Whereβ(bi)mi ndefines the minimal bounded size of each buffer bi∈ B required for scheduling
the ETG. Consequently, the minimal buffer size configuration which defines the borders between the deadlock region and feasible region depicted in Figure 8.7 can be defined as:
βmi n= {β(b1)mi n,β(b2)mi n, . . . ,β(bnB)mi n} (8.38)
The flowchart of this approach is depicted in Figure 8.8. It must be noted that, if this analysis is performed on a collection of ETGs, then the minimal size value of each buffer is the maximal value obtained within the ETGs collection.
Deadlock recovery
In the previous approach, the problem of Equation (8.36) should be solved nStimes. Another
approach, that reduces the number of time that this problem should be solved, is to schedule post-mortem the ETG using a dynamic buffer size configuration that is modified each time that a deadlock condition arises (i.e. the ETG has not action firing that cannot be scheduled because some buffers are full). This second approach can be considered as an improvement of the one introduced in [195], where the key idea is to recover only a blocked action from a deadlock execution that produces the highest number of tokens that could resolve the deadlock condition. However, it must be noted that in [195] any minimization cost function
can be used based on the prediction of the program execution and buffer utilization. On the contrary, with this second approach, when a deadlock condition arises, a trace sub- graph S(k)0H
p is evaluated as previously described. Successively, the problem of Equation
(8.35) is solved in order to identify the next schedulable firings as done for the approach that avoids deadlocks. Hence, the found fired action is scheduled supposing, only at this time, an unbounded buffer size configuration. The new maximum token capacity of each buffer is then used from the successive scheduling, as a new buffer size configuration. It is worth noting that, initially the size of all the buffers can be set as 0 tokens. Only when all the action firings have been scheduled can the bounded buffer size configuration be defined as the maximal token capacity of each buffer obtained during the entire ETG post-mortem scheduling, as defined in Equation (8.37). The flowchart of this approach is depicted in Figure 8.9.