Parallel and Distributed Computing
Parallel and Distributed Computing
Computing
x+1≤N
X = 10…… x>=10
Process Graph
● S0 → s’
– Set of all reachable states at A’ is denoted by
reach(A’)
– Transition system can also be represented through
graphs
– Example Parallel and Distributed Computing 48
Observation Bisimilarity
• Let Ai’ = (Ai, Si, →i, S0i ), i = 1, 2 be two
transition systems
• A1’ and A2’ are observation bisimilar, denoted
by A1’≅ A2’ if there is a relation B ⊆ S1×S2 such
that,
– (S01, S02) ∈ B
– If (S1, S2) ∈ B and then there is S2’ such that (S1’,
S2’) ∈ B and
– If (S1, S2) ∈ B andthen there is S1’ such that (S1’,
S2’) ∈ B and Parallel and Distributed Computing 49
Observation
Bisimilarity………………
• Example
– Consider the following two processes
• Example 2
2 3
3
6
4 add
2. Dependency
3. Conflict
• 5. Confusion
– (Conflict+ Concurrency)
Quiz:-
(1,0,1,0) →not
Reachable
M0 =(2,0)
R(M0) = (1,1) (0,2)
3
Man
woman
T1 → Dead
T2 → Live
T3 → ?????
1. Simplicity of abstraction
2. Dual nature of TM
3. Inclusion of non – determinism
4. Realization of unbounded parallelism
5. Provision of an easy abstract measure for
resources
….
Since 7 is crashed it
does not received
The message
Both 5 and 6 hold the
election
6 is announcing
6 is winner
Step 3:-
2 → [2,3,4,5,6,0,1,2]
5 → [5, 6,0,1,2,3,4,5]
• Lamport’s Algorithm
– Each message carries a time stamp of the sender’s
clock
– When a message arrives
1. If receiver’s clock < (message_time _stamp)
set system clock
Parallel to (message_time
and Distributed Computing _stamp+1) 103
Vector Clock
• Rules
1. Vector initialization to 0 at each process
Vi[j] = 0, for i, j = 1, 2, ………………………, N
1. Process increments its elements of the local
vector before time stamping event
Vi[i] = Vi[i] + 1
1. Message is sent from process Pi with Vi
attached to it
2. When Pi receives message, compare vector
elements, and set local vector to higher of
Parallel and Distributed Computing 104
Vector
Clock………………………………
..
• Comparing vector timestamps
1. V = V’ iff V[i] = V’[i] for i = 1, 2, ………………..,N
2. V ≤ V’ iff V[i] ≤ V’[i] for i = 1, 2, ………………..,N
• For any two events e and e’
1. If e → e’ then V(e) < V(e’)
2. If V(e) < V(e’) then e → e’
• Two events e and e’ are concurrent iff neither
V(e) < V(e’) is true nor V(e’) < V(e) is true
(2, 1, 0) (2, 2, 0)
(2, 2, 2)
? ? ?
[3,7,8,3,9,2,3,1]→ [7,8,9,3]→[8,9]→9
• Eg
• A = {5, 3, -6, 2, 7, 10, -2, 8}
• The output is
{5, 8, 2, 4, 11, 21, 19, 27}
• i=2j+1 to n : 2→8
• i=2 → read a[i-2j]
→ read a[2-20]
→ read a[1] = 3
→ a[i] = a[i - 2j] + a[i] → a[2] = a[1] + a[2] = 5+3=8
• i=3
a[3] = a[2] + a[3] = 3 + (-6) = -3
• i=4
• i=5
• i=6 Parallel and Distributed Computing 127
List Ranking
• The problem is that, given a singly linked list L,
with N objects, for each node compute the
distance to the end of the list
• If d denotes the distance
• Parallel algorithm
– Assign one processor for each node
– For each node i, do in parallel
• i.d = i.d + i.next.d
• i.next = i.next.next
Parallel and Distributed Computing 128
List
Ranking……………………………
• Illustration
……
P1 P2 P3 P4 P5 P6
1 1 1 1 1 0 /
2 2 2 2 1 / 0 /
4 4 3 / 2 /
5 / 4 /
2, 1 3, 4 7, 5 8, 9
L(S) R(S) L(S) R(S) R(S) R(S)
L(S)
L(S)
1 2 3 4 5 7 8 9
– Where b ∈ Zp
– Where
• N → no. of processors
• di → datum broadcast by the processor Pi
• σh → selection operation, 1≤h≤k, where k is the
number of criteria
• t(i, h) → tag broadcast by processor i for criteria h
• l(i, h) → limit value j for criteria σh
• R → reduction operation, R ∈ {Σ, π, ∧, ∨, ⊕, ∩, ∪}
Parallel and Distributed Computing 140
BSR………………………………
…………….
• Types
1. One criterion BSR algorithm
2. Two criterion BSR algorithm
3. Three criterion BSR algorithm
4. Multiple criterion BSR algorithm
Sequence ( ) ( ( ( ) ) ) ( ( ) )
Index(j) 1 2 3 4 5 6 7 8 9 10 11 12
bj 1 -1 1 1 1 -1 -1 -1 1 1 -1 -1
∑bi | i≤ j 1 0 1 2 3 2 1 0 1 2 1 0
Pj 1 1 1 2 3 3 2 1 1 2 2 1
P’j 0 0.5 0.66 1.75 2.8 2.83 1.86 0.87 0.89 1.9 1.91 0.92
qj -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
qj J=1 -1 0 0.5 0.92 1.91 2.8 1.75 0.66 0.87 1.86 1.9 0.89
J=1, (
tj 0 1 2 12 11 5 J=7,
4 ) 3 8 7 10 9
rj 2 3 8 7 Parallel
6 and Distributed
0 Computing
10 9 12 11 5 4 151
Maximal Sum Sub Segment
• Given an array of numbers d1, d2, ……., dm, it
is required to find a contiguous sub array of
maximal sum
• Example
– A = {-2, -3, 4, -1, -2, 1, 5, -3}
– Maximal Sum = 4 + (-1) + (-2) + 1 + 5 = 7
fby → followed by
asa → as soon as
Ai
Dij
f(6)=(P2,31)
…
• Example 14
13
5
5
12 4 P1 P2 P3
Level 5
11 4
0 14 13 11
Level 4 10 4 Task
Task Schedul
Priority
9 4 ing 1 12 10 9
8 4
Level 3
7 3 2 8 6 7
6 3 3 5 3 4
Level 2 5 3 4 2
4 2 5 1
3 2
Level 1
2 2
1
Parallel and Distributed Computing 1 184
Scheduling in – forests / out –
forests without
communication…………………
• Example …
• Model A
• No. of message = |(a, c), (a, e)| = 2
• Total cost = 2*1Parallel
+ 3and=Distributed
5 Computing 187
Communication
Model………………..
• Exercise
S2 S3
S4
u = {b}, v = {a}
1 4
2 5
P1 P2 P3
3 6
3 2 1
4 3
4 5 6
5 2
7 8 9
6 1
Task Scheduling
7 0
8 0
9 0
Task Priority
Task Graph
Parallel and Distributed Computing 197
Scheduling Interval Ordered Task
…
• Without communication (Ex)
1 4
2 5 P1 P2 P3
3 6 3 2 1
4 3 6
5 2 4 5
6 1 7
7 0 8 9
8 0 Task Scheduling
9 0
Task Priority
Task Graph
Parallel and Distributed Computing 201
Scheduling Interval Ordered Task
…
• Exercise
<9> 11 <8>
10 a 11 P1 P2
b 10 0 a b
<6,7> <5,7>
9 8 c 9 1 c d
d 8 2 f e
<1,4> <3,4> 7 <3>
6 e 6 3 g h
5
f 7 4 i j
<1,2> g 5 5 k
<2>
4 3 h 4 Task Scheduling
i 3
1 Task Priority
<2> 2 j 1
<1>
Task Graph k
Parallel and Distributed Computing
2 203
Two Processor Scheduling
• Ex
P1 P2 P1 P2
a a a
b b c
c
Task Graph
No Duplication Task Duplication
Fault
Rollback
c Engineering Objects are the run time representations of computational object Single computer system
0 0 5 1 9
0 3 0
10+1= 16 17
11+1= 14
1 2
Post Order (Left,Right,Root)
efbgchida a=9
b=3
c=5
d=8
Post Order
efbgchida
e=1
f=2
g=4
h=6
Parallel and Distributed Computing 228
i=7
Computing a post order
numbering…..
• Exercise (Compute post order of following
tree)
• Example
9-1+1=9 1 4 6
9
3 9-7+1=3 2 5
Euler Tour 4 7
2 3 8
3 6 9
4 9
6 8
Level 2
Level 3
2 2
LCA(9,12) = 3
Euler Tour
Computation… bc=(2,2)->(3,10)
(2,11)
l(a)=1,r(a)=11 For “a” bd=(2,2)->(11,11)
(3,10) (11,11) cd=(3,10)->(11,11) (3,11) (4,11) (5,11) (6,11) (7,11) (8,11) (9,11) (10,11)
(2,2)
1 2 3 4 5 6 7 8 9 10 11
1 A A A A A A A A A A A
2 A B A
3 A C C C C C C C C
4 A C E
5 A C F F F
6 A C F H
7 A C F I
8 A C G G G
9 A C G J
10 A C G K
A
11 A D
Parallel and Distributed Computing 240
LCA (Lowest Common Ancestor)
Computation…
1 2 3 4 5 6 7 8 9 10 11
1 A A A A A A A A A A A
2 A B A A A A A A A A A
3 A A C C C C C C C C A
4 A A C E C C C C C C A
5 A A C C F F F C C C A
6 A A C C F H F C C C A
7 A A C C F F I C C C A
8 A A C C C C C G G G A
9 A A C C C C C G J G A
10 A A C C C C C G G K A
11 A A A A A A A A A A D