Abstraction of Clocks in Synchronous Data-flow Systems A. Cohen 1 L. - - PowerPoint PPT Presentation

abstraction of clocks in synchronous data flow systems
SMART_READER_LITE
LIVE PREVIEW

Abstraction of Clocks in Synchronous Data-flow Systems A. Cohen 1 L. - - PowerPoint PPT Presentation

Abstraction of Clocks in Synchronous Data-flow Systems A. Cohen 1 L. Mandel 2 F. Plateau 2 M. Pouzet 23 (1) INRIA Saclay - Ile-de-France, Orsay, France (2) LRI, Univ. Paris-Sud 11, Orsay, France and INRIA Saclay (3) Institut Universitaire de


slide-1
SLIDE 1

Abstraction of Clocks in Synchronous Data-flow Systems

  • A. Cohen 1
  • L. Mandel 2
  • F. Plateau 2
  • M. Pouzet23

(1) INRIA Saclay - Ile-de-France, Orsay, France (2) LRI, Univ. Paris-Sud 11, Orsay, France and INRIA Saclay (3) Institut Universitaire de France

Synchron Workshop - 2 December 2008

slide-2
SLIDE 2

N-Synchronous Model: A Relaxed Notion of Synchrony

A B

ha hb

◮ 0-synchronous : no buffers (ha = hb).

For instance (1010) = (0110).

◮ n-synchronous : buffer of size n (ha <: hb).

For instance (1010) <: (0110) Interest: more flexible, as much guaranties as in synchronous model.

slide-3
SLIDE 3

N-Synchronous Model: picture in picture example

!"#$%"&'() *)'+# ,+"#-+# .+#'$/() *)'+#

β1 β1 on hf β2 β2 on reorder β3 β3 on vf

0"1&2/()+#

α α on hf on reorder on vf hf = (10100100) reorder = 03600(1) vf = (172007201720072007201720072007201720)

0"1&2/()+# 13+&

not incrust

4+#5+

α1 α1 on hf on reorder on vf α2 α2 on not incrust α3 on not incrust α3 on incrust incrust α3

◮ Previous work: subtyping relation can be checked provided

clocks are periodic.

◮ Motivations:

  • 1. dealing with long patterns in periodic clocks
  • 2. modelizing jitter

How to deal with “almost periodic” clocks ? For instance α on w with w = 00.( (10) + (01) )ω (e.g. w = 00 01 10 01 01 10 01 10 . . . )

slide-4
SLIDE 4

Clocks as Infinite Binary Words

Instants Number of ones 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 13 12 11 10 9 8 7 6 5 4 3 2 1

Ow1 Ow2 Ow3

[w1]6 |w1[1..8]|1 w1

w ::= 0.w | 1.w Notations: w[i] : element at index i [w]j : position of the jth 1 Ow(i): number of 1s seen in w until index i. buffer size(w1, w2) = maxi∈N(Ow1(i) − Ow2(i)) precedence w1 w2

def

⇔ ∀i, Ow1(i) ≥ Ow2(i)

synchronizability w1 ⊲ ⊳ w2

def

⇔ ∃b1, b2 ∈ Z, ∀i, b1 ≤ Ow1(i) − Ow2(i) ≤ b2

subtyping w1 <: w2

def

⇔ (w1 w2)/ (w2 w2)

composed clocks c ::= w | not w | c on c

slide-5
SLIDE 5

Abstraction of Infinite Binary Words [SYNCHRON’07, APLAS’08]: abs(w) = [d, D] (T)

concr ([d, D] (T)) def ⇔ {w, ∀j ≥ 0, T ×j +d ≤ [w]j+1 ≤ T ×j +D}

Instants Number of ones 12 11 10 9 8 7 6 5 4 3 2 1 7 6 5 4 3 2 1

fw1 fw2

[w2]5

{ a1

}a2

w2 d = 5

3

T = 5

3

D = 9

3

T = 5

3

slide-6
SLIDE 6

Drawbacks

◮ sets of 1s in prefix are badly abstracted.

Instants Number of ones 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 14 13 12 11 10 9 8 7 6 5 4 3 2 1

fnot w4 fw4

⇒ a ⊆ not∼ not∼ a.

◮ words with finite number number of 1s cannot be abstracted.

⇒ not∼ can not be applied to 000(1).

slide-7
SLIDE 7

New Abstraction [JFLA’09]:

concr

  • b0, b1, r

def ⇔

  • w, ∀i ≥ 1,

w[i] = 1 ⇒ Ow(i − 1) < r × i + b1 ∧ w[i] = 0 ⇒ Ow(i − 1) ≥ r × i + b0

  • Instants

Number of ones 12 11 10 9 8 7 6 5 4 3 2 1 7 6 5 4 3 2 1

Ow1 Ow2

slide-8
SLIDE 8

◮ Initial sets of 1s are well abstracted. Instants Number of ones 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 14 13 12 11 10 9 8 7 6 5 4 3 2 1

Ow4

slide-9
SLIDE 9

◮ Clocks with a nul rate can be abstracted. Instants Number of ones 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 9 8 7 6 5 4 3 2 1

Ow5

slide-10
SLIDE 10

Abstract Clocks as Automata

4, 1 7, 2 6, 2 5, 1 4, 0 3, 0 2, 0 1, 0 1 1 1 1 1

a2 =

  • − 9

5, − 7 5, 3 5

  • 4, 0

3, 0 2, 0 1, 0 1 1

a4 =

  • − 3

2, − 2 2, 1 2

  • Aa = Q, Σ, δ, qo with:

