SLIDE 1 synchronous networks
an interconnection structure with
- boolean nodes, primary inputs and primary outputs
ti d l i i t d ith h b l d an interconnection structure with
- a propagation delay is associated with each boolean node;
all input-output delays of a node are equal
- single-phase edge-triggered memory elements on the edges;
g p g gg y g all memory elements are triggered by the same clock
- cycles have at least one memory element
a d v b c d e
D D
i
D
e u
D D
i
D
SLIDE 2
retiming
i i ddi d l i i l k d l retiming = adding, deleting, moving clocked memory elements, neither changing the topology of the network nor the boolean operations in the node nor th oo an op rat ons n th no
SLIDE 3 retiming
i i l fi filt
clock time
1
flipflops
input
retiming
clock
retimed fir-filter:
p
flipflop delay adder delay
clock time
1
input
flipflops flipflops
adder delay flipflop delay
retiming changes
flipflop delay
m g g the temporal behavior of the network, and not the sequential behavior
SLIDE 4
leiserson's correlator
g e f
+
host g
+
e
+
f
=
host a
= =
c d
=
b
a finite directed multigraph,
7 e g 7 f 7
vertex weighted (delay ≥ 0), and arc weighted
3 d h
(number of memory elements)
3 1 c 3 1 a 3 b 1 1
)
SLIDE 5 retiming steps
b shifting clocked memory elements: D b clock D a c l k a D c clock model:
a
d
b
d b
a
d
b
b
d
c
d
a c
c
d
a c retiming = adding, deleting, moving clocked memory elements,
= delay of boolean node
neither changing the topology of the network nor the boolean operations in the node
SLIDE 6
retiming model
retiming = an integer labeling r of vertices. interpretation: interpretation:
r < 0 r > 0 r elements removed r elements added r elements added r elements removed
a retiming is legal if the retimed network has no negative weights
w r
netwerk, retimed by : all “equivalent” synchronous networks can be obtained from an initial network by has no negative weights
wij i j rj ri
be obtained from an initial network by legal retiming
[Leiserson 1983]
i j ri rj wij+ rj- ri
SLIDE 7 feasible clock periods
d(p)=path delay= d(p)=path delay= sum of all vertex-weights (delays) on a directed path ( ) h i h w(p)=path weight= sum of all arc-weights ( # memory elements) on a directed path properties under retiming: condition: all cycle weights must be positive! properties under retiming:
changes in path weights depend only on end vertices cycle weights are invariant
a clock period is feasible if it exceeds any path delay on a zero-weight path y p y g p the minimum feasible clock period Φ = max {d(p) | w(p) = 0}
SLIDE 8
a retiming problem formulation
problem statement for clock period minimization : given G (V, E, d, w), find a legal retiming r so that
Φ { d( ) | ( ) 0 }
is minimized
Φ = max { d(p) | w(p) = 0 }
example : smaller correlator
7 a a h c
+
host a 3 2 b c
= =
host b c 3 b
SLIDE 9 two auxiliary matrices
p p
W(u,v) = min {w(p) | u → v}: the minimum number of m.e. on any path from u to v D(u v) = max {d(p) | u → v and w(p) = W(u v)}:
l b φ i f ibl l k i d fif D( ) φ W( ) 0
D(u,v) max {d(p) | u → v and w(p) W(u,v)}: the maximum path delay over a "critical" path
a real number φ is a feasible clock period fif D(u,v) >φ → W(u,v)>0
the set of "critical" paths invariant under retiming Wr(u,v) := W(u,v) + r(v) - r(u) D (u v) := D(u v) Dr(u,v) := D(u,v) Φ, the minimum feasible clock period, is equal to some D(u,v)
→ W and D are useful quantities!
SLIDE 10 all-pairs shortest paths
4 3 2 input: 3 8 ∞
4 8 1 2 1 3 ∞ ∞ 2 3 4 ∞ 8 ∞
1 ∞ 4 7 ∞ ∞ M = 1 7 2 6
4 5
∞ ∞ ∞ 6
3 1
2 1
N 4 3 N 4 4 5 2 1 1 7 2 8 4
5
1 5 6 3
C = 4 4 4 3 3 3 N 4 4 2 N 5 1 1 N Π =
SLIDE 11
floyd-warshall
assume V = {1,2,…,n} consider the subset V(k) = {1 2 k} for some k ≤ n consider the subset V(k) = {1,2,…,k} for some k ≤ n let i and j be two vertices consider the set P(i,j,k) of paths from i to j ith i t m di t d s f m V(k) with intermediate nodes from V(k) let p be a shortest path in P(i,j,k) if k is not an intermediate node of p then if k is not an intermediate node of p, then if k is an intermediate node of p, then p is a shortest path in P(i,j,k-1) i h h h i P(i k k 1) p=qr with q a shortest path in P(i,k,k-1) and r a shortest path in P(k,j,k-1) recursively formulated: let be the weight of the shortest path in P(i,j,k)
(k) ij
c
ij
m
if k = 0
(k)
c =
y
(k 1) (k 1) (k 1) ij ik kj
min(c ,c c )
− − −
+ if k > 0
j ij
c =
desired answer:
( )
(n) (n) ij
C c =
SLIDE 12 bottom-up computation
4 3 2 floyd-warshall(W) 1 n ← rows[W] 8 1 2 4 1 3 5 [ ] 2
(0)
C W ← 3 for k ← 1 to n 4 do for i ← 1 to n 7 6
4 5
(k) (k 1) (k 1) (k 1) ij ij ik kj
c min(c ,c c )
− − −
← +
5 do for j ← 1 to n 6 7 return
(n)
C
3 8 ∞
3 8 ∞
3 8 ∞
) d d , d min(
) ( 11 ) ( 41 ) ( 41
+
C
∞ ∞ 2 3 4 ∞ 8 ∞
1 ∞ 4 7 ∞ ∞ D =
(0)
∞ ∞ 2 3 4 ∞ 8 ∞
1 ∞ 4 7 ∞ ∞ C =
(0)
C =
(1)
3 8 4 ∞ ∞ 1 7 ∞ 4 ∞ ∞ ∞ ∞ ∞ 6 ∞ ∞ ∞ 6
SLIDE 13 bottom-up computation
4 3 2 floyd-warshall(W) 1 n ← rows[W] 8 1 2 4 1 3 5 [ ] 2
(0)
C W ← 3 for k ← 1 to n 4 do for i ← 1 to n 7 6
4 5
(k) (k 1) (k 1) (k 1) ij ij ik kj
c min(c ,c c )
− − −
← +
5 do for j ← 1 to n 6 7 return
(n)
C
3 8 ∞
3 8 ∞
3 8 ∞
) d d , d min(
) ( 12 ) ( 41 ) ( 42
+
C
∞ ∞ 2 3 4 ∞ 8 ∞
1 ∞ 4 7 ∞ ∞ D =
(0)
∞ ∞ 2 3 4 ∞ 8 ∞
1 ∞ 4 7 ∞ ∞ C =
(0)
C =
(1)
3 8 4 ∞ ∞ 1 7 ∞ 4 ∞ ∞ 2 ∞ ∞ ∞ 6 ∞ ∞ ∞ 6
SLIDE 14 bottom-up computation
4 3 2 floyd-warshall(W) 1 n ← rows[W] 8 1 2 4 1 3 5 [ ] 2
(0)
C W ← 3 for k ← 1 to n 4 do for i ← 1 to n 7 6
4 5
(k) (k 1) (k 1) (k 1) ij ij ik kj
c min(c ,c c )
− − −
← +
5 do for j ← 1 to n 6 7 return
(n)
C
3 8 ∞
3 8 ∞
3 8 ∞
C
1
2
∞ ∞ 2 3 4 ∞ 8 ∞
1 ∞ 4 7 ∞ ∞ D =
(0)
∞ ∞ 2 4 ∞ ∞
1 ∞ 7 ∞ ∞ C =
(0)
C =
(1)
3 8 4 ∞ ∞ 1 7 ∞ 4 ∞ ∞ 2 5
C =
(n)
3 7 2 4
1 5
3
∞ ∞ ∞ 6 ∞ ∞ ∞ 6 ∞ ∞ ∞ 6 8 5 1 6
SLIDE 15 construction of shortest paths
) k ( ij
π
let be the predecessor of j on a shortest path in P(i,j,k)
= π
) ( ij
NIL
if i = j or
∞ =
ij
w
i if i ≠ j and
∞ <
ij
w
) 1 k ( kj ) 1 k ( ik ) 1 k ( ij ) 1 k ( kj
d d d if
− − − −
+ > π = π
) k ( ij
(k > 0)
) 1 k ( kj ) 1 k ( ik ) 1 k ( ij ) 1 k ( ij
d d d if
− − − −
+ ≤ π
desired answer:
( )
) n ( ij ) n (
π = Π
kj ik ij kj
d d d if + > π
SLIDE 16 remarks
floyd-warshall(W) 1 n ← rows[W] [ ] 2
(0)
C W ← 3 for k ← 1 to n 4 do for i ← 1 to n
(k) (k 1) (k 1) (k 1) ij ij ik kj
c min(c ,c c )
− − −
← +
5 do for j ← 1 to n 6 7 return
(n)
C
- detection of negative-weight cycles
(a negative number on the diagonal of )
) (V3 O
C
(n)
C
(a negative number on the diagonal of )
- space-optimization possible
- works for any (min,+)algebra that is a semiring
( )
C
SLIDE 17 calculating W and D
- reweight each edge with
- calculate all-pair shortest paths with:
( )
ij, i
w d − – additions must be done as two-component vectors – comparisons must be done lexicographically, p g p y, i.e. for and if or ( and )
1 1 1
c (a ,b ) =
2 2 2
c (a ,b ) =
1 2
c c <
1 2
a a <
1 2
a a =
1 2
b b < f ( ) – if then and
1 2 1 2 1 2 1 2 (n) ij ij ij
c (x ,y ) =
ij ij
w x =
ij j ij
d d y = −
SLIDE 18 checking clock feasibility
p p p
W(u,v) = min {w(p) | u → v}: the minimum number of m.e. on any path from u to v D(u v) = max {d(p) | u → v and w(p) = W(u v)}:
retiming r allows a clock period φ fif
( ) ( ) ( ) [ ]
v u w v r u r
E e
→ ≤ − ∀ ∈
e
l b φ i f ibl l k i d fif D( ) φ W( ) 0
p
D(u,v) max {d(p) | u → v and w(p) W(u,v)}: the maximum path delay over a "critical" path
( ) ( ) ( ) [ ]
1 v , u W v r u r ] v , u [ D
v u,
− ≤ − ⇒ φ > ∀
a real number φ is a feasible clock period fif D(u,v)>φ → W(u,v)>0
7 h b 2 c 2 a 2 W h
2 ) b ( r ) h ( r ≤
7 a 2 2 2 2 2 2 h b c a
) a ( r r(b) ) c ( r r(b) 2 ) b ( r ) h ( r ≤ − ≤ − ≤ −
3 2 h c h 13 b 3 3 c 6 6 a 13 13 D h b
) h ( r ) a ( r ) a ( r r(c) ≤ − ≤ −
3 2 b 13 10 7 3 13 10 6 3 13 13 10 7 b c a
SLIDE 19 checking clock feasibility
p p p
W(u,v) = min {w(p) | u → v}: the minimum number of m.e. on any path from u to v D(u v) = max {d(p) | u → v and w(p) = W(u v)}:
retiming r allows a clock period φ fif
( ) ( ) ( ) [ ]
v u w v r u r
E e
→ ≤ − ∀ ∈
e
l b φ i f ibl l k i d fif D( ) φ W( ) 0
p
D(u,v) max {d(p) | u → v and w(p) W(u,v)}: the maximum path delay over a "critical" path
( ) ( ) ( ) [ ]
1 v , u W v r u r ] v , u [ D
v u,
− ≤ − ⇒ φ > ∀
a real number φ is a feasible clock period fif D(u,v)>φ → W(u,v)>0
7 h b 2 c 2 a 2 W h
2 ) b ( r ) h ( r ≤ 1 ) a ( r ) h ( r ≤ −
7 a 2 2 2 2 2 2 h b c a
) a ( r r(b) ) c ( r r(b) 2 ) b ( r ) h ( r ≤ − ≤ − ≤ − 1 ) h ( ( ) 1 ) a ( r r(b) 1 ) h ( r r(b) 1 ) a ( r ) h ( r − ≤ − − ≤ − ≤
3 2 h c h 13 b 3 3 c 6 6 a 13 13 D h b
) h ( r ) a ( r ) a ( r r(c) ≤ − ≤ − 1 ) a ( r r(c) 1 ) b ( r ) c ( r 1 ) h ( r r(c) − ≤ − ≤ − − ≤ −
3 2 b 13 10 7 3 13 10 6 3 13 13 10 7 b c a
7 = φ
1 ) c ( r ) a ( r 1 ) b ( r ) a ( r ) ( ( ) ≤ − ≤ −
SLIDE 20 linear programming
find an n-vector x
p g g
maximizing the objective function
∑ =
n 1 i i ix
c
subject to the constraints subject to the constraints A x ≤ b where A is an m×n matrix and b an m-vector where A is an m×n matrix and b an m vector important facts: any such linear programming problem can be solved in polynomial time y p g g p p y any problem that can be formulated as LP belongs to P the widely used simplex-algorithm does not run in polynomial time ! ! feasibility: find an n-vector x subject to the constraints A x ≤ b j where A is an m×n matrix and b an m-vector
SLIDE 21 difference constraints
- feasibility problem (the constraints of an LP: )
A x ≤ b
- each row in A has only 0's except for one 1 and one -1
1 -1 0 0 0 x x
2 1
≤ −
- feasibility problem (the constraints of an LP: )
A x ≤ b
2 1
x x x 1 1 0 0 0 1 0 0 0 -1 0 1 0 0 -1
≤
1 5 1 x x
5 1
− ≤ − 1 x x
2 5
≤ − 5 x x
1 3
≤ −
2 1 5 4 3
x x x
0 0 -1 1 0 0 0 -1 0 1 0 0 0 1 1 ≤ 4
3 4 x x
1 4
≤ − 3 x x
3 5
− ≤ − 3 ≤ 1 x x
3 4
− ≤ − 0 0 0 -1 1
3 x x
4 5
− ≤ −
- ne solution: (-5,-3,0,-1,-4),
but also: (0,2,5,4,1), or (100,102,105,104,101) property: for any solution x of a system of difference constraints, x+d with d some constant is a solution as well
SLIDE 22 constraint graphs
1
v 5 ≤
5
v
1
≤
≤
1 etc 1 1 0 0 0
2
v v 5 4
etc
2 1
x x 1 -1 0 0 0 1 0 0 0 -1 0 1 0 0 -1
1 5
4
v
3
v 1
5 4 3
x x x 1 0 1 0 0
0 0 -1 1 0 0 0 -1 0 1 ≤ 5 4
assigning shortest distance δ(v0 vi) claim: 0 0 0 -1 1
assigning shortest distance δ(v0,vi)
- f vi from v0 to variable to xi
yields a feasible solution
SLIDE 23 constraint graphs
for every arc (vi,vj) in E we have
1
v
) v , v ( w ) v , v ( ) v , v (
j i i
δ ≤ δ
and so:
5
v
1
) v , v ( w ) v , v ( ) v , v (
j i i
δ − δ
and therefore:
2
v v 5 4
) v , v ( w x x
j i i j
≤ −
f l ( ) claim
4
v
3
v for every cycle (va,vb, . . . ,vk) we have
) v , v ( w x x
b a a b
≤ − ) v , v ( w x x
c b b c
≤ −
assigning shortest distance δ(v0 vi) claim:
) v , v ( w x x
a k k a
≤ −
assigning shortest distance δ(v0,vi)
- f vi from v0 to variable to xi
yields a feasible solution ) cycle ( w 0 ≤ negative weight cycle infeasible
SLIDE 24 checking clock feasibility
p p p
W(u,v) = min {w(p) | u → v}: the minimum number of m.e. on any path from u to v D(u v) = max {d(p) | u → v and w(p) = W(u v)}:
retiming r allows a clock period φ fif
( ) ( ) ( ) [ ]
v u w v r u r
E e
→ ≤ − ∀ ∈
e
l b φ i f ibl l k i d fif D( ) φ W( ) 0
p
D(u,v) max {d(p) | u → v and w(p) W(u,v)}: the maximum path delay over a "critical" path
( ) ( ) ( ) [ ]
1 v , u W v r u r ] v , u [ D
v u,
− ≤ − ⇒ φ > ∀
a real number φ is a feasible clock period fif D(u,v)>φ → W(u,v)>0
7 h b 2 c 2 a 2 W h
2 ) b ( r ) h ( r ≤ 1 ) a ( r ) h ( r ≤ −
7 a 2 2 2 2 2 2 h b c a
) a ( r r(b) ) c ( r r(b) 2 ) b ( r ) h ( r ≤ − ≤ − ≤ − 1 ) h ( ( ) 1 ) a ( r r(b) 1 ) h ( r r(b) 1 ) a ( r ) h ( r − ≤ − − ≤ − ≤
3 2 h c h 13 b 3 3 c 6 6 a 13 13 D h b
) h ( r ) a ( r ) a ( r r(c) ≤ − ≤ − 1 ) a ( r r(c) 1 ) b ( r ) c ( r 1 ) h ( r r(c) − ≤ − ≤ − − ≤ −
3 2 b 13 10 7 3 13 10 6 3 13 13 10 7 b c a
7 = φ
1 ) c ( r ) a ( r 1 ) b ( r ) a ( r ) ( ( ) ≤ − ≤ −
SLIDE 25 checking clock feasibility
retiming r allows a clock period φ fif
( ) ( ) ( ) [ ]
v u w v r u r
E e
→ ≤ − ∀ ∈
e
( ) ( ) ( ) [ ]
1 v , u W v r u r ] v , u [ D
v u,
− ≤ − ⇒ φ > ∀
2
1 ) a ( r ) h ( r ≤ − 2 ) b ( r ) h ( r ≤ −
1 r(b) r(b) r(h) r(h)
1
1 ) h ( r r(c) 1 ) a ( r r(b) 1 ) h ( r r(b) − ≤ − − ≤ − − ≤ − ) a ( r r(c) ) a ( r r(b) ) c ( r r(b) ≤ − ≤ − ≤ −
r(b) r(b) r(h) r(h) 1 1 1
1 ) b ( ) ( 1 ) a ( r r(c) 1 ) b ( r ) c ( r 1 ) h ( r r(c) − ≤ − ≤ − ≤ ) h ( r ) a ( r ) a ( r r(c) ≤ − ≤
r(a) r(a) r(c) r(c) 1
1
1
1 ) c ( r ) a ( r 1 ) b ( r ) a ( r ≤ − ≤ −
1 ( ) ( ) ( ) ( ) constraint graph constraint graph 1
SLIDE 26 checking clock feasibility
retiming r allows a clock period φ fif
( ) ( ) ( ) [ ]
v u w v r u r
E e
→ ≤ − ∀ ∈
e
( ) ( ) ( ) [ ]
1 v , u W v r u r ] v , u [ D
v u,
− ≤ − ⇒ φ > ∀
2
1 ) a ( r ) h ( r ≤ − 2 ) b ( r ) h ( r ≤ −
1 r(b) r(b) r(h) r(h)
1
, 1 , 1 , ] a , c , b , h [ r − − = r 1 ) h ( r r(c) 1 ) a ( r r(b) 1 ) h ( r r(b) − ≤ − − ≤ − − ≤ − ) a ( r r(c) ) a ( r r(b) ) c ( r r(b) ≤ − ≤ − ≤ −
r(b) r(b) r(h) r(h) 1 1 1
1 ) b ( ) ( 1 ) a ( r r(c) 1 ) b ( r ) c ( r 1 ) h ( r r(c) − ≤ − ≤ − ≤ ) h ( r ) a ( r ) a ( r r(c) ≤ − ≤
r(a) r(a) r(c) r(c) 1
1
1
1 ) c ( r ) a ( r 1 ) b ( r ) a ( r ≤ − ≤ −
1 ( ) ( ) ( ) ( ) constraint graph constraint graph 1
SLIDE 27
the smaller correlator
7
13 Φ
+
a 7 a
13 = Φ
= =
host b c 3 2 h c
= =
3 2 b 7 a
, 1 , 1 , ] a , c , b , h [ r − − = r
1 a
+
h a 3 1 h c 1
= =
host b c 3 b
= =
7 = Φ
SLIDE 28
checking clock feasibility
retiming r allows a clock period φ fif
( ) ( ) ( ) [ ]
v u w v r u r
E e
→ ≤ − ∀ ∈
e
a real number φ is a feasible clock period fif D(u,v)>φ → W(u,v)>0
( ) ( ) ( ) [ ]
1 v , u W v r u r ] v , u [ D
v u,
− ≤ − ⇒ φ > ∀
7 h b 2 c 2 a 2 W h
2 ) b ( r ) h ( r ≤ 1 ) a ( r ) h ( r 1 ) h ( r ) a ( r 1 ) a ( r ) a ( r ≤ − ≤ − − ≤ −
7 a 2 2 2 2 2 2 h b c a
) a ( r r(b) ) c ( r r(b) 2 ) b ( r ) h ( r ≤ − ≤ − ≤ − 1 ) a ( r r(b) 1 ) h ( r r(b) 1 ) a ( r ) h ( r − ≤ − − ≤ − ≤ −
3 2 h c h 13 b 3 3 c 6 6 a 13 13 D h b
) h ( r ) a ( r ) a ( r r(c) ≤ − ≤ − 1 ) a ( r r(c) 1 ) b ( r ) c ( r 1 ) h ( r r(c) − ≤ − ≤ − − ≤ −
3 2 b 13 10 7 3 13 10 6 3 13 13 10 7 b c a
6 = φ
1 ) c ( r ) a ( r 1 ) b ( r ) a ( r 1 ) a ( r r(c) ≤ − ≤ − ≤
SLIDE 29 checking clock feasibility
retiming r allows a clock period φ fif
( ) ( ) ( ) [ ]
v u w v r u r
E e
→ ≤ − ∀ ∈
e
a real number φ is a feasible clock period fif D(u,v)>φ → W(u,v)>0
( ) ( ) ( ) [ ]
1 v , u W v r u r ] v , u [ D
v u,
− ≤ − ⇒ φ > ∀
2 ) b ( r ) h ( r ≤
2 r(b) r(b) r(h) r(h)
1
1 ) a ( r ) h ( r 1 ) h ( r ) a ( r 1 ) a ( r ) a ( r ≤ − ≤ − − ≤ − ) a ( r r(b) ) c ( r r(b) 2 ) b ( r ) h ( r ≤ − ≤ − ≤ −
r(b) r(b) r(h) r(h) 1 1 1
1 ) a ( r r(b) 1 ) h ( r r(b) 1 ) a ( r ) h ( r − ≤ − − ≤ − ≤ −
negative weight cycle:
φ = 6 is infeasible ) h ( r ) a ( r ) a ( r r(c) ≤ − ≤ −
r(a) r(a) r(c) r(c) 1
1
1 1
1 ) a ( r r(c) 1 ) b ( r ) c ( r 1 ) h ( r r(c) − ≤ − ≤ − − ≤ −
( ) ( ) ( ) ( ) constraint graph constraint graph 1
1
6 = φ
1 ) c ( r ) a ( r 1 ) b ( r ) a ( r 1 ) a ( r r(c) ≤ − ≤ − ≤
SLIDE 30
relaxation
shortest-path weight property: δ(s,v) ≤ δ(s,u) + w(u,v) for any edge (u,v) shortest-path estimates: d[v] for any vertex v initialize-single-source(G,s) 2 9 5 initialize single source(G,s) 1 for each vertex v in V[G] 2 do d[v] ← ∞ 3 π[v] ← NIL 9 5 Relax(u,v,w) 2 3 π[v] ← NIL 4 d[s] ← 0 relax(u,v,w) 2 7 5 2 6 5 ( ) 1 if d[v] > d[u] + w(u,v) 2 then d[v] ← d[u] + w(u,v) 3 π[v] ← u 6 5 Relax(u,v,w) 2 3 π[v] ← u 2 6 5 > d[v] ≤ d[u] + w(u,v)
SLIDE 31
the bellman-ford algorithm
1 initialize-single-source(G s) bellman-ford(G,w, s)
(V 1) E relaxations
∅
2 for i ← 1 to | V[G] | - 1 1 initialize-single-source(G,s) 4 do relax(u,v,w) 3 do for each edge (u,v) in E[G]
(V-1) E relaxations
7 then return false 5 for each edge (u,v) in E[G] 6 do if d[v] > d[u] + w(u,v)
negative-cycle detection
8 return true
relax(u,v,w) negative cycle detection 1 if d[v] > d[u] + w(u,v) 2 then d[v] ← d[u] + w(u,v) 3 π[v] ← u
SLIDE 32 the bellman-ford algorithm
Order: (u,v),(u,x),(u,y),(v,u),(x,v), (x,y),(y,v),(z,u),(z,x)
1 initialize-single-source(G s) bellman-ford(G,w,s)
6
u v 5 ∞ ∞ 6 11 4 2 1 2 3 4
∅
2 for i ← 1 to | V[G] | - 1 1 initialize-single-source(G,s) 4 do relax(u,v,w) 3 do for each edge (u,v) in E[G]
6 8
2 7 z
7 then return false 6 do if d[v] > d[u] + w(u,v) 5 for each edge (u,v) in E[G]
7 2 9 x y ∞ ∞ 7 2
8 return true
relax(u,v,w) running time: O(VE) 1 if d[v] > d[u] + w(u,v) 2 then d[v] ← d[u] + w(u,v) 3 π[v] ← u
SLIDE 33 correctness
given: system of difference constraints A x ≤ b theorem: given:
- system of difference constraints A x ≤ b
- constraint graph G
if G has no negative-weight cycles, then theorem:
)) v , v ( ),..., v , v ( ), v , v ( ( x
n 2 1 1
δ δ δ =
is a feasible solution for the system if G has negative-weight cycles, g g y , then the system has no feasible solution proof:
k 1
v v =
w(c) < 0
j
v ) v , v ( w ) v , v ( ) v , v (
j i i j
+ δ ≤ δ ) v , v ( w ) v , v ( ) v , v (
j i i j
≤ δ − δ
c
) v , v ( w
2 1
≤
1 2
x x −
2 3
x x − ) v , v ( w
3 2
≤
i
v
1 k
v −
2 3
) , (
3 2
. . .
1 k 1
x x
−
− ) v , v ( w
1 1 k−
≤ ) v , v ( w x x
j i i j
≤ −
+ ≤ w(c)< 0 ≤ w(c)< 0
SLIDE 34 bellman-ford: correctness
assumption: no reachable negative-weight cycles property: upon termination, d[v] = δ(s,v) for all v in V proof: 1. v not reachable invariant: d[v] = ∞ = δ(s v) invariant: d[v] = ∞ = δ(s,v)
let p = v0 v1 … vk be a shortest path from s (=v0) to v (=vk) th k | V | then, k < | V | induction: d[v0] = δ(s,v0) = δ(s,s) = 0 is an invariant basis: d[vi] = δ(s,vi) after the i-th pass d ( ) f h ( ) h step: assume d[vi-1] = δ(s,vi-1) after the (i-1)-th pass edge (vi-1,vi) is relaxed in the i-th pass d[vi] ≤ d[vi-1]+w(vi-1,vi) = δ(s,vi-1)+w(vi-1,vi) = δ(s,vi d[vi] = δ(s,vi)
SLIDE 35 bellman-ford: correctness
t : property: no reachable negative-weight cycles fif bellman-ford returns true ti h bl ti i ht l to prove: for all (u,v) in E, d[v] ≤ d[u] + w(u,v) assumption: no reachable negative-weight cycles consider (u,v): d[v] = δ(s,v) ≤ δ(s,u) + w(u,v) = d[u] + w(u,v) assumption: bellman ford returns true assumption: bellman-ford returns true to prove: no reachable negative-weight cycles assume there is a negative-weight cycle c = v0 v1 … vk (=v0)
∑
< =
k
) vi 1 vi ( w ) c ( w
∑ =
< − =
1 i
) vi , 1 vi ( w ) c ( w
∑ ∑ ∑
= = =
− + − ≤
k 1 i k 1 i k 1 i
) vi , 1 vi ( w ] 1 vi [ d ] vi [ d
∑ ∑
− =
k k
] 1 vi [ d ] vi [ d
∑ ∑
= = 1 i 1 i
] 1 vi [ d ] vi [ d
6 do if d[v] > d[u] + w(u,v) 5 for each edge (u,v) in E[G]
∑ =
≥ −
k 1 i
) vi , 1 vi ( w
7 then return false
[ ] [ ] ( , )
SLIDE 36 clock period minimization
ll h h
( )
3
O
1) compute all W and D : all pairs shortest paths 2) sort all entries of D :
( )
3
V
O
( )
V ln V2
O
) 3) find the minimum feasible clock period Φ : b h
( )
O
( )
V ln V
O
binary search manner shortest path in constraint graph
- by testing entries D
- check feasibility
for a clock period of dij
( )
V ln
O
( )
E V
O
4) determine r for Φ in constraint graph shortest path
( )
E V •
O
( )
E V
O
in constraint graph
( )
E V •
O
complexity:
( )
V ln V
3
SLIDE 37 leiserson’s correlator
+
g
+
e
+
f
Φ 24
+
host g
+ +
Φ=24
=
a
= =
c d
=
b adder 7 f a r delay comparator delay =7 =3
2
7 e g 7 f 7 delay
rg=0 rf=-1 re=-2 rh=0 rd=-2
3 1 d 1 h
rh 0
d
3 1 c 3 1 a 3 b 1 1
ra=-1 rb=-1 rc=-2 wab:=1-1+1=1 wbc:=1-2+1=0
SLIDE 38 leiserson’s correlator
+
g
+
e
+
f
Φ 13
+
host
+ +
Φ=13
=
a
= =
c d
=
b f
2 wef:=0-1+2=1 wfg:=0-0+1=1
7 e g 7 f 7
rg=0 rf=-1 re=-2 rh=0 rd=-2 wde:= +2=0 +1=0 +1=1 wgh:= 0-0+0=0
3 1 d 1 h
rh 0
d
wcd:=
de
0-2+2=0 wce:=0-2+ wbf:=0-1+ wag:=0-0+ wah:=
3 c 3 a 3 b 1 1
ra=-1 rb=-1 rc=-2
cd
1-2+2=1 w w wab:=1-1+1=1 wbc:=1-2+1=0 w
ah
1-1+0=0