Download presentation
Presentation is loading. Please wait.
Published byHartanti Darmali Modified over 5 years ago
1
Netzer & Miller 1990: On the Complexity of Event Ordering for Shared-Memory Parallel Program Executions
2
Programs and Executions (histories)
We consider temporal relations: A must happen before B C can happen before A D happened before E Program: Execution: P1: Loop: W X,1 A: W Y,1 sync R X if X==1 goto loop; P1: W X,1 W Y,1 sync E: R X,2 P2: R X,1 sync D: W X,2 R Y,1 P2: C: R X sync B: R X W X,2 R Y
3
Relations For an execution – either the relation holds or not.
For a program – “must happen” if relation holds in every possible execution. “can happen” – if holds in part of the possible executions. Let a,b denote events (or instructions) in a program. a happens before b (a b ), if a finishes before b starts in every execution (global observer-wise). a and b are ordered if in every execution a b or b a. Similarly – unordered. Note the global observer makes this definition hold for any memory model.
4
Example: X := 0 Fork P1: {X := 1;} P2: {if X == 1 foo();} Join a In this example, for almost all memory models, a must happen before b despite the fact that there is no synchronization (because of the read-write dependence). b
5
Theorem: given a program P that uses semaphores, and given events a,b in P, the decision whether a b, whether a and b are ordered, or whether a and b are unordered, is Co-NP Complete. Proof: We will see for a b. Proofs of other relations are similar. The proof is by reduction from 3-CNF-NSAT, so every boolean formula is not satisfiable iff a b for two events a,b that are defined by the reduction from the specific formula.
6
Informal Reminder: NP and Co-NP
There is a set NP of problems for which: we do not have a polynomial solution, we have an exponential solution. A problem in NP is complete when: we have polynomial reduction from each of the other problems in NP to this problem. Co-NP Completeness: Same but for the set of “complement problems” (e.g.: satisfiable vs non-satisfiable).
7
3-CNF-SAT An instance of 3-CNF-SAT has n variables
V={x1,…,xn} and a Boolean formula B having m clauses C1^C2^…^Cm. A clause is a disjunction of 3 literals (xi or not(xi)) from V – (L1vL2vL3).
8
Idea of the proof Given a boolean formula B, we will construct a program of 3n+3m+2 processes which use 3n+m+1 semaphores (initialized to 0). The execution of the program is a simulation of a non-deterministic computation of B. Use semaphores to compute truth values assignment of variables and clauses. Prove that the execution of the program assumes certain interleavings iff B is not satisfiable.
9
Idea of the proof – cntd. The parallel program uses semaphores xi and not-xi to represent the truth value of a variable xi: signal(xi) (signal(not-xi) represents an assignment of True (False) to xi. The processes make progress in 2 rounds. The first round is a non-deterministic guess of a truth value to each variable. The assignment is represented by letting either signal(xi) or signal(not-xi) to perform, but not both. The second round begins after signal(pass2), and ensures there are no deadlocks in the program: perform all semaphores that were not performed in the first round.
10
Details of the reduction: the construction per clause
For every clause Cj=L1vL2vL3 construct a program: Pj1: wait(L1) signal(Cj) Pj2: wait(L2) Pj3: wait(L3) L1,L2,L3 are semaphores corresponding to literals in Cj. The semaphore Cj represents the truth value of the clause Cj. The semaphore Cj will be signaled if the random assignment of truth values to the literals in the first round implies Cj==True.
11
The construction per variable
For each variable xi construct the 3 processes: Pi1: wait(Ai) signal(xi) : Pi2: signal(not-xi) Pi3: signal(Ai) wait(pass2) Where “:” denotes signal(xi) or signal(not-xi) according to the occurance of xi or not-xi in B.
12
Putting the construction together
Construct two additional control processes: P1: wait(C1) : wait(Cm) b: P2: a: signal(pass2) m n There are n operations signal(pass2) (one for every variable xi). Since there are no conditional operations and shared variables, every run of the program produces the same execution.
13
Claim: a b iff B is not satisfiable
Assume that B is not satisfiable. Then there is always a Cj which is not satisfied by the truth values that were guessed in round 1. Thus, signal(Cj) is not performed in round 1. B will not be performed until signal(Cj) occurs in round 2. Round 2 occurs only after a, hence a happens before b.
14
Proof cntd. Suppose a b. I.e., there is no execution in which b happens before a or is not synchronized with a. Assume by way of contradiction that B is satisfiable. Then there exists a guess of round 1 that satisfies all clauses.This would have made the occurance of b precede that of a, thus contradicting the assignment.
15
Other relations Similar reductions prove that computing a is always ordered with b, and a is always not ordered with b is Co-NP hard. Same reductions give that b a may happen iff B is satisfiable, and so computing the above is NP-complete. Similar reductions show that computing may happen that a,b are ordered/unordered are NP-complete.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.