SLIDE 1 Fence-Insertion
for Structured Programs Mohammad Taheri
Spring 2020 University of Vienna
Arash Pourdamghani Mohsen Lesani
SLIDE 2
Developing a Distributed System!
2
SLIDE 3
Looking Deeper
3
357 F(x) ……….. 385 F’(x)
SLIDE 4
Out of Order Execution
4
357 F(x) ……….. 385 F’(x) F’(x)
↓
F(x) Programmer's Expectation Runtime Execution
SLIDE 5 Fence Insertion
5
357 F(x) 385 F’(x) 500 H(x) 525 H’(x) 146 G(x) 912 G’(x)
SLIDE 6
Our Solution
6
SLIDE 7
Outline
7
Problem Statement NP-Hardness Poly-time Algorithm
SLIDE 8
CFG
8
SLIDE 9
A Closer Look
9
h F(x) i Some Code k G(x)
SLIDE 10
Maintaining Correctness
10
h F(x) i Some Code k F’(x)
SLIDE 11
Fence Insertion
11
h F(x) i Some Code k F’(x)
SLIDE 12
All Constraints
12
SLIDE 13
Naive Solution
13
SLIDE 14
Optimization
14
SLIDE 15
Outline
15
Problem Statement NP-Hardness Poly-time Algorithm
SLIDE 16
Reduction from Minimum Set Cover
16
𝑉 = 𝑣1, 𝑣2, 𝑣3, 𝑣4, … , un 𝑇 = 𝑇1, 𝑇2, … , 𝑇𝑛 𝐹𝑦𝑏𝑛𝑞𝑚𝑓: 𝑇1 = 𝑣1, 𝑣2, 𝑣3 , 𝑇2 = {𝑣2, 𝑣4}
SLIDE 17 Reduction from Minimum Set Cover
17
𝑉 = 𝑣1, 𝑣2, 𝑣3, 𝑣4, … , un : Constraint Types, Straight line program with 2n instructions, Constraints with type 𝑣𝑗 𝑝𝑜 𝑤𝑗, 𝑤2𝑜−𝑗+1 , (𝑤𝑜
2, 𝑤𝑜 2 + 1):The middle edge
SLIDE 18
Reduction from Minimum Set Cover
18
𝑇 = 𝑇1, 𝑇2, … : Fence Types We could many fences of 𝑇𝑗 𝐹𝑦𝑏𝑛𝑞𝑚𝑓: 𝑇1 = 𝑣1, 𝑣2, 𝑣3 , 𝑇2 = {𝑣2, 𝑣4}
SLIDE 19
19
𝑉 = 𝑣1, 𝑣2, 𝑣3, 𝑣4, … 𝑇 = {𝑇1, 𝑇2, … } Given Solution of Fence Insertion
SLIDE 20
20
𝑉 = 𝑉1, 𝑉2, 𝑉3, 𝑉4, … 𝑇 = {𝑇1, 𝑇2, … } Given Solution of Minimum Set Cover
SLIDE 21
Outline
21
Problem Statement NP-Hardness Poly-time Algorithm
SLIDE 22
22
P
SLIDE 23
1- Constraint Elimination 2- Finding Diamond 3- Decomposing into Paths 4- Solving for Paths
Algorithm Overview
23
SLIDE 24
Out of Order Execution!
24
1- Constraint Elimination 2- Finding Diamond 3- Decomposing into Paths 4- Solving for Paths 4- Solving for Paths 2- Finding Diamond 1- Constraint Elimination 3- Decomposing into Paths
SLIDE 25
A Simple Path
25
SLIDE 26
A Simple Path
26
SLIDE 27
A Simple Path
27
SLIDE 28
A Simple Path
28
SLIDE 29
A Simple Path
29
SLIDE 30
Structured
30
SLIDE 31
A(C)FG
31
SLIDE 32
Finding Diamonds
32
SLIDE 33
Level 0
33
SLIDE 34
Level 1
34
SLIDE 35
Level 2
35
SLIDE 36
Branch/Merge
36
SLIDE 37
Algorithm
37
SLIDE 38
Algorithm
38
SLIDE 39
Fence Elimination
39
SLIDE 40
Passing Constraints
40
SLIDE 41
Spanning Constraints
41
SLIDE 42
Control Dependency Preservation
42
SLIDE 43
Decomposing into simple paths
43
SLIDE 44
Absorption in a Path
44
SLIDE 45
Emission in a Path
45
SLIDE 46
Before
46
SLIDE 47
After Level 0
47
SLIDE 48
After Level 1
48
SLIDE 49
The End!
49
SLIDE 50 Complexity
1- 𝐹 ∈ 𝑃 𝑊 2-Elimination: 𝑃 𝐷 + 𝑊 3-Finding Diamonds: 𝑃 𝑊𝑚𝑝𝑊 4-Decompsiton and Insertion: σ|𝑞| |𝐷𝑞𝑗|𝑚𝑝𝐷𝑞𝑗 + |𝑊
𝑞𝑗|
⇒Polynomial Time!
50
SLIDE 51
What about loops?
51
SLIDE 52
Elimination
52
SLIDE 53
Transformation
53
SLIDE 54
54
Thank you
SLIDE 55 Probabilistic Smart Contracts: Secure Randomness on the Blockchain [ICBC 2019]
Propose a novel game-theoretic approach for generating provably unmanipulatable pseudorandom numbers on the blockchain.
Hybrid Mining: Exploiting Blockchain's Computational Power for Distributed Problem Solving [SAC 2019]
A new mining protocol that combines solving real-world useful problems with Hashcash.
55