The Combinatorics of Barrier Synchronization
Olivier Bodini, Matthieu Dien, Antoine Genitrini, Fr\'ed\'eric, Peschanski

TL;DR
This paper explores the combinatorial aspects of barrier synchronization, providing formulas and algorithms for counting and randomly generating process executions without explicit state-space construction.
Contribution
It introduces a systematic combinatorial approach and efficient algorithms for counting and sampling process executions in barrier synchronization.
Findings
Developed a symbolic integral formula for counting executions
Created a generic algorithm for uniform random sampling
Proposed efficient algorithms for specific process subclasses
Abstract
In this paper we study the notion of synchronization from the point of view of combinatorics. As a first step, we address the quantitative problem of counting the number of executions of simple processes interacting with synchronization barriers. We elaborate a systematic decomposition of processes that produces a symbolic integral formula to solve the problem. Based on this procedure, we develop a generic algorithm to generate process executions uniformly at random. For some interesting sub-classes of processes we propose very efficient counting and random sampling algorithms. All these algorithms have one important characteristic in common: they work on the control graph of processes and thus do not require the explicit construction of the state-space.
| Algorithm | Class | Count. | Unif. Rand. Gen. | Reference |
|---|---|---|---|---|
| FJ | Fork-join | on average | [6] | |
| Arch | Arch-processes | worst case | [7]/Theorem 19 | |
| bit | BIT-decomposable | ? | ? | Theorem 10 |
| cftp666The cftp algorithm is the only one we did not design, but only implement. Its complexity is (randomized) expected time. | All processes | – | expected | [14] |
| FJ size | FJ gen | (count) | bit gen | (count) | cftp gen | |
|---|---|---|---|---|---|---|
| 10 | 19 | 0.00001 s | (0.0002 s) | 0.0006 s | (0.03 s) | 0.04 s |
| 30 | 0.00002 s | (0.0002 s) | 0.02 s | (0.03 s) | 1.8 s | |
| 40 | 0.00004 s | (0.0003 s) | 3.5 s | (5.2 s) | 5.6 s | |
| 63 | 0.0005 s | (0.03 s) | Mem. crash | (Crash) | 55 s | |
| 217028 | 8.11 s | (3.34 s) | Mem. crash | (Crash) | Timeout |
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
The Combinatorics of Barrier Synchronization*†*111
† This research was partially supported by the ANR MetACOnc project ANR-15-CE40-0014.
Olivier Bodini
Laboratoire d’Informatique de Paris-Nord, CNRS UMR 7030 - Institut Galilée - Université Paris-Nord, 99, avenue Jean-Baptiste Clément, 93430 Villetaneuse, France.
,
Matthieu Dien
Université de Caen – GREYC – CNRS UMR 6072.
,
Antoine Genitrini
Sorbonne Université, CNRS, Laboratoire d’Informatique de Paris 6 -LIP6- UMR 7606, F-75005 Paris, France.
and
Frédéric Peschanski
Sorbonne Université, CNRS, Laboratoire d’Informatique de Paris 6 -LIP6- UMR 7606, F-75005 Paris, France.
Abstract.
In this paper we study the notion of synchronization from the point of view of combinatorics. As a first step, we address the quantitative problem of counting the number of executions of simple processes interacting with synchronization barriers. We elaborate a systematic decomposition of processes that produces a symbolic integral formula to solve the problem. Based on this procedure, we develop a generic algorithm to generate process executions uniformly at random. For some interesting sub-classes of processes we propose very efficient counting and random sampling algorithms. All these algorithms have one important characteristic in common: they work on the control graph of processes and thus do not require the explicit construction of the state-space.
Key words and phrases:
Barrier synchronization Combinatorics Uniform random generation.
1. Introduction
The objective of our (rather long-term) research project is to study the combinatorics of concurrent processes. Because the mathematical toolbox of combinatorics imposes strong constraints on what can be modeled, we study process calculi with a very restricted focus. For example in [5] the processes we study can only perform atomic actions and fork child processes, and in [4] we enrich this primitive language with non-determinism. In the present paper, our objective is to isolate another fundamental “feature” of concurrent processes: synchronization. For this, we introduce a simple process calculus whose only non-trivial concurrency feature is a principle of barrier synchronization. This is here understood intuitively as the single point of control where multiple processes have to “meet” before continuing. This is one of the important building blocks for concurrent and parallel systems [13].
Combinatorics is about “counting things”, and what we propose to count in our study is the number of executions of processes wrt. their “syntactic size”. This is a symptom of the so-called “combinatorial explosion”, a defining characteristic of concurrency. As a first step, we show that counting executions of concurrent processes is a difficult problem, even in the case of our calculus with limited expressivity. Thus, one important goal of our study is to investigate interesting sub-classes for which the problem becomes “less difficult”. To that end, we elaborate in this paper a systematic decomposition of arbitrary processes, based on only four rules: (B)ottom, (I)ntermediate, (T)op and (S)plit. Each rule explains how to “remove” one node from the control graph of a process while taking into account its contribution in the number of possible executions. Indeed, one main feature of this BITS-decomposition is that it produces a symbolic integral formula to solve the counting problem. Based on this procedure, we develop a generic algorithm to generate process executions uniformly at random. Since the algorithm is working on the control graph of processes, it provides a way to statistically analyze processes without constructing their state-space explicitly. In the worst case, the algorithm cannot of course overcome the hardness of the problem it solves. However, depending on the rules allowed during the decomposition, and also on the strategy adopted, one can isolate interesting sub-classes wrt. the counting and random sampling problem. We identify well-known “structural” sub-classes such as fork-join parallelism [11] and asynchronous processes with promises [15]. For some of these sub-classes we develop dedicated and efficient counting and random sampling algorithms. A large sub-class that we find particularly interesting is what we call the “BIT-decomposable” processes, i.e. only allowing the three rules (B), (I) and (T) in the decomposition. The counting formula we obtain for such processes is of a linear size (in the number of atomic actions in the processes, or equivalently in the number of vertices in their control graph). We also discuss informally the typical shape of “BIT-free” processes.
The outline of the paper is as follows. In Section 2 we introduce a minimalist calculus of barrier synchronization. We show that the control graphs of processes expressed in this language are isomorphic to arbitrary partially ordered sets (Posets) of atomic actions. From this we deduce our rather “negative” starting point: counting executions in this simple language is intractable in the general case. In Section 3 we define the BITS-decomposition, and we use it in Section 4 to design a generic uniform random sampler. In Section 5 we discuss various sub-classes of processes related to the proposed decomposition, and for some of them we explain how the counting and random sampling problem can be solved efficiently. In Section 6 we propose an experimental study of the algorithm toolbox discussed in the paper.
Note that some technical complement and proof details are deferred to an external “companion” document. Moreover we provide the full source code developed in the realm of this work, as well as the benchmark scripts. All these complement informations are available online222cf. https://gitlab.com/ParComb/combinatorics-barrier-synchro.git.
Related work
Our study intermixes viewpoints from concurrency theory, order-theory as well as combinatorics (especially enumerative combinatorics and random sampling). The heaps combinatorics (studied in e.g. [1]) provides a complementary interpretation of concurrent systems. One major difference is that this concerns “true concurrent” processes based on the trace monoid, while we rely on the alternative interleaving semantics. A related uniform random sampler for networks of automata is presented in [3]. Synchronization is interpreted on words using a notion of “shared letters”. This is very different from the “structural” interpretation as joins in the control graph of processes. For the generation procedure [1] requires the construction of a “product automaton”, whose size grows exponentially in the number of “parallel” automata. By comparison, all the algorithms we develop are based on the control graph, i.e. the space requirement remains polynomial (unlike, of course, the time complexity in some cases). Thus, we can interpret this as a space-time trade-of between the two approaches. A related approach is that of investigating the combinatorics of lassos, which is connected to the observation of state spaces through linear temporal properties. A uniform random sampler for lassos is proposed in [16]. The generation procedure takes place within the constructed state-space, whereas the techniques we develop do not require this explicit construction. However lassos represent infinite runs whereas for now we only handle finite (or finite prefixes) of executions.
A coupling from the past (CFTP) procedure for the uniform random generation of linear extensions is described, with relatively sparse details, in [14]. The approach we propose, based on the continuous embedding of Posets into the hypercube, is quite complementary. A similar idea is used in [2] for the enumeration of Young tableaux using what is there called the density method. The paper [12] advocates the uniform random generation of executions as an important building block for statistical model-checking. A similar discussion is proposed in [18] for random testing. The leitmotiv in both cases is that generating execution paths without any bias is difficult. Hence a uniform random sampler is very likely to produce interesting and complementary tests, if comparing to other test generation strategies.
Our work can also be seen as a continuation of the algorithm and order studies [17] orchestrated by Ivan Rival in late 1980’s only with powerful new tools available in the modern combinatorics toolbox.
2. Barrier synchronization processes
The starting point of our study is the small process calculus described below.
Definition 1** (Syntax of barrier synchronization processes).**
We consider countably infinite sets of (abstract) atomic actions, and of barrier names. The set of processes is defined by the following grammar:
[TABLE]
The language has very few constructors and is purposely of limited expressivity. Processes in this language can only perform atomic actions, fork child processes and interact using a basic principle of synchronization barrier. A very basic process is the following one:
[TABLE]
This process can initially perform the actions and in an arbitrary order. We then reach the state in which all the processes agrees to synchronize on :
[TABLE]
The possible next transitions are:
In the resulting states, the barrier has been “consumed”.
The operational semantics below characterize processes transitions of the form in which can perform action to reach its (direct) derivative .
Definition 2** (Operational semantics).**
[TABLE]
with: \begin{array}[]{ll}\left[\begin{array}[]{l}{\scriptstyle\small{\textsf{sync}}_{B}(0)=0}\\ {\scriptstyle\small{\textsf{sync}}_{B}(\alpha.P)=\alpha.P}\\ {\scriptstyle\small{\textsf{sync}}_{B}(P\parallel Q)=\small{\textsf{sync}}_{B}(P)\parallel\small{\textsf{sync}}_{B}(Q)}\\ {\scriptstyle\small{\textsf{sync}}_{B}(\nu(B)P)=\nu(B)P}\\ {\scriptstyle\forall C\neq B,~{}\small{\textsf{sync}}_{B}(\nu(C)P)=\nu(C)~{}\small{\textsf{sync}}_{B}(P)}\\ {\scriptstyle\small{\textsf{sync}}_{B}(\langle B\rangle P)=P}\\ {\scriptstyle\forall C\neq B,~{}\small{\textsf{sync}}_{B}(\langle C\rangle P)=\langle C\rangle P}\end{array}\right.&\left[\begin{array}[]{l}{\scriptstyle\small{\textsf{wait}}_{B}(0)=\small{\textsf{false}}}\\ {\scriptstyle\small{\textsf{wait}}_{B}(\alpha.P)=\small{\textsf{wait}}_{B}(P)}\\ {\scriptstyle\small{\textsf{wait}}_{B}(P\parallel Q)=\small{\textsf{wait}}_{B}(P)\lor\small{\textsf{wait}}_{B}(Q)}\\ {\scriptstyle\small{\textsf{wait}}_{B}(\nu(B)P)=\small{\textsf{false}}}\\ {\scriptstyle\forall C\neq B,~{}\small{\textsf{wait}}_{B}(\nu(C)P)=\small{\textsf{wait}}_{B}(P)}\\ {\scriptstyle\small{\textsf{wait}}_{B}(\langle B\rangle P)=\small{\textsf{true}}}\\ {\scriptstyle\forall C\neq B,~{}\small{\textsf{wait}}_{B}(\langle C\rangle P)=\small{\textsf{wait}}_{B}(P)}\\ \end{array}\right.\end{array}
The rule (sync) above explains the synchronization semantics for a given barrier . The rule is non-trivial given the broadcast semantics of barrier synchronization. The definition is based on two auxiliary functions. First, the function produces a derivative process in which all the possible synchronizations on barrier in have been effected. If has a sub-process that cannot yet synchronize on , then the predicate is true and the synchronization on is said incomplete. In this case the rule (sync) does not apply, however the transitions within can still happen through (lift).
2.1. The control graph of a process
We now define the notion of a (finite) execution of a process.
Definition 3** (execution).**
An execution of is a finite sequence such that there exist a set of processes and a path with (no transition is possible from ).
We assume that the occurrences of the atomic actions in a process expression have all distinct labels, . This is allowed since the actions are uninterpreted in the semantics (cf. Definition 2). Thus, each action in an execution can be associated to a unique position, which we denote by . For example if , then .
The behavior of a process can be abstracted by considering the causal ordering relation wrt. its atomic actions.
Definition 4** (cause, direct cause).**
Let be a process. An action of is said a cause of another action , denoted by , iff for any execution of we have . Moreover, is a direct cause of , denoted by iff and there is no such that . The relation obtained from is denoted by .
Obviously is a partially ordered set (poset) with covering , capturing the causal ordering of the actions of . The covering of a partial order is by construction an intransitive directed acyclic graph (DAG), hence the description of itself is simply the transitive closure of the covering, yielding edges over elements. The worst case (maximizing the number of edges) is a complete bipartite graph with two sets of vertices connected by edges (cf. Fig. 1).
For most practical concerns we will only consider the covering, i.e. the intransitive DAG obtained by the transitive reduction of the order. It is possible to direclty construct this control graph, according to the following definition.
Definition 5** (Construction of control graphs).**
Let be a process term. Its control graph is , constructed inductively as follows:
\left[\begin{array}[]{l|l}\small{\textsf{ctg}}(0)=\langle\emptyset,\emptyset\rangle&\phantom{i}\small{\textsf{ctg}}(\nu(B)P)=\bigotimes_{\langle B\rangle}\small{\textsf{ctg}}(P)\\[2.0pt] \begin{array}[]{l}\small{\textsf{ctg}}(\alpha.P)=\alpha\leadsto\small{\textsf{ctg}}(P)\\ \small{\textsf{ctg}}(\langle B\rangle P)=\langle B\rangle\leadsto\small{\textsf{ctg}}(P)\phantom{i}\end{array}&\phantom{i}\begin{array}[t]{l}\small{\textsf{ctg}}(P\parallel Q)=\small{\textsf{ctg}}(P)\cup\small{\textsf{ctg}}(Q)\\ \text{ with }\langle V_{1},E_{1}\rangle\cup\langle V_{2},E_{2}\rangle=\langle V_{1}\cup V_{2},E_{1}\cup E_{2}\rangle\end{array}\\[2.0pt] \end{array}\right.
with \left\{\begin{array}[]{l}x\leadsto\langle V,E\rangle=\langle V\cup\{x\},\{(x,y)\mid y\in\small{\textsf{srcs}}(E)\lor(E=\emptyset\land y\in V)\}\rangle\\ \small{\textsf{srcs}}(E)=\{y\mid(y,z)\in E\land\nexists x,~{}(x,y)\in E\}\\ \bigotimes_{\langle B\rangle}\langle V,E\rangle=\langle V\setminus\{\langle B\rangle\},E\setminus\begin{array}[t]{l}\{(x,y)\mid x\neq y\land(x=\langle B\rangle\lor y=\langle B)\rangle\}\\ \cup~{}\{(\alpha,\beta)\mid\{(\alpha,\langle B\rangle),~{}(\langle B\rangle,\beta)\}\subseteq E\}\rangle\end{array}\end{array}\right.
Given a control graph , the notation corresponds to prefixing the graph by a single atomic action. The set corresponds to the sources of the edges in , i.e. the vertices without an incoming edge. And removes an explicit barrier node and connect all the processes ending in to the processes starting from it. In effect, this realizes the synchronization described by the barrier . We illustrate the construction on a simple process below:
\begin{array}[t]{l}\small{\textsf{ctg}}(\nu(B)\nu(C)[\langle B\rangle\langle C\rangle a.0||\langle B\rangle\langle C\rangle b.0])\\ =\bigotimes_{\langle B\rangle}\bigotimes_{\langle C\rangle}\left(\small{\textsf{ctg}}(\langle B\rangle\langle C\rangle a.0)\cup\small{\textsf{ctg}}(\langle B\rangle\langle C\rangle b.0)\right)\\ =\bigotimes_{\langle B\rangle}\bigotimes_{\langle C\rangle}\begin{array}[t]{l}\langle\{\langle B\rangle,\langle C\rangle,a\},\{(\langle B\rangle,\langle C\rangle),(\langle C\rangle,a)\}\rangle\}\\ \cup\langle\{\langle B\rangle,\langle C\rangle,b\},\{(\langle B\rangle,\langle C\rangle),(\langle C\rangle,b)\}\rangle\end{array}\\ =\bigotimes_{\langle B\rangle}\bigotimes_{\langle C\rangle}\langle\{\langle B\rangle,\langle C\rangle,a,b\},\{(\langle B\rangle,\langle C\rangle),(\langle C\rangle,a),(\langle C\rangle,b)\}\rangle\\ =\bigotimes_{\langle B\rangle}\langle\{\langle B\rangle,a,b\},\{(\langle B\rangle,a),(\langle B\rangle,b)\}\rangle\\ =\langle\{a,b\},\emptyset\rangle\end{array}
The graph with only two unrelated vertices and no edge is the correct construction. Now, slightly changing the process we see how the construction fails for deadlocked processes.
\begin{array}[t]{l}\small{\textsf{ctg}}(P)=\bigotimes_{\langle B\rangle}\bigotimes_{\langle C\rangle}\left(\small{\textsf{ctg}}(\langle B\rangle\langle C\rangle a.0)\cup\small{\textsf{ctg}}(\langle C\rangle\langle B\rangle b.0)\right)\\ =\bigotimes_{\langle B\rangle}\bigotimes_{\langle C\rangle}\begin{array}[t]{l}\langle\{\langle B\rangle,\langle C\rangle,a\},\{(\langle B\rangle,\langle C\rangle),(\langle C\rangle,a)\}\rangle\}\\ \cup\langle\{\langle C\rangle,\langle B\rangle,b\},\{(\langle C\rangle,\langle B\rangle),(\langle B\rangle,b)\}\rangle\end{array}\\ =\bigotimes_{\langle B\rangle}\bigotimes_{\langle C\rangle}\langle\{\langle B\rangle,\langle C\rangle,a,b\},\{(\langle B\rangle,\langle C\rangle),(\langle C\rangle,a),(\langle C\rangle,\langle B\rangle),(\langle B\rangle,b)\}\rangle\\ =\bigotimes_{\langle B\rangle}\langle\{\langle B\rangle,a,b\},\{(\langle B\rangle,\langle B\rangle),(\langle B\rangle,a),(\langle B\rangle,b)\}\rangle\\ =\langle\{a,b\},\{(\langle B\rangle,\langle B\rangle),(\langle B\rangle,a),(\langle B\rangle,b)\}\rangle\end{array}
In the final step, the barrier cannot be removed because of the self-loop. So there are two witnesses of the fact that the construction failed: there is still a barrier name in the process, and there is a cycle in the resulting graph.
Theorem 6**.**
Let be a process, then has a deadlock iff has a cycle. Moreover, if is deadlock-free (hence it is a DAG) then iff (hence the DAG is intransitive).
idea.
The proof is not difficult but slightly technical. The idea is to extend the notion of execution to go “past” deadlocks, thus detecting cycles in the causal relation. The details are given in companion document. ∎∎
In Fig. 2 (left) we describe a system written in the proposed language, together with the covering of , i.e. its control graph (right). We also indicate the number of its possible executions, a question we address next.
2.2. The counting problem
One may think that in such a simple setting, any behavioral property, such as the counting problem that interests us, could be analyzed efficiently e.g. by a simple induction on the syntax. However, the devil is well hidden inside the box because of the following fact.
Theorem 7**.**
Let be a partially ordered set. Then there exists a barrier synchronization process such that is isomorphic to .
Proof.
(sketch). Consider the (intransitive) covering DAG of a poset . We suppose each vertex of to be uniquely identified by a label ranging over . The objective is to associate to each such vertex labeled a process expression . The construction is done backwards, starting from the sinks (vertices without outgoing edges) of and bubbling-up until its sources (vertices without incoming edges).
There is a single rule to apply, considering a vertex labeled whose children have already been processed, i.e. in a situation depicted as follows:
[TABLE]
In the special case is a sink we simply define . In this construction it is quite obvious that for each of the ’s, provided the barriers are defined somewhere in the outer scope.
At the end we have a set of processes associated to the vertices of and we finally define .
That has the same covering as is a simple consequence of the construction. ∎∎
Corollary 8**.**
Let be a non-deadlocked process. Then is an execution of if it is a linear extension of . Consequently, the number of executions of is equal to the number of linear extensions of .
We now reach our “negative” result that is the starting point of the rest of the paper: there is no efficient algorithm to count the number of executions, even for such simplistic barrier processes.
Corollary 9**.**
Counting the number of executions of a (non-deadlocked) barrier synchronization process is -complete333A function is in P if there is a polynomial-time non-deterministic Turing machine such that for any instance , is the number of executions of that accept as input. See https://en.wikipedia.org/wiki/%E2%99%AFP-complete.
This is a direct consequence of [8] since counting executions of processes boils down to counting linear extensions in (arbitrary) posets.
3. A generic decomposition scheme and its (symbolic) counting algorithm
We describe in this section a generic (and symbolic) solution to the counting problem, based on a systematic decomposition of finite Posets (thus, by Theorem 6, of process expressions) through their covering DAG (i.e. control graphs).
3.1. Decomposition scheme
In Fig. 3 we introduce the four decomposition rules that define the BITS-decomposition. The first three rules are somehow straightforward. The (B)-rule (resp. (T)-rule) allows to consume a node with no outgoing (resp. incoming) edge and one incoming (resp. outgoing) edge. In a way, these two rules consume the “pending” parts of the DAG. The (I)-rule allows to consume a node with exactly one incoming and outgoing edge. The final (S)-rule takes two incomparable nodes and decomposes the DAG in two variants: the one for and the one for the converse .
We now discuss the main interest of the decomposition: the incremental construction of an integral formula that solves the counting problem. The calculation is governed by the equations specified below the rules in Fig. 3, in which the current formula is updated according to the definition of in the equations.
Theorem 10**.**
The numerical evaluation of the integral formula built by the BITS-decomposition yields the number of linear extensions of the corresponding Poset. Moreover, the applications of the BITS-rules are confluent, in the sense that all the sequences of (valid) rules reduce the DAG to an empty graph444At the end of the decomposition, the DAG is in fact reduced to a single node, which is removed by an integration between [math] and ..
The precise justification of the integral computation and the proof for the theorem above are postponed to Section 3.2 below. We first consider an example.
Example 11**.**
Illustrating the BITS-decomposition scheme.
[TABLE]
The DAG to decompose (on the left) is of size with nodes . The decomposition is non-deterministic, multiple rules apply, e.g. we could “consume” the node with the (I) rule. Also, the (S)plit rule is always enabled. In the example, we decide to first remove the node by an application of the (T) rule. We then show an application of the (S)plit rule for the incomparable nodes and . The decomposition should then be performed on two distinct DAGs: one for and the other one for . We illustrate the second choice, and we further eliminate the nodes then using the (I) rule, etc. Ultimately all the DAGs are decomposed and we obtain the following integral computation:
[TABLE]
The result means that there are exactly 14 distinct linear extensions in the example Poset.
3.2. Embedding in the hypercube: the order polytope
The justification of our decomposition scheme is based on the continuous embedding of posets into the hypercube, as investigated in [19].
Definition 12** (order polytope).**
Let be a poset of size . Let be the unit hypercube defined by . For each constraint we define the convex subset , i.e. one of the half spaces obtained by cutting with the hyperplane . Thus, the order polytope of is:
[TABLE]
Each linear extension, seen as total orders, can similarly be embedded in the unit hypercube. Then, the order polytopes of the linear extensions of a poset form a partition of the Poset embedding as illustrated in Figure 4.
The number of linear extensions of a poset , written , is then characterized as a volume in the embedding.
Theorem 13**.**
*([19, Corollary 4.2])
Let be a Poset of size then its number of linear extensions where is the volume, defined by the Lebesgue measure, of the order polytope .*
The integral formula introduced in the BITS-decomposition corresponds to the computation of , hence we may now give the key-ideas of Theorem 10.
Theorem 10, sketch.
We begin with the (S)-rule. Applied on two incomparable elements and , the rule partitions the polytope in two regions: one for and the other for . Obviously, the respective volume of the two disjoint regions must be added.
We focus now on the (I)-rule. In the context of Lebesgue integration, the classic Fubini’s theorem allows to compute the volume of a polytope as an iteration on integrals along each dimension, and this in all possible orders, which gives the confluence property. Thus,
[TABLE]
being the indicator function of such that with the projection of on the dimension associated to . By convexity of , the function is the indicator function of a segment . So the following identity holds: . Finally, the two other rules (T) and (B) are just special cases (taking , alternatively ). ∎∎
Corollary 14**.**
(Stanley [19]) The order polytope of a linear extension is a simplex and the simplices of the linear extensions are isometric, thus of the same volume.
4. Uniform random generation of process executions
In this section we describe a generic algorithm for the uniform random generation of executions of barrier synchronization processes. The algorithm is based on the BITS-decomposition and its embedding in the unit hypercube. It has two essential properties. First, it is directly working on the control graphs (equivalently on the corresponding poset), and thus does not require the explicit construction of the state-space of processes. Second, it generates possible executions of processes at random according to the uniform distribution. This is a guarantee that the sampling is not biased and reflects the actual behavior of the processes.
The starting point of Algorithm 1 (cf. previous page) is a Poset over a set of points (or equivalently its covering DAG). The decomposition scheme of Section 3 produces an integral formula of the form . with a symbolic integral formula over the points . The variables represent a permutation of the poset points giving the order followed along the decomposition. Thus, the variable corresponds to the -th removed point during the decomposition. We remind the reader that the evaluation of the formula gives the number of linear extensions of the partial order. Now, starting with the complete formula, the variables will be eliminated, in turn, in an “outside-in” way. Algorithm 1 takes place at the -th step of the process. At this step, the considered formula is of the following form:
[TABLE]
Note that in the subformula the variable may only occur (possibly multiple times) as an integral bound.
In the algorithm, the variable gets the result of the numerical computation of the integral at the given step. Next we draw (with Uniform) a real number uniformly at random between the integration bounds and . Based on these two intermediate values, we perform a numerical solving of variable in the integral formula corresponding to the slice of the polytope along the hyperplan . The result, a real number between and , is stored in variable . The justification of this step is further discussed in the proof sketch of Theorem 15 below.
If there remains integrals in , the algorithm is applied recursively by substituting the variable in the integral bounds of by the numerical value . If no integral remains, all the computed values ’s are returned. As illustrated in Example 16 below, this allows to select a specific linear extension in the initial partial ordering. The justification of the algorithm is given by the following theorem.
Theorem 15**.**
Algorithm 1 uniformly samples a point of the order polytope with a complexity in the number of integrations.
sketch.
The problem is reduced to the uniform random sampling of a point in the order polytope. This is a classical problem about marginal densities that can be solved by slicing the polytope and evaluating incrementally the continuous random variables associated to the coordinates of . More precisely, during the calculation of the volume of the polytope , the last integration (of a monovariate polynomial ) done from 0 to 1 corresponds to integrate the slices of according the last variable . So, the polynomial is nothing but the density function of the random variable corresponding to the value of . Thus, we can generate according to this density and fix it. When this is done, we can inductively continue with the previous integrations to draw all the random variables associated to the coordinates of . The linear complexity of Algorithm 1 follows from the fact that each partial integration deletes exactly one variable (which corresponds to one node). Of course at each step a possibly costly computation of the counting formula is required. ∎∎
We now illustrate the sampling process based on Example 11 (page 11).
Example 16**.**
First we assume that the whole integral formula has already been computed. To simplify the presentation we only consider (S)plit-free DAGs i.e. decomposable without the (S) rule. Note that it would be easy to deal with the (S)plit rule: it is sufficient to uniformly choose one of the DAG processed by the (S)-rule w.r.t. their number of linear extensions.
Thus we will run the example on the DAG of Example 11 where the DAG corresponding to “” as been randomly chosen (with probability ) i.e. the following formula holds:
[TABLE]
In the equation above, the sub-formula between parentheses would be denoted by in the explanation of the algorithm. Now, let us apply the Algorithm 1 to that formula in order to sample a point of the order polytope. In the first step the normalizing constant is equal to , we draw uniformly in and so we compute a solution of . That solution corresponds to the second coordinate of a the point we are sampling. And so on, we obtain values for each of the coordinates:
[TABLE]
These points belong to a simplex of the order polytope. To find the corresponding linear extension we compute the rank of that vector i.e. the order induced by the values of the coordinates correspond to a linear extension of the original DAG:
[TABLE]
This is ultimately the linear extension returned by the algorithm.
5. Classes of processes that are BIT-decomposable
(or not)
Thanks to the BITS decomposition scheme, we can generate a counting formula for any (deadlock-free) process expressed in the barrier synchronization calculus, and derive from it a dedicated uniform random sampler. However the (S)plit rule generates two summands, thus if we cannot find common calculations between the summands the resulting formula can grow exponentially in the size of the concerned process. If we avoid splits in the decomposition, then the counting formula remains of linear size. This is, we think, a good indicator that the subclass of so-called “BIT-decomposable” processes is worth investigating for its own sake. In this Section, we first give some illustrations of the expressivity of this subclass, and we then study the question of what it is to be not BIT-decomposable. By lack of space, the discussion in this Section remains rather informal with very rough proof sketches, and more formal developments are left for a future work. Also, the first two subsections are extended results based on previously published papers (respectively [6] and [7]).
5.1. From tree Posets to fork-join parallelism
If the control-graph of a process is decomposed with only the B(ottom) rule (or equivalently the T(op) rule), then it is rather easy to show that its shape is that of a tree. These are processes that cannot do much beyond forking sub-processes. For example, based on our language of barrier synchronization it is very easy to encode e.g. the (rooted) binary trees:
[TABLE]
The good news is that the combinatorics on trees is well-studied. In the paper [4] we provide a thorough study of such processes, and in particular we describe very efficient counting and uniform random generation algorithms. Of course, this is not a very interesting sub-class in terms of concurrency.
Thankfully, many results on trees generalize rather straightforwardly to fork-join parallelism, a sub-class we characterize inductively in Table 1. Informally, this proof system imposes that processes use their synchronization barriers according to a stack discipline. When synchronizing, only the last created barrier is available, which exactly corresponds to the traditional notion of a join in concurrency. Combinatorially, there is a correspondence between these processes and the class of series-parallel Posets. In the decomposition both the (B) and the (I) rule are needed, but following a tree-structured strategy. Most (if not all) the interesting questions about such partial orders can be answered in (low) polynomial time.
Theorem 17** (cf. [6]).**
For a fork join process of size the counting problem is of time complexity and we developed a bit-optimal uniform random sampler with time complexity on average.
5.2. Asynchronism with promises
We now discuss another interesting sub-class of processes that can also be characterized inductively on the syntax of our process calculus, but this time using the three BIT-decomposition rules (in a controlled manner). The strict stack discipline of fork-join processes imposes a form of synchronous behavior: all the forked processes must terminate before a join may be performed. To support a limited form of asynchronism, a basic principle is to introduce promise processes.
In Table 2 we define a simple inductive process structure composed as follows. A main control thread can perform atomic actions (at any time), and also fork a sub-process of the form but with a strong restriction:
- •
a single barrier is created for the sub-processes to interact.
- •
the left sub-process must be the continuation of the main control thread,
- •
the right sub-process must be a promise, which can only perform a sequence of atomic actions and ultimately synchronize with the control thread.
We are currently investigating this class as a whole, but we already obtained interesting results for the arch-processes in [7]. An arch-process follows the constraint of Table 2 but adds further restrictions. The main control thread can still spawn an arbitrary number of promises, however there must be two separate phases for the synchronization. After the first promise synchronizes, the main control thread cannot spawn any new promise. In [7] a supplementary constraint is added (for the sake of algorithmic efficiency): each promise must perform exactly one atomic action, and the control thread can only perform actions when all the promises are running. In this paper, we remove this rather artificial constraint considering a larger, and more useful process sub-class.
In Fig. 5 (left) is represented the general structure of a generalized arch-process. The ’s actions are the promise forks, and the synchronization points are the ’s. The constraint is thus that all the ’s occur before the ’s.
Theorem 18**.**
The number of executions of an arch-process can be calculated in arithmetic operations, using a dynamic programming algorithm based on memoization.
idea.
A complete proof is provided in [7] for “simple” arch-processes, and the generalization is detailed in the companion document. We only describe the inclusion-exclusion principle on which our counting algorithm is based. Fig. 5 (right) describes this principles (we omit the representation of the other promises to obtain a clear picture of our approach). Our objective is to count the number of execution contributed by a single promise with atomic action . If we denote by this contribution, we reformulate it as a combination \ell_{\mathcal{P}}=\ell_{\color[rgb]{1,0,0}\definecolor[named]{pgfstrokecolor}{rgb}{1,0,0}{\mathcal{A}}}-\ell_{\color[rgb]{0,0,1}\definecolor[named]{pgfstrokecolor}{rgb}{0,0,1}{\mathcal{B}}}+\ell_{\color[rgb]{0,1,0}\definecolor[named]{pgfstrokecolor}{rgb}{0,1,0}{\mathcal{C}}} as depicted on the rightmost part of Fig. 5. First, we take the “virtual” promise going from the starting point of until the end point of the main thread. Of course there are two many possibilities if we only keep {\color[rgb]{1,0,0}\definecolor[named]{pgfstrokecolor}{rgb}{1,0,0}\mathcal{A}}. An over-approximation of what it is to remove is the promise {\color[rgb]{0,0,1}\definecolor[named]{pgfstrokecolor}{rgb}{0,0,1}\mathcal{B}} going from the start of the last promise (at point ) until the end. But this time we removed too many possibilities, which corresponds to promise {\color[rgb]{0,1,0}\definecolor[named]{pgfstrokecolor}{rgb}{0,1,0}\mathcal{C}}. The latter is thus reinserted in the count. Each of these three “virtual” promises have a simpler counting procedure. To guarantee the quadratic worst-time complexity (in the number of arithmetic operations), we have to memoize the intermediate results. We refer to the companion document for further details. ∎∎
From this counting procedure we developed a uniform random sampler following the principles of the recursive method, as described in [10].
Theorem 19**.**
Let be a promise-process of size with promises. A random sampler of time-complexity (in the number of arithmetic operations) builds uniform executions.
The algorithm and the complete proof are detailed in the companion document. One notable aspect is that in order to get rid of the forbidden case of executions associated to the “virtual” promise {\color[rgb]{0,0,1}\definecolor[named]{pgfstrokecolor}{rgb}{0,0,1}\mathcal{B}} we cannot only do rejection (because the induced complexity would be exponential). In the generalization of arch-processes, we proceed by case analysis: for each possibility for the insertion of in the main control thread we compute the relative probability for the associated process . This explains the increase of complexity (from to ) if compared to [7].
5.3. BIT-free processes
The class of BIT-decomposable processes is rather large, and we in fact only uncovered two interesting sub-classes that can be easily captured inductively on the process syntax. The relatively non-trivial process of Fig. 2 is also interestingly BIT-decomposable. We now adopt the complementary view of trying to understand the combinatorial structure of a so called “BIT-free” process, which is not decomposable using only the (B), (I) and (T) rules.
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1[1] Samy Abbes and Jean Mairesse. Uniform generation in trace monoids. In MFCS 2015 , volume 9234 of LNCS , pages 63–75. Springer, 2015.
- 2[2] Cyril Banderier, Philippe Marchal, and Michael Wallner. Rectangular Young tableaux with local decreases and the density method for uniform random generation (short version). In GAS Com 2018 , Athens, Greece, June 2018.
- 3[3] Nicolas Basset, Jean Mairesse, and Michèle Soria. Uniform sampling for networks of automata. In Concur 2017 , volume 85 of LIP Ics , pages 36:1–36:16. Schloss Dagstuhl, 2017.
- 4[4] O. Bodini, A. Genitrini, and F. Peschanski. The combinatorics of non-determinism. In FSTTCS’13 , volume 24 of LIP Ics , pages 425–436. Schloss Dagstuhl, 2013.
- 5[5] O. Bodini, A. Genitrini, and F. Peschanski. A Quantitative Study of Pure Parallel Processes. Electronic Journal of Combinatorics , 23(1):P 1.11, 39 pages, 2016.
- 6[6] Olivier Bodini, Matthieu Dien, Antoine Genitrini, and Frédéric Peschanski. Entropic uniform sampling of linear extensions in series-parallel posets. In CSR 2017 , volume 10304 of LNCS , pages 71–84. Springer, 2017.
- 7[7] Olivier Bodini, Matthieu Dien, Antoine Genitrini, and Alfredo Viola. Beyond series-parallel concurrent systems: The case of arch processes. In Analysis of Algorithms, Aof A 2018 , volume 110 of LIP Ics , pages 14:1–14:14, 2018.
- 8[8] G. Brightwell and P. Winkler. Counting linear extensions is #P-complete. In STOC , pages 175–181, 1991.
