Lucy-n: a n-Synchronous Extension of Lustre Louis Mandel Florence Plateau Marc Pouzet Laboratoire de Recherche en Informatique Universit´ e Paris-Sud 11 INRIA Saclay – Ile-de-France MPC – 22/06/2010
Kahn Process Networks [Gilles Kahn, 1974] x y i o P Q R Network of processes • concurrent execution • communication through buffers of sufficient size If processes are deterministic then the network is deterministic 2
Programming Kahn Process Networks Problem: computation of sufficient buffer sizes • risk of data loss, of deadlock • sometimes, need of infinite buffers Goal: • rejection of infinite buffers • automatic sizing of buffers Related work: • Synchronous Data Flow and variants [Lee et al. ] [Buck] • scheduling [Carlier, Chretienne] [Baccelli, Cohen, Quadrat] • Network Calculus [Cruz], Real-time Calculus [Thiele et al. ] 3
Dataflow Synchronous Model x y i o Q P R Programming Kahn networks without buffers: • programming languages: Lustre, Signal, Lucid Synchrone • instantaneous consumption of produced data • strong guaranties: bounded memory, absence of deadlocks But: communication without buffers sometimes too restrictive (e.g. multimedia applications) 4
n-Synchronous Model x y i o Q P R Programming Kahn networks with bounded memory Automatic methods at compile time to: • reject networks needing infinite memory • compute activation paces of computations nodes • compute sufficient buffers sizes More flexibility with the same guaranties 5
Overview 1. Lucy-n: a n-Synchronous Extension of Lustre 2. Adaptability Relation 3. Clock Typing 6
Lucy-n: a n-Synchronous Extension of Lustre
A Dataflow Synchronous Kernel ` a la Lustre x flow values clock 5 7 3 6 2 8 1 1111111 ... x ... 8
A Dataflow Synchronous Kernel Sampling c x when flow values clock 5 7 3 6 2 8 1 1111111 ... x ... c 1 0 1 0 1 0 1 ... 5 3 2 1 1010101 ... x when c ... clock ( x when c ) = clock ( x ) on c def on operator : = 0 . ( w 1 on w 2 ) 0 .w 1 on w 2 def = 1 . ( w 1 on w 2 ) 1 .w 1 on 1 .w 2 def = 0 . ( w 1 on w 2 ) 1 .w 1 on 0 .w 2 8
A Dataflow Synchronous Kernel Sampling c d x when when flow values clock 5 7 3 6 2 8 1 1111111 ... x ... c 1 0 1 0 1 0 1 ... 5 3 2 1 1010101 ... x when c ... d 1 0 1 1 ... 5 2 1 1000101 ... (x when c) when d ... clock ( (x when c) when d ) = clock ( x when c ) on d def on operator : = 0 . ( w 1 on w 2 ) 0 .w 1 on w 2 def = 1 . ( w 1 on w 2 ) 1 .w 1 on 1 .w 2 def = 0 . ( w 1 on w 2 ) 1 .w 1 on 0 .w 2 8
A Dataflow Synchronous Kernel Scalar Operators x z + y flow values clock 5 7 3 6 2 8 1 111111 ... x ... 3 2 1 5 4 1 7 111111 ... y ... 8 9 4 11 6 9 8 111111 ... z = x + y ... 9
A Dataflow Synchronous Kernel Scalar Operators c x z t + when y flow values clock 5 7 3 6 2 8 1 111111 ... x ... 3 2 1 5 4 1 7 111111 ... y ... 8 9 4 11 6 9 8 111111 ... z = x + y ... c 1 0 1 0 1 0 1 ... 8 4 6 8 101010 ... t = z when c ... 9
A Dataflow Synchronous Kernel Scalar Operators c x z t + when y o c + r when flow values clock 5 7 3 6 2 8 1 111111 ... x ... 3 2 1 5 4 1 7 111111 ... y ... 8 9 4 11 6 9 8 111111 ... z = x + y ... c 1 0 1 0 1 0 1 ... 8 4 6 8 101010 ... t = z when c ... 3 1 4 7 101010 ... r = y when c ... 11 5 10 15 101010 ... o = t + r ... 9
A Dataflow Synchronous Kernel Scalar Operators c x z t + when y o c’ + r when flow values clock 5 7 3 6 2 8 1 111111 ... x ... 3 2 1 5 4 1 7 111111 ... y ... 8 9 4 11 6 9 8 111111 ... z = x + y ... c 1 0 1 0 1 0 1 ... 8 4 6 8 101010 ... t = z when c ... 2 5 1 010101 ... r = y when c’ ... rejected o = t + r 10
n-Synchronous Extension: Bufferization Operator c x z t t’ + when y o c’ + r when flow values clock 8 4 6 8 ... 101010 ... t = z when c 8 4 6 ... 010101 ... t’ = buffer(t) 2 5 1 ... 010101 ... r = y when c’ 10 9 7 ... 010101 ... o = t’ + r • adaptability relation ⇒ communication through a bounded buffer • example : clock ( t ) < : clock ( t’ ) 11
Adaptability Relation
Cumulative Function 11 Number of ones 10 O w 1 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Instants w 1 1 1 0 1 0 1 1 0 1 0 1 1 0 1 0 1 O w 1 : cumulative function of the word w 1 13
Adaptability Relation 11 Number of ones 10 O w 1 9 O w 2 8 7 Writings in the buffer 6 5 4 3 2 Readings in the buffer 1 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Instants buffer size size ( w 1 , w 2 ) = max i ∈ N ( O w 1 ( i ) − O w 2 ( i )) def adaptability w 1 < : w 2 ⇔ ∃ n ∈ N , ∀ i, 0 ≤ O w 1 ( i ) − O w 2 ( i ) ≤ n 14
Adaptability Relation 11 Number of ones 10 O w 1 9 O w 2 8 7 Writings in the buffer 6 5 4 3 2 Readings in the buffer 1 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Instants buffer size size ( w 1 , w 2 ) = max i ∈ N ( O w 1 ( i ) − O w 2 ( i )) def adaptability w 1 < : w 2 ⇔ ∃ n ∈ N , ∀ i, 0 ≤ O w 1 ( i ) − O w 2 ( i ) ≤ n def synchronizability ⇔ ∃ b 1 , b 2 ∈ Z , ∀ i, b 1 ≤ O w 1 ( i ) − O w 2 ( i ) ≤ b 2 w 1 ⊲ ⊳ w 2 def precedence w 1 � w 2 ⇔ ∀ i, O w 1 ( i ) ≥ O w 2 ( i ) 14
Ultimately Periodic Clocks 11 Number of ones 10 O w 1 9 O w 2 8 7 Writings in the buffer 6 5 4 3 2 Readings in the buffer 1 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Instants Example : 0(00111) = 0 00111 00111 ... Checking relations on clocks • synchronizability test: (11010) ⊲ ⊳ 0(00111) • precedence test: (11010) � 0(00111) 15
Abstract Clocks: abs ( w ) = � b 0 , b 1 � ( r ) 11 Number of ones ∆ 1 ¸ ` 3 10 0 , 4 ˙ ´ ∆ 0 a 1 = 5 5 O w 1 9 8 7 ∆ 1 : r × i + b 1 6 5 ∆ 0 : r × i + b 0 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Instants O w ( i ) ≤ ∆ 1 ( i ) w [ i ] = 1 ⇒ concr ( � b 0 , b 1 � ( r )) = w | O w ( i ) ≥ ∆ 0 ( i ) w [ i ] = 0 ⇒ 16
Adaptability Relation on Abstract Clocks ⊳ ∼ and � ∼ ⊲ 11 Number of ones ¸ ` 3 10 0 , 4 ˙ ´ a 1 = O w 1 5 5 9 O w 2 8 7 6 5 4 ¸ ` 3 3 − 9 5 , − 3 ˙ ´ a 2 = 5 5 2 1 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Instants ⊳ ∼ � b 0 2 , b 1 2 � ( r 2 ) def � b 0 1 , b 1 1 � ( r 1 ) ⊲ synchronizability ⇔ r 1 = r 2 � b 0 1 , b 1 1 � ( r ) � ∼ � b 0 2 , b 1 2 � ( r ) def ⇔ b 1 2 − b 0 1 < 1 precedence size ∼ ( a 1 , a 2 ) = ⌊ b 1 1 − b 0 2 ⌋ buffer size 17
Property Property size_abs_correctness: forall (w1:ibw) (w2:ibw), forall a1 a2: abstraction_phd, forall H_swf_a1: strong_well_formed_abstraction_phd a1, forall H_swf_a2: strong_well_formed_abstraction_phd a2, forall H_non_empty_1: non_empty a1, forall H_non_empty_2: non_empty a2, forall (H_a1_eq_abs_w1: in_abstraction_phd w1 a1), forall (H_a2_eq_abs_w2: in_abstraction_phd w2 a2), forall H_sub: adaptability_abs a1 a2, forall s, size w1 w2 s -> (s <= size_abs a1 a2)%Z. Correctness properties proved in Coq: ✿ 18
Clock Typing
Typing plus plus c x z t t’ + when y o c’ + r when let node plus_plus (x,y) = o where 4 rec z = x + y 5 and t = z when c 6 and t’= buffer(t) 7 and r = y when c’ 8 and o = t’ + r 9 val plus_plus : (int * int) -> int val plus_plus :: forall ’a. (’a * ’a) -> ’a on c’ Buffer line 7, characters 11-21: size = 1 20
Typing plus plus c x x α z z t t’ + when y y α o c’ + α r when let node plus_plus (x,y) = o where 4 rec z = x + y 5 and t = z when c 6 and t’= buffer(t) 7 and r = y when c’ 8 and o = t’ + r 9 val plus_plus : (int * int) -> int val plus_plus :: forall ’a. (’a * ’a) -> ’a on c’ Buffer line 7, characters 11-21: size = 1 20
Typing plus plus c x x α z z t t t’ t’ + when y y α α on c o c’ + α r r when α on c ′ let node plus_plus (x,y) = o where 4 rec z = x + y 5 and t = z when c 6 and t’= buffer(t) 7 and r = y when c’ 8 and o = t’ + r 9 val plus_plus : (int * int) -> int val plus_plus :: forall ’a. (’a * ’a) -> ’a on c’ Buffer line 7, characters 11-21: size = 1 20
Typing plus plus c x x α z z t t t t’ t’ t’ + when y y α α on c ′ α on c o o c’ + α α on c ′ r r when α on c ′ let node plus_plus (x,y) = o where 4 rec z = x + y 5 and t = z when c 6 and t’= buffer(t) 7 and r = y when c’ 8 and o = t’ + r 9 val plus_plus : (int * int) -> int val plus_plus :: forall ’a. (’a * ’a) -> ’a on c’ Buffer line 7, characters 11-21: size = 1 20
Typing plus plus c x x α z z t t t t’ t’ t’ + when y y α α on c ′ α on c o o c’ + α α on c ′ r r when α on c ′ < : α on c ′ } , ( α × α ) → α on c ′ for all α such that { α on c < : < : Subtyping constraint solving • simple case: α on w 1 < : < : < : α on w 2 ⇔ w 1 < : w 2 size ( α on w 1 , α on w 2 ) = size ( w 1 , w 2 ) 21
Recommend
More recommend