◮ The set of states Q = {(i, j) ∈ N2} : coordinates in the

2D-chronograms. Finite number of state equivalence classes.

◮ The initial state qo is (0, 0) ◮ The alphabet Σ is {0, 1} ◮ The transition function δ is defined by:

δ(1, (i, j)) = nf (i + 1, j + 1) if Ow(i − 1) < r × i + b1 δ(0, (i, j)) = nf (i + 1, j) if Ow(i − 1) ≥ r × i + b0 It is undefined otherwise.

slide-11
SLIDE 11

Checking Clocks are in an Abstraction

type rat = { num: int; den: int; } (* "+:", "<:" ... are operations over rat *) let norm { num = n; den = l; } i j = if i >= l && j >= n then (i - l, j - n) else (i, j) let node check (b0, b1, r) clk = ok where rec i, j = (1,0) fby norm r (i+1) (if clk then j + 1 else j) and ok = if clk then (rat_of_int j) <: r *: (rat_of_int i) +: b1 else (rat_of_int j) >=: r *: (rat_of_int i) +: b0

slide-12
SLIDE 12

Generating Clocks in an Abstraction

let node generate choice (b0, b1, r) = clk where rec i, j = (1,0) fby norm r (i+1) (if clk then j + 1 else j) and one = (rat_of_int j) <: (r *: (rat_of_int i) +: b1) and zero = (rat_of_int j) >=: (r *: (rat_of_int i) +: b0) and clk = choice one zero let node early a = generate (fun x y -> x) a let node late a = generate (fun x y -> not y) a

slide-13
SLIDE 13

Generating Clocks in an Abstraction with Lustre Compiler (Pascal Raymond)

node generate(x : bool) returns (clk: bool); let

  • - we simply copy the input on the output

clk = x ;

  • - but we enforce the correctness of x

assert check(-9, -7, 3, 5, x) ; tel node early() returns (clk: bool); let clk = generate(true); tel node late() returns (clk: bool); let clk = generate(false); tel

slide-14
SLIDE 14

~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1

slide-15
SLIDE 15

Abstract Operators:

◮ abstract not operator:

not∼

b0, b1, r

  • =
  • −b1 − ε, −b0 − ε, 1 − r
  • with r = n

l ,

b0 = k0

l ,

b1 = k1

l ,

ε = l−1

l

Property: a = not∼ not∼ a

◮ abstract on operator:

  • b01, b11, r1
  • n∼

b02, b12, r2

  • =
  • b012, b112, r12
  • with:

r12 = r1 × r2, b012 = b01 × r2 + b02, b112 = b11 × r2 + b12 + ε.

slide-16
SLIDE 16

Abstraction of a composed clock

◮ abs(c)

abs(not w)

def

not∼ abs(w)

abs(c1 on c2)

def

⇔ abs(c1) on∼ abs(c2) Proposition: c ∈ concr(abs(c))

slide-17
SLIDE 17

Abstract Relations

◮ synchronizability:

  • b01, b11, r1

⊳∼ b02, b12, r2

  • ⇔ r1 = r2

Proposition: abs(c1) ⊲ ⊳∼ abs(c2) ⇔ c1 ⊲ ⊳ c2

◮ precedence: b01 ≥ b12 ⇒ a1 ∼ a2

Proposition: abs(c1) ∼ abs(c2) ⇒ c1 c2

◮ subtyping: a1 <:∼ a2 ⇔ (a1 ⊲

⊳∼ a2) ∧ (a1 ∼ a2) ⇒ can be checked in constant time.

slide-18
SLIDE 18

Proofs in Coq

concr

  • b0, b1, r

def ⇔

  • w, ∀i ≥ 1,

w[i] = 1 ⇒ Ow(i − 1) < r × i + b1 ∧ w[i] = 0 ⇒ Ow(i − 1) ≥ r × i + b0

  • Definition in_abstractionj (w: ibw) (a:abstractionj) :=

forall i: nat, forall H_i_ge_1: (i >= 1)%nat, (w i = true -> ones w (pred i) < absj_r a * i + absj_b1 a) /\ (w i = false -> ones w (pred i) >= absj_r a * i + absj_b0 a).

slide-19
SLIDE 19

Proofs in Coq

For instance, on∼ correctness:

Property on_correctness: forall (w1:ibw) (w2:ibw), forall H_wf_w1: well_formed_ibw w1, forall H_wf_w2: well_formed_ibw w2, forall (a1:abstractionj) (a2:abstractionj), forall H_wf_a1: well_formed_abstractionj a1, forall H_wf_a2: well_formed_abstractionj a2, forall (H_a1_eq_absj_w1: in_abstractionj w1 a1), forall (H_a2_eq_absj_w2: in_abstractionj w2 a2), in_abstractionj (on w1 w2) (on_absj a1 a2).

slide-20
SLIDE 20

Other Applications - Modelizing Execution Time

Instants Number of ones 12 11 10 9 8 7 6 5 4 3 2 1 7 6 5 4 3 2 1

f :: ∀α.α on∼ 0, 0, 1

2

  • → α on∼

− 3

2, − 1 2, 1 2

  • Composed twice:

f o f :: ∀α.α on∼ 0, 0, 1

2

  • → α on∼

− 6

2, − 2 2, 1 2

slide-21
SLIDE 21

Other Applications

Modelizing Several Reads (or writes) at the Same Instant

Instants Number of ones 12 11 10 9 8 7 6 5 4 3 2 1 14 13 12 11 10 9 8 7 6 5 4 3 2 1