Synchron 2008 – CPL Aussois
Lusteral
Uniform and Modular Composition of Data-flow & Control-flow in the Lazy λ-Calculus
- M. Mendler, University of Bamberg
Synchron 2008 – CPL Aussois 1
joint work with Marc Pouzet
Lusteral Uniform and Modular Composition of Data-flow & - - PowerPoint PPT Presentation
Lusteral Uniform and Modular Composition of Data-flow & Control-flow in the Lazy -Calculus joint work with Marc Pouzet M. Mendler, University of Bamberg Synchron 2008 CPL Aussois Synchron 2008 CPL Aussois 1 Constructive Data
Synchron 2008 – CPL Aussois
Synchron 2008 – CPL Aussois 1
joint work with Marc Pouzet
Synchron 2008 – CPL Aussois
Lusterel-2
Synchron 2008 – CPL Aussois
Synchron 2008 – CPL Aussois 3
Synchron 2008 – CPL Aussois
Synchron 2008 – CPL Aussois 4
wA
A/arm
wB
B/arm
WaitAandB
done
/ AB
dA dB
ABSync Reset signal arm
idle cnt 1
arm Detection Inhib
Timer
2 T / disarm
eot
disarm
2
signal disarm
Synchron 2008 – CPL Aussois
Synchron 2008 – CPL Aussois
Lusterel-6
equational reasoning higher-order polymorphic declarative extensible
strong typing smooth morphing between data and control-flow
Synchron 2008 – CPL Aussois
Synchron 2008 – CPL Aussois 7
Synchron 2008 – CPL Aussois
Synchron 2008 – CPL Aussois 8
Synchron 2008 – CPL Aussois
Lusterel-9
Synchron 2008 – CPL Aussois
Synchron 2008 – CPL Aussois 10
Synchron 2008 – CPL Aussois
Synchron 2008 – CPL Aussois 11
Synchron 2008 – CPL Aussois
Synchron 2008 – CPL Aussois 12
Synchron 2008 – CPL Aussois
Synchron 2008 – CPL Aussois 13
Synchron 2008 – CPL Aussois
Synchron 2008 – CPL Aussois 14
Synchron 2008 – CPL Aussois
Synchron 2008 – CPL Aussois 16
xs = ys = zs = xs = f (3 fby (fst zs), snd zs) zs f h g
fby
3 ys xs ys = h (snd xs) zs = g (ys, fst xs) 3 5 6 2
Synchron 2008 – CPL Aussois
Synchron 2008 – CPL Aussois 17
xs = ys = zs = xs = f (3 fby (fst zs), snd zs) zs f h g
fby
3 ys xs ys = h (snd xs) zs = g (ys, fst xs) 3 9 5 6 1 2 9 4
Synchron 2008 – CPL Aussois
Synchron 2008 – CPL Aussois 18
4 1 9 3 5 2 5 2 1 xs = ys = zs = xs = f (3 fby (fst zs), snd zs) zs f h g
fby
3 ys xs ys = h (snd xs) zs = g (ys, fst xs) 7 7 9 5 1 3 5 6 2
Synchron 2008 – CPL Aussois
Synchron 2008 – CPL Aussois 19
xs = f (3 fby (fst zs), snd zs) ys = h (snd xs) zs = g (ys, fst xs) fst (f(3:fst zs), snd(g(h(snd(f(3 fby (fst zs), snd zs))),fst xs) … loop ! fst xs fst (f(3 fby (fst zs), snd zs)) fst (f(3:(fst zs), snd zs)) fst (f(3:(fst zs), snd(g(ys,fst xs)))) fst (f(3:(fst zs), snd(g(h(snd xs),fst xs)) zs f h g
fby
3 ys xs Eager Evaluation
lazy on streams lazy on state (data)
Synchron 2008 – CPL Aussois
Synchron 2008 – CPL Aussois 20
xs = f (3 fby (fst zs), snd zs) ys = h (snd xs) zs = g (ys, fst xs) fst xs fst(f(3 fby (fst zs), snd zs)) fst((f1 × f2)(3 fby (fst zs), snd zs)) fst((λw.(f1(fst w), f2(snd w))(3 fby (fst zs), snd zs)) fst(f1(fst(3 fby (fst zs), snd zs)), f2(snd(3 fby (fst zs), snd zs))) f1(3:(fst zs)) f1(3) : f1(fst zs) f1(fst(3 fby (fst zs), snd zs)) f h g
fby
3 ys xs zs f1(3 fby (fst zs)) ... f1(3) : H(f1(3)) : H(H(f1(3))) : H(H(H(f1(3)))) : ... where H[v] = f1(g1(h(f2(g2(v)))) Lazy Evaluation
Synchron 2008 – CPL Aussois
Lusterel-21
Synchron 2008 – CPL Aussois
Synchron 2008 – CPL Aussois 28
when
xs cs zs xs = x0 x1 ⊥ x2 ⊥ x3 x4 ⊥ x5 x6 ... cs = T F ⊥ F ⊥ T F ⊥ T T ... zs = x0 ⊥ ⊥ ⊥ ⊥ x3 ⊥ ⊥ x5 x6 ... cs?c xs?x zs!x tick c=F c=T tick absence ⊥ is not communicated !
Synchron 2008 – CPL Aussois
Synchron 2008 – CPL Aussois 29
when
xs cs1 zs xs = x0 x1 ⊥ x2 ⊥ x3 x4 ⊥ x5 x6 ... cs1= T F ⊥ F ⊥ T F ⊥ T T ... zs = x0 ⊥ ⊥ ⊥ ⊥ x3 ⊥ ⊥ x5 x6 ... ys = y0 y1 ⊥ y2 ⊥ y3 y4 ⊥ y5 y6 ... cs2= F T ⊥ T ⊥ F T ⊥ F F ... zs = ⊥ y1 ⊥ y2 ⊥ ⊥ y4 ⊥ ⊥ ⊥ ...
when
ys cs2 zs
zs = x0 y1 ⊥ y2 ⊥ x3 y4 ⊥ x5 x6 ...
Synchron 2008 – CPL Aussois
Synchron 2008 – CPL Aussois 30
when
xs cs1 zs zs = x0 ⊥ ⊥ ⊥ ⊥ x3 ⊥ ⊥ x5 x6 ... zs = ⊥ y1 ⊥ y2 ⊥ ⊥ y4 ⊥ ⊥ ⊥ ... ``state bus´´ zs
when
ys cs2 zs state bus values = response functions: parallel emits = function composition: The last value dominates the bus
zs = x0 y1 ⊥ y2 ⊥ x3 y4 ⊥ x5 x6 ...
Synchron 2008 – CPL Aussois
Synchron 2008 – CPL Aussois 31
when
xs cs1 zs zs = x0 ⊥ ⊥ ⊥ ⊥ x3 ⊥ ⊥ x5 x6 ... zs = ⊥ y1 ⊥ y2 ⊥ ⊥ y4 ⊥ ⊥ ⊥ ... ``state bus´´ zs
when
ys cs2 zs
SF DF DF
zs = x0 y1 ⊥ y2 ⊥ x3 y4 ⊥ x5 x6 ...
Synchron 2008 – CPL Aussois
Synchron 2008 – CPL Aussois 32
zs = x0 ⊥ ⊥ ⊥ ⊥ x3 ⊥ ⊥ x5 x6 ... zs = ⊥ y1 ⊥ y2 ⊥ ⊥ y4 ⊥ ⊥ ⊥ ...
SF DF DF
Synchron 2008 – CPL Aussois
Lusterel-33
Synchron 2008 – CPL Aussois
Synchron 2008 – CPL Aussois 37
R::b
DF::SDF (a,b) c
E::a v::c
R::b
SF::SSM a b
E::a
Synchron 2008 – CPL Aussois
Lusterel-39
Synchron 2008 – CPL Aussois
Lusterel-40
state flow variable signal emission weak preemption parallel binding DF to signal local signal iteration wait branching signal input
Synchron 2008 – CPL Aussois
Lusterel-41
close-off state flow static lifting of value operators up-sampling down-sampling delay initialisation initialised delay data flow variable feed-back, recursive data flow
Synchron 2008 – CPL Aussois
Lusterel-46
SEC TDIV
STOP
Synchron 2008 – CPL Aussois
START s := 0 last_s Leftb/
H
Leftb/ Rightb/ CONTROL last_s := pre s MEM CHRONO s := if False cnt < pre cnt then (last_s + 1) ´mod´ 60 else last_s cnt := 0 (pre cnt + 1) mod 100
Synchron 2008 – CPL Aussois
MEM
s
STOP
last_s s
START
s
SEC
cnt
TDIV
time
CONTROL
last_s
CHRONO
s
user action
system
Synchron 2008 – CPL Aussois
MEM
s last_s
Synchron 2008 – CPL Aussois
STOP
s last_s
Synchron 2008 – CPL Aussois
STOP
s last_s
Synchron 2008 – CPL Aussois
START
s
SEC
cnt
TDIV
last_s
Synchron 2008 – CPL Aussois
CTRL
s env last_s STOP START CONTROL H
Leftb/ Leftb/ Rightb/
Synchron 2008 – CPL Aussois
CTRL
s env last_s STOP START CONTROL H
Leftb/ Leftb/ Rightb/
Synchron 2008 – CPL Aussois
CTRL
s env last_s
STOP START CONTROL H
Leftb/ Leftb/ Rightb/
Synchron 2008 – CPL Aussois
MEM
CHRONO
CONTROL
s last_s s s
CHRONO
s
user action
Synchron 2008 – CPL Aussois
tick zs!s ys?act xs zs s ys isRbp act / s←0 i s L b p a c t / d ←
startb s d stopb s
zs!s tick ys?act isLbp act / / d←d+1 d=100 / s←s+1´mod´60 d← 0 1 2 3 2 3 1
chrono
/ s←0 d
Haskell implementation
Synchron 2008 – CPL Aussois
Lusterel-76
Synchron 2008 – CPL Aussois
Lusterel-88
Esterel Control Flow is concurrent (non-sequential) ! Concurrent AND Æ
xs ys zs present x else pause ; present y then emit z present x else pause ; present y then emit z x y z present x then present y then emit z; present x then present y then emit z; x z y
z is absent if at least one of x or y is absent
present x then emit z || present y then emit z present x then emit z || present y then emit z x y z
Concurrent OR z is present if at least one of x or y is present
xs ys zs
Ç
Synchron 2008 – CPL Aussois
Lusterel-89
Synchron 2008 – CPL Aussois