Automated generation of BSP Automata - Julien Tesson

BSP code (well structured). DSL for queries. • based on BSPRE. • computed by a BSPA. Limitations. • regular expressions expressiveness. • output is a boolean ...
2MB taille 3 téléchargements 501 vues
Automated generation of BSP Automata Thibaut Tachon Ga´etan Hains Supervisor in Huawei

&

Fr´ed´eric Loulergue Academic supervisor

Frebrary 15th, 2017

1/28

Content Introduction Definitions BSP Language BSP Regular Expressions BSP Automaton Applications Query Language Parallel recognition of RE From BSPRE to BSPA Desynchronization Br¨ uggemann-Klein Synchronization Conclusion 2/28

Regular language Regular Expressions r

::= | | | | |

Finite Automata

r r0 r + r0 r∗ a  ∅

A = (Q, Σ, δ, I , F ) Q Σ δ I F

State set Alphabet Transitions Initial states Final states

Br¨uggemann-Klein r = (a + b)ba∗

b

=⇒

0

2

a

a b b

3

a

4

1

3/28

Bulk-Synchronous Parallel model • Superstep sequence • Local determinism → global determinism • Neither deadlocks nor data races • Simple cost model

Async computations

Communications Sync

local comp. 0 local comp. 1

Next Superstep comp. 0

...

comp. 1

...

comp. 2

...

comp. 3

...

Barr. local comp. 2 local comp. 3

4/28

BSP Language Regular language Symbol : Word : Language :

Type Σ Σ∗  P Σ∗

Example a abccd {a, aab, ab}

BSP words and language Word vector : BSP word : BSP Language :

p processors

Type

Example

(Σ∗ )p

hab, a, bbbi hab, aihbb, abai {hab, ai, hab, baiha, bbbi}

((Σ∗ )p )∗  P ((Σ∗ )p )∗

5/28

BSP Regular Expressions Grammar R ::= R R 0 | R + R 0 | R ∗ | ∅ |  | hr 0 , . . . , r p−1 i

Language r

L(r )

r0

L(r 0 )

r L(r ) · 0 r + r L(r ) ∪ L(r 0 ) ∞

r∗

∪Li (r ) i=0

a  ∅

{a} {} {}

R R0

L(R)

R R + R0

L(R) · L(R 0 ) L(R) ∪ L(R 0 )

R∗

∪Li (R) i=0



hr0 , . . . , rp−1 i L(r0 ) × · · · × L(rp−1 )  {} ∅ {} 6/28

BSP Automata : Definition

A = ({Q i }i∈[p] , Σ, {δ i }i∈[p] , {I i }i∈[p] , {F i }i∈[p] , ∆) • p sized automata vector • Common alphabet • Synchronization function

Delta

Notation

• ∆ : Qp → Qp

• p processors

• Q p = (Q 0 × ... × Q p−1 )

• [p] = {0 . . . p − 1}

7/28

BSP Automata: Example (p = 2) c 0

a

1

b

b

b

2 Δ

a 0'

3

2'

3'

b

5 4 a

d d

7

6 Δ 4'

5'

a

1'

8/28

BSP Automata: Example (p = 2) c 0

a

1

b

b

b

2 Δ

a 0'

3

2'

3'

b

5 4 a

d d

7

6 Δ 4'

5'

a

1'

Legend

8/28

BSP Automata: Example (p = 2) c 0

a

1

b

b

b

2

b

Δ

a 0'

3

2'

5 4 a

3'

d d

7

6 Δ 4'

5'

a

1'

Legend

Delta ∆ = { h2, 20 i → h3, 30 i , h6, 40 i → h7, 50 i}

8/28

BSP Automata: Example (p = 2) c 0

a

1

b

b

b

2

b

Δ

a 0'

3

2'

5 4 a

3'

d d

7

6 Δ 4'

5'

a

1'

Legend

Delta ∆ = { h2, 20 i → h3, 30 i , h6, 40 i → h7, 50 i}

Accept : hab, aihbd, ai ?

8/28

BSP Automata : Recognition hq00 , . . . , q0p−1 i

9/28

BSP Automata : Recognition hq00 , . . . , q0p−1 i

input 6= 

Apply ∆

yes

yes

(Apply δ ∗ )p

∆ arg

9/28

BSP Automata : Recognition hq00 , . . . , q0p−1 i

input 6= 

Apply ∆

yes

yes

(Apply δ ∗ )p

