Statistical Analysis of Non-Deterministic Fork-Join Processes
Martin Pépin
Joint work with Antoine Genitrini & Frédéric Peschanski Accepted for publication at ICTAC’20
October 13, 2020
Sorbonne Université — LIP6 — Paris
Statistical Analysis of Non-Deterministic Fork-Join Processes task - - PowerPoint PPT Presentation
Martin Ppin Joint work with Antoine Genitrini & Frdric Peschanski Accepted for publication at ICTAC20 October 13, 2020 Sorbonne Universit LIP6 Paris Statistical Analysis of Non-Deterministic Fork-Join Processes task 1
Statistical Analysis of Non-Deterministic Fork-Join Processes
Martin Pépin
Joint work with Antoine Genitrini & Frédéric Peschanski Accepted for publication at ICTAC’20
October 13, 2020
Sorbonne Université — LIP6 — Paris
What is concurrency?
task 1 task 1 task 1 task 2 task 2 task 2 task 3 task 3 Time
One computation unit shared by several processes: → Possible dependencies between processes → Scheduling
1/15
Why is it diffjcult?
You would like to check that all possible schedulings are correct. “all schedulings” → Combinatorics!
2/15
Why is it diffjcult?
You would like to check that all possible schedulings are correct. “all schedulings” → Combinatorics!
2/15
Why is it diffjcult?
You would like to check that all possible schedulings are correct. “all schedulings” → Combinatorics!
2/15
Why is it diffjcult? (2)
Negative result (Brightwell & Winkler ’91) Counting the linear extensions of a partial order is a #-P complete problem. I.e. it is as hard as counting the number of solutions in SAT. So we cannot count effjciently… in the general case. But we can have some restrictions on the programs.
3/15
Why is it diffjcult? (2)
Negative result (Brightwell & Winkler ’91) Counting the linear extensions of a partial order is a #-P complete problem. I.e. it is as hard as counting the number of solutions in SAT. So we cannot count effjciently… in the general case. But we can have some restrictions on the programs.
3/15
The long-term project “Quantitative and algorithmic aspects of concurrency”
> Olivier Bodini, Matthieu Dien, Antoine Genitrini, MP, Frédéric Peschanski, … > Identify fundamental components of concurrency and interpret them as combinatorial objects > Algorithmic solutions for the counting and sampling problems > Analytical results (when possible)
4/15
Outline
A class of concurrent programs Algorithmic aspects Conclusion and perspective
Fork-Join parallelism
Parallel composition P Q
task 1 task 2 task 3
∥
task 1 task 2
↓
task 1 task 1 task 2 task 3 task 2
Execution = any interleaving
execution of Q. Sequential composition P Q
task 1 task 2 task 3
;
task 1 task 2
↓
task 1 task 2 task 3 task 1 task 2
Execution = an execution of P followed by an execution of Q.
5/15
Non-determinism and loops
Non-deterministic choice P Q
task 1 task 2 task 3
+
task 1 task 2
↓
task 1 task 2 task 3
task 1 task 2
Execution = an execution of P
Loop (
task 1 task 2
)⋆ ↓
task 1 task 2
task 1 task 2 task 1 task 2
. . . Execution = sequence of executions of Q
6/15
Non-deterministic Fork-Join programs (NFJ)
P, Q ::= P ∥ Q (parallel composition) | P; Q (sequential composition) | P + Q (non-deterministic choice) | P⋆ (loop) | a (atomic action) | (empty program)
7/15
Combinatorial interpretation
Defjne the executions of P as a combinatorial class P: 0 = E a = Z P Q P Q P Q P Q P Q P Q
!
P SEQ P
!
P Q P Q P SEQ P Labelled and unlabelled operators in the same grammar;
!
P Q might contain the empty execution; P non-empty executions of P.
8/15
Combinatorial interpretation
Defjne the executions of P as a combinatorial class P: 0 = E a = Z P; Q = P × Q
Q P Q
!
P SEQ P
!
P Q P Q P SEQ P
unlabelled operators in the same grammar;
!
P Q might contain the empty execution; P non-empty executions of P.
8/15
Combinatorial interpretation
Defjne the executions of P as a combinatorial class P: 0 = E a = Z P; Q = P × Q
!
P SEQ P
!
P Q P Q P SEQ P
unlabelled operators in the same grammar;
!
P Q might contain the empty execution; P non-empty executions of P.
8/15
Combinatorial interpretation
Defjne the executions of P as a combinatorial class P: 0 = E a = Z P; Q = P × Q
!
P⋆ = SEQ (P)
!
P Q P Q P SEQ P
unlabelled operators in the same grammar;
!
P Q might contain the empty execution; P non-empty executions of P.
8/15
Combinatorial interpretation
Defjne the executions of P as a combinatorial class P: 0 = E a = Z P; Q = P × Q
△
!
P⋆ = SEQ (P)
△
!
P Q P Q P SEQ P
unlabelled operators in the same grammar;
△
!
P, Q might contain the empty execution; P non-empty executions of P.
8/15
Combinatorial interpretation
Defjne the executions of P as a combinatorial class P: 0 = E a = Z P; Q = P × Q
△
!
P⋆ = SEQ (P)
△
!
P + Q̸=0 = P̸=0 + Q̸=0
unlabelled operators in the same grammar;
△
!
P, Q might contain the empty execution;
executions of P.
8/15
Outline
A class of concurrent programs Algorithmic aspects Conclusion and perspective
Counting executions
Algorithm: P
− → P
symbolic method
− → GF
[zn]
− → count COUNT 0 1 COUNT a z COUNT P Q p z q z COUNT P Q p z q z COUNT P Q p z q z p 0 q 0 COUNT P 1 p z p 0
1
All operation are taken zn
1
p z COUNT P q z COUNT Q p z q z p z q z where
n an n zn n anzn and n anzn n an n zn 9/15
Counting executions
Algorithm: P
− → P
symbolic method
− → GF
[zn]
− → count COUNT(0) = 1 COUNT(a) = z COUNT(P ∥ Q) = p(z) ⊚ q(z) COUNT(P; Q) = p(z) · q(z) COUNT(P + Q) = p(z) + q(z) − p(0)q(0) COUNT(P⋆) = (1 − (p(z) − p(0)))−1 All operation are taken mod zn+1 p(z) = COUNT(P) q(z) = COUNT(Q) p z q z p z q z where
n an n zn n anzn and n anzn n an n zn 9/15
Counting executions
Algorithm: P
− → P
symbolic method
− → GF
[zn]
− → count COUNT(0) = 1 COUNT(a) = z COUNT(P ∥ Q) = p(z) ⊚ q(z) • COUNT(P; Q) = p(z) · q(z) COUNT(P + Q) = p(z) + q(z) − p(0)q(0) COUNT(P⋆) = (1 − (p(z) − p(0)))−1 All operation are taken mod zn+1 p(z) = COUNT(P) q(z) = COUNT(Q)
where L (∑
n an n! zn)
= ∑
n anzn and B (∑ n anzn) = ∑ n an n! zn 9/15
Counting executions — complexity
Theorem The counting algorithm performs O(|P|M(n)) arithmetic
The coeffjcients of the polynomial have O(n ln n) bits.
O P M n M n n bit-complexity.
10/15
Counting executions — complexity
Theorem The counting algorithm performs O(|P|M(n)) arithmetic
The coeffjcients of the polynomial have O(n ln n) bits.
= ⇒ O(|P|M(n)M(n ln n)) bit-complexity.
10/15
Random sampling of executions
Algorithm: P
− → P recursive method − →
[FZC′93]
uniform execution Rule: 1 0
3
2 2
3 1
4 1
3 2
8 0
3 3
24 1 2 1 2 0 1 2 1 2 1 1 1 2 1 2 1 2 0 + 1 + 1 = 2
11/15
Random sampling of executions
Algorithm: P
− → P recursive method − →
[FZC′93]
uniform execution SAMPLE((a + b)⋆ ∥ (c + (d; e) + (f; g)), 3) Rule: 1 0
3
2 2
3 1
4 1
3 2
8 0
3 3
24 1 2 1 2 0 1 2 1 2 1 1 1 2 1 2 1 2 0 + 1 + 1 = 2
11/15
Random sampling of executions
Algorithm: P
− → P recursive method − →
[FZC′93]
uniform execution SAMPLE((a + b)⋆ ∥ (c + (d; e) + (f; g)), 3) Rule: Pn = Q0R0 (n ) + Q1Rn−1 (n
1
) + Q2Rn−2 (n
2
) + · · · Pick k ∈ 0; n with probability QkRn−k (n
k
) /Pn 1 · 0 · (3 ) + 2 · 2 · (3
1
) + 4 · 1 · (3
2
) + 8 · 0 · (3
3
) = 24 · (0 + 1/2 + 1/2 + 0) 0 1 2 1 2 1 1 1 2 1 2 1 2 0 + 1 + 1 = 2
11/15
Random sampling of executions
Algorithm: P
− → P recursive method − →
[FZC′93]
uniform execution SHUFFLE(SAMPLE((a + b)⋆, 1), SAMPLE((c + (d; e) + (f; g)), 2)) Rule: 1 · 0 · (3 ) + 2 · 2 · (3
1
) + 4 · 1 · (3
2
) + 8 · 0 · (3
3
) = 24 · (0 + 1/2 + 1/2 + 0) 0 1 2 1 2 1 1 1 2 1 2 1 2 0 + 1 + 1 = 2
11/15
Random sampling of executions
Algorithm: P
− → P recursive method − →
[FZC′93]
uniform execution SHUFFLE(SAMPLE((a + b)⋆, 1), . . .) Rule: P⋆ → 0 + P; P⋆ 1 · 0 · (3 ) + 2 · 2 · (3
1
) + 4 · 1 · (3
2
) + 8 · 0 · (3
3
) = 24 · (0 + 1/2 + 1/2 + 0) 0 1 2 1 2 1 1 1 2 1 2 1 2 0 + 1 + 1 = 2
11/15
Random sampling of executions
Algorithm: P
− → P recursive method − →
[FZC′93]
uniform execution SHUFFLE(SAMPLE(0 + (a + b); (a + b)⋆, 1), . . .) Rule: P⋆ → 0 + P; P⋆ 1 · 0 · (3 ) + 2 · 2 · (3
1
) + 4 · 1 · (3
2
) + 8 · 0 · (3
3
) = 24 · (0 + 1/2 + 1/2 + 0) 0 1 2 1 2 1 1 1 2 1 2 1 2 0 + 1 + 1 = 2
11/15
Random sampling of executions
Algorithm: P
− → P recursive method − →
[FZC′93]
uniform execution SHUFFLE(SAMPLE((a + b); (a + b)⋆, 1), . . .) Rule: 1 · 0 · (3 ) + 2 · 2 · (3
1
) + 4 · 1 · (3
2
) + 8 · 0 · (3
3
) = 24 · (0 + 1/2 + 1/2 + 0) 0 1 2 1 2 1 1 1 2 1 2 1 2 0 + 1 + 1 = 2
11/15
Random sampling of executions
Algorithm: P
− → P recursive method − →
[FZC′93]
uniform execution SHUFFLE(SAMPLE((a + b); (a + b)⋆, 1), . . .) Rule: Pn = Q0R0 + Q1Rn−1 + Q2Rn−2 + · · · Pick k ∈ 0; n with probability QkRn−k/Pn 1 · 0 · (3 ) + 2 · 2 · (3
1
) + 4 · 1 · (3
2
) + 8 · 0 · (3
3
) = 24 · (0 + 1/2 + 1/2 + 0) 0 · 1 + 2 · 1 = 2 · (0 + 1) 1 1 2 1 2 1 2 0 + 1 + 1 = 2
11/15
Random sampling of executions
Algorithm: P
− → P recursive method − →
[FZC′93]
uniform execution SHUFFLE(SAMPLE(a + b, 1), . . .) Rule: 1 · 0 · (3 ) + 2 · 2 · (3
1
) + 4 · 1 · (3
2
) + 8 · 0 · (3
3
) = 24 · (0 + 1/2 + 1/2 + 0) 0 · 1 + 2 · 1 = 2 · (0 + 1) 1 1 2 1 2 1 2 0 + 1 + 1 = 2
11/15
Random sampling of executions
Algorithm: P
− → P recursive method − →
[FZC′93]
uniform execution SHUFFLE(SAMPLE(a + b, 1), . . .) Rule: Pn = Qn + Rn Choose Q with probability Qn/Pn 1 · 0 · (3 ) + 2 · 2 · (3
1
) + 4 · 1 · (3
2
) + 8 · 0 · (3
3
) = 24 · (0 + 1/2 + 1/2 + 0) 0 · 1 + 2 · 1 = 2 · (0 + 1) 1 + 1 = 2 · (1/2 + 1/2) 0 + 1 + 1 = 2
11/15
Random sampling of executions
Algorithm: P
− → P recursive method − →
[FZC′93]
uniform execution SHUFFLE(a, . . .) Rule: 1 · 0 · (3 ) + 2 · 2 · (3
1
) + 4 · 1 · (3
2
) + 8 · 0 · (3
3
) = 24 · (0 + 1/2 + 1/2 + 0) 0 · 1 + 2 · 1 = 2 · (0 + 1) 1 + 1 = 2 · (1/2 + 1/2) 0 + 1 + 1 = 2
11/15
Random sampling of executions
Algorithm: P
− → P recursive method − →
[FZC′93]
uniform execution SHUFFLE(a, SAMPLE((c + (d; e) + (f; g)), 2)) Rule: 1 · 0 · (3 ) + 2 · 2 · (3
1
) + 4 · 1 · (3
2
) + 8 · 0 · (3
3
) = 24 · (0 + 1/2 + 1/2 + 0) 0 · 1 + 2 · 1 = 2 · (0 + 1) 1 + 1 = 2 · (1/2 + 1/2) 0 + 1 + 1 = 2
11/15
Random sampling of executions
Algorithm: P
− → P recursive method − →
[FZC′93]
uniform execution SHUFFLE(a, SAMPLE((c + (d; e) + (f; g)), 2)) Rule: Pn = Qn + Rn + Sn Choose Q (or R) with probability Qn/Pn (or Rn/Pn) 1 · 0 · (3 ) + 2 · 2 · (3
1
) + 4 · 1 · (3
2
) + 8 · 0 · (3
3
) = 24 · (0 + 1/2 + 1/2 + 0) 0 · 1 + 2 · 1 = 2 · (0 + 1) 1 + 1 = 2 · (1/2 + 1/2) 0 + 1 + 1 = 2
11/15
Random sampling of executions
Algorithm: P
− → P recursive method − →
[FZC′93]
uniform execution SHUFFLE(a, SAMPLE((d; e), 2)) Rule: 1 · 0 · (3 ) + 2 · 2 · (3
1
) + 4 · 1 · (3
2
) + 8 · 0 · (3
3
) = 24 · (0 + 1/2 + 1/2 + 0) 0 · 1 + 2 · 1 = 2 · (0 + 1) 1 + 1 = 2 · (1/2 + 1/2) 0 + 1 + 1 = 2
11/15
Random sampling of executions
Algorithm: P
− → P recursive method − →
[FZC′93]
uniform execution SHUFFLE(a, de) Rule: 1 · 0 · (3 ) + 2 · 2 · (3
1
) + 4 · 1 · (3
2
) + 8 · 0 · (3
3
) = 24 · (0 + 1/2 + 1/2 + 0) 0 · 1 + 2 · 1 = 2 · (0 + 1) 1 + 1 = 2 · (1/2 + 1/2) 0 + 1 + 1 = 2
11/15
Random sampling of executions
Algorithm: P
− → P recursive method − →
[FZC′93]
uniform execution dae Rule: 1 · 0 · (3 ) + 2 · 2 · (3
1
) + 4 · 1 · (3
2
) + 8 · 0 · (3
3
) = 24 · (0 + 1/2 + 1/2 + 0) 0 · 1 + 2 · 1 = 2 · (0 + 1) 1 + 1 = 2 · (1/2 + 1/2) 0 + 1 + 1 = 2
11/15
Random sampling of executions
Pn = Q0Rn + Q1Rn−1 + Q2Rn−2 + · · · + QnR0 How to draw k ∈ 0; n with probability QkRn−k/Pn? Solution 1: Draw x UNIF 0 Pn and take the minimum k such that x Q0Rn Q1Rn
1
QkRn
k.
Solution 2 (boustrophedonic alg., [FZC’93,Molinero’05]): Draw x UNIF 0 Pn and take the minimum k such that x Q0Rn QnR0 Q1Rn
1
Qn
1R1
Q2Rn
2
k terms .
12/15
Random sampling of executions
Pn = Q0Rn + Q1Rn−1 + Q2Rn−2 + · · · + QnR0 How to draw k ∈ 0; n with probability QkRn−k/Pn? Solution 1: Draw x ∼ UNIF(0; Pn) and take the minimum k such that x < Q0Rn + Q1Rn−1 + · · · + QkRn−k. Solution 2 (boustrophedonic alg., [FZC’93,Molinero’05]): Draw x UNIF 0 Pn and take the minimum k such that x Q0Rn QnR0 Q1Rn
1
Qn
1R1
Q2Rn
2
k terms .
12/15
Random sampling of executions
Pn = Q0Rn + Q1Rn−1 + Q2Rn−2 + · · · + QnR0 How to draw k ∈ 0; n with probability QkRn−k/Pn? Solution 1: Draw x ∼ UNIF(0; Pn) and take the minimum k such that x < Q0Rn + Q1Rn−1 + · · · + QkRn−k. Solution 2 (boustrophedonic alg., [FZC’93,Molinero’05]): Draw x ∼ UNIF(0; Pn) and take the minimum k such that x < Q0Rn + QnR0 + Q1Rn−1 + Qn−1R1 + Q2Rn−2 + . . . (k terms).
12/15
Random sampling of executions — complexity
Theorem [FZC’93,Molinero’05] The recursive method with solution 2 has complexity O(n ln n). Theorem [Molinero’05] The recursive method has complexity O(n) on recursion-free specifjcations.
The constant hidden in the O depends on the specifj- cation!
13/15
Random sampling of executions — complexity
Theorem [FZC’93,Molinero’05] The recursive method with solution 2 has complexity O(n ln n). Theorem [Molinero’05] The recursive method has complexity O(n) on recursion-free specifjcations.
The constant hidden in the O depends on the specifj- cation!
13/15
Random sampling of executions — complexity
Theorem [FZC’93,Molinero’05] The recursive method with solution 2 has complexity O(n ln n). Theorem (updated) The recursive method has complexity O(h · n) on recursion-free specifjcation, where h is the number of nested
The constant hidden in the O depends on the specifj- cation!
13/15
Random sampling of executions — complexity
Theorem Random sampling of executions has complexity O(n · min(h(P), ln n)) where h denotes the “height”
14/15
Outline
A class of concurrent programs Algorithmic aspects Conclusion and perspective
Conclusion
Take away:
Future work:
15/15
Conclusion
Take away:
Future work:
15/15