∆ arg

no Reject

9/28

BSP Automata : Recognition hq00 , . . . , q0p−1 i

input 6= 

yes

(Apply δ ∗ )p

no Apply ∆

All final yes

Accept

yes

∆ arg

no no Reject

9/28

BSP Automata: Example (p = 2) c 0

a

1

b

b

b

2

b

Δ

a 0'

3

2'

5 4 a

3'

d d

7

6 Δ 4'

5'

a

1'

Legend

Delta ∆ = { h2, 20 i → h3, 30 i , h6, 40 i → h7, 50 i}

Accept : hab, aihbd, ai ?

10/28

Model Regular language Symbol : Word : Language :

Type Σ Σ∗  P Σ∗

model an instruction a program trace all possible traces of a program

BSP words and language Word vector : BSP word : BSP Language :

p processors

Type

model

(Σ∗ )p

one superstep a BSP program trace all possible program traces

((Σ∗ )p )∗  P ((Σ∗ )p )∗

11/28

Query language Which target • BSP program trace • BSP code (well structured)

DSL for queries • based on BSPRE • computed by a BSPA

Limitations • regular expressions expressiveness • output is a boolean

12/28

Parallel recognition of RE

RE

Σ∗

DFA Bool

13/28

Parallel recognition of RE RE

DFA

Σ∗

Bool

BSPRE

(Σ∗ )p

∗

BSPA Bool 13/28

Parallel recognition of RE RE

Σ∗

DFA Bool

RE

Σ∗

BSPRE

(Σ∗ )p

∗

BSPA Bool 13/28

From RE to BSPRE String research r = σ ∗ string σ ∗

where r ∈ RE σ = ∀σi ∈ Σ, (σ0 + σ1 + . . . )

Distribution of input Block

P1

P2

P3

14/28

Block distribution

P1

P2

P3

R ∈ BSPRE   

h σ∗ , σ∗ , σ ∗ string σ ∗ i R = +h σ∗ , σ ∗ string σ ∗ , σ∗ i   + h σ ∗ string σ ∗ , σ∗ , σ∗ i ?

15/28

Block distribution s t r i ng

P1

P2

P3

R ∈ BSPRE   

h σ∗ , σ∗ , σ ∗ string σ ∗ i R = +h σ∗ , σ ∗ string σ ∗ , σ∗ i   + h σ ∗ string σ ∗ , ∗ ∗ σ , σ i ?

15/28

Block distribution

s t r i ng

P1

P2

P3

R ∈ BSPRE   

h σ∗ , σ∗ , σ ∗ string σ ∗ i R = +h σ∗ , σ ∗ string σ ∗ , σ∗ i   + h σ ∗ string σ ∗ , σ∗ , σ∗ i ?

15/28

Block distribution

s t r i ng

P1

P2

P3

R ∈ BSPRE   

h σ∗ , σ∗ , σ ∗ string σ ∗ i R = +h σ∗ , σ ∗ string σ ∗ , σ∗ i   + h σ ∗ string σ ∗ , σ∗ , σ∗ i ?

15/28

Block distribution

P1

R=

 h      +h      +h  

P2

σ∗ σ∗ σ∗

, , ,

P3

σ∗ σ∗ σ∗ .. .

, σ ∗ string σ ∗ i s , tring σ∗ i st , ring σ∗ i

   +h σ∗ , σ ∗ string σ ∗ ,    ..    .    ∗ ∗ + h σ string σ , σ∗ ,

σ∗

i

σ∗

i 15/28

Block distribution s t r i ng

P1

R=

 h      +h     + h  

P2

σ∗ σ∗ σ∗

, , ,

P3

σ∗ σ∗ σ∗ .. .

, σ ∗ string σ ∗ i s , tring σ∗ i st , ring σ∗ i

   +h σ∗ , σ ∗ string σ ∗ ,    ..    .    ∗ ∗ + h σ string σ , σ∗ ,

σ∗

i

σ∗

i 15/28

Block distribution s t r i ng

P1

R=

 h      +h     + h  

P2

σ∗ σ∗ σ∗

, , ,

P3

σ∗ σ∗ σ∗ .. .

, σ ∗ string σ ∗ i s , tring σ∗ i st , ring σ∗ i

   +h σ∗ , σ ∗ string σ ∗ ,    ..    .    ∗ ∗ + h σ string σ , σ∗ ,

σ∗

i

σ∗

i 15/28

Block distribution let m = |string |

R=

 h      +h      +h  

σ∗ σ∗ σ∗

, , ,

σ∗ σ∗ σ∗ .. .

, σ ∗ string σ ∗ i s , tring σ∗ i st , ring σ∗ i

   +h σ∗ , σ ∗ string σ ∗ ,    ..    .    ∗ ∗ + h σ string σ , σ∗ ,

σ∗

i

σ∗

i

Possibilities number (p − 1) × m + 1 15/28

Parallel recognition of RE

RE

Σ∗

BSPRE

(Σ∗ )p

∗

BSPA Bool

16/28

From BSPRE to BSPA

Algorithm global scheme

(Σ, p) bspre

(Σ, p) bspa

Desynchronization

(Σ ∪ {;t }) re

p

Synchronization

(BK : re → nfa)

p

(Σ ∪ {;t }) nfa

p

17/28

Desynchronization

(Σ, p) bspre → (Σ ∪ {;t }) re

p

Pre-processing • Vectors annotated with their position • Depth First Search of syntactic tree • Vector number : S

18/28

Desynchronization

(Σ, p) bspre → (Σ ∪ {;t }) re

p

Pre-processing • Vectors annotated with their position • Depth First Search of syntactic tree • Vector number : S

Annotation example a, bb,  (a+b)∗ , h a+b i+h a∗ i h aa i

18/28

Desynchronization

(Σ, p) bspre → (Σ ∪ {;t }) re

p

Pre-processing • Vectors annotated with their position • Depth First Search of syntactic tree • Vector number : S

Annotation example

=⇒

a, bb,  (a+b)∗ , h a+b i+h a∗ i h aa i a, bb,  (a+b)∗ , h a+b i0 +h a∗ i1 h aa i2

18/28

Desynchronization

(Σ, p) bspre → (Σ ∪ {;t }) re

p

Auxiliary recursive function dsni (F ·BSP G ) = dsni (F ) · dsni (G ) dsni (F +BSP G ) = dsni (F ) + dsni (G ) dsni (F ∗BSP ) = dsni (F )∗ dsni (hr0 , . . . , rp−1 it ) = ri · ;t dsni (BSP ) =  dsni (∅BSP ) = ∅

Main function Dsn(R) = hdsn0 (R), . . . , dsnp−1 (R)i 19/28

Desynchronization

(Σ, p) bspre → (Σ ∪ {;t }) re

p

Auxiliary recursive function dsni (F ·BSP G ) = dsni (F ) · dsni (G ) dsni (F +BSP G ) = dsni (F ) + dsni (G ) dsni (F ∗BSP ) = dsni (F )∗ dsni (hr0 , . . . , rp−1 it ) = ri · ;t dsni (BSP ) =  dsni (∅BSP ) = ∅

Main function 0

Dsn(R) = hdsn (R), . . . , dsn

p−1

(R)i

Σdsync = Σ∪

 S

;t



t∈[S] 19/28

From BSPRE to BSPA

Algorithm global scheme

(Σ, p) bspre

(Σ, p) bspa

Desynchronization

(Σ ∪ {;t }) re

p

Synchronization

(BK : re → nfa)

p

(Σ ∪ {;t }) nfa

p

20/28

Br¨uggemann-Klein

  (Σ ∪ {;t }) re → (Σ ∪ {;t }) nfa

Principles • Improvement of Glushkov O(n3 ) • Pre-processing : Star Normal From

Features • Time complexity : O(n2 ) • Space complexity : O(n) • No -transitions. i ∀i ∈ [p], Ai = (Q i , Σdsync , δdsync , Ii, Fi)

21/28

From BSPRE to BSPA

Algorithm global scheme

(Σ, p) bspre

(Σ, p) bspa

Desynchronization

(Σ ∪ {;t }) re

p

Synchronization

(BK : re → nfa)

p

(Σ ∪ {;t }) nfa

p

22/28

Synchronization : Auxiliary functions For each ;t

...

1

...

2

...

3 4

;t ;t ;t

5

...

6

...

7

...

;t

23/28

Synchronization : Auxiliary functions For each ;t

...

1

...

2

...

3 4

;t ;t ;t

5

...

6

...

7

...

;t

23/28

Synchronization : Auxiliary functions For each ;t

... ...

...

1 × 2 × 3 4

;t ;t ;t

5

...

6

...

7

...

;t

23/28

Synchronization : Auxiliary functions For each ;t arg t : state vector set ... ...

...

1 × 2 × 3 4

;t ;t ;t

5

...

6

...

7

...

;t

arg t

23/28

Synchronization : Auxiliary functions For each ;t

... ...

...

1 × 2 × 3 4 arg t

;t ;t ;t

5 × 6 × 7

...

arg t : state vector set res t : state vector set

... ...

;t

res t

23/28

Synchronization : Auxiliary functions For each ;t

... ...

...

1 × 2 × 3 4 arg t

;t ;t ;t

5 × 6 × 7

arg t : state vector set res t : state vector set

... ... ...

∆=

[

[ 

#» q → #» q0



#» q 0 ∈res t q ∈arg t #»

;t

res t

23/28

Synchronization : Auxiliary functions For each ;t

... ...

...

1 × 2 × 3 4 arg t

;t ;t ;t

5 × 6 × 7

arg t : state vector set res t : state vector set

... ... ...

∆=

[ [ t∈[S]

[ 

#» q → #» q0



#» q 0 ∈res t q ∈arg t #»

;t

res t

23/28

Synchronization : Auxiliary functions For each ;t

... ...

...

1 × 2 × 3 4 arg t

;t ;t ;t

5 × 6 × 7

arg t : state vector set res t : state vector set

... ... ...

∆=

[ [ t∈[S]

[ 

#» q → #» q0



#» q 0 ∈res t q ∈arg t #»

;t

res t

∆ = { h1, 2, 3i → h5, 6, 7i , h1, 2, 4i → h5, 6, 7i , ... }

23/28

Synchronization : Auxiliary functions Input vectors of ∆ src t (δdsync ) =

n o  q | (q, ;t ) → q 0 ∈ δdsync

p−1 0 arg t ({δ i }i∈[p] ) = src t (δdsync ) × · · · × src t (δdsync )

Output vectors of ∆ dst t (δdsync ) =

n o  q 0 | (q, ;t ) → q 0 ∈ δdsync

p−1 0 res t ({δ i }i∈[p] ) = dst t (δdsync ) × · · · × dst t (δdsync )

24/28

Synchronization

(Σ ∪ {;t }) nfa

p

→ (Σ, p) bspa

i Syn( ({Q i }i∈[p] , Σdsync , {δdsync }i∈[p] , {I i }i∈[p] , {F i }i∈[p] ))

= ({Q i }i∈[p] , Σ, {δ i }i∈[p] , {I i }i∈[p] , {F i }i∈[p] , ∆) where ∆=

[  [ t∈[S]

#» q ∈arg t

i δ i = δdsync \

[

[ 

#» q → #» q0



#» q 0 ∈res t

 i (q, ;t ) → q 0 ∈ δdsync

t∈[S]

Σ = Σdsync \

S

;t

t∈[S] 25/28

Example

BSPRE (a+b)a, h ab i0



(+b)b, ab, h ba i1 +h a i2



26/28

Example

BSPRE (a+b)a, h ab i0



(+b)b, ab, h ba i1 +h a i2



Desynchronization



h

(a+b) a ;0 (+b) b ;1)+(a b ;2) ,



a b ;0 (b a ;1)+(a ;2)

i

26/28

Example BSPRE

h

(a+b)a, i0 ab



h

(+b)b, ab, i1 +h a i2 ba



Desynchronization



h

(a+b) a ;0 (+b) b ;1)+(a b ;2) ,



a b ;0 (b a ;1)+(a ;2)

i

BK a b 0

2

a

a a

3

;0

4

b

a

1'

5

b

b

2'

;0

3'

a b

7' 4'

9

;2

10

6

;1

7

;1

6'

b

b

1

0'

8

;2 a

8' 5'

26/28

Example Desynchronized automata 8

a 2

b 0

a

a a

3

;0

4

b

5

a

1'

b

2'

;0

3'

a b

7' 4'

9

;2

10

6

;1

7

;1

6'

b

b

1

0'

b

;2 a

8' 5'

Synchronization b b 0

2

a 1

0'

a

1'

5

b

b

6

a a b

4

3 Δ 2'

3'

a b

8 4' a

b a

7 Δ 6'

9 5' 7'

Δ

10 8'

27/28

Conclusion

What is done • Software for RE and Automata transformation • BSPRE → BSPA

What is being done • Determinize and minimize BSPA • Automatize RE → BSPRE • Implement BSPA recognition

28/28