Esterel de A Z 5 Boucles et rincarnation
Esterel de A à Z 5. Boucles et réincarnation en Esterel Gérard Berry Collège de France Chaire Algorithmes, machines et langages Cours du 14 mars 2018 Suivi du séminaire de Reinhard von Hanxleden gerard. berry@college-de-france. fr http: //www-sop. inria. fr/members/Gerard. Berry
Agenda 1. Pourquoi une étude spéciale des boucles G. Berry, Collège de France 21/03/2018 2
Pourquoi une étude spéciale des boucles • Les boucles ne posent pas de problème sémantique • Interprète Esterel trivial : implémenter les règles G. Berry, Collège de France 21/03/2018 3
Pourquoi une étude spéciale des boucles • Mais la traduction en circuits du cours 4 ne marche pas car pas d’allocation dynamique de portes et fils • Aussi nécessaire pour les implémentations en logiciel rapide (S. Edwards, D. Potop, M. Perreaut), cf. cours 6 But de ce cours : traiter la schizophrénie des signaux et parallèles par la réincarnation G. Berry, Collège de France 21/03/2018 4
Agenda 1. Pourquoi une étude spéciale des boucles 2. Un programme schizophrène G. Berry, Collège de France 21/03/2018 5
Exemple de programme schizophrène Un programme banal : output O ; loop signal S in if S then emit O end ; pause ; emit S end signal end loop G. Berry, Collège de France 21/03/2018 6
Instant 1 Un programme banal : output O ; loop signal S in if S then emit O end ; pause ; emit S end signal end loop Arrêt sur pause, S absent, O non émis, G. Berry, Collège de France 21/03/2018 7
Instant 2 a Un programme banal : output O ; loop signal S in if S then emit O end ; pause ; emit S end signal end loop S S, O inconnus, pause termine, la séquence démarre G. Berry, Collège de France 21/03/2018 8
Instant 2 b Un programme banal : output O ; loop signal S in if S then emit O end ; pause ; emit S end signal end loop S S emit S est exécuté, S est marqué présent G. Berry, Collège de France 21/03/2018 9
Instant 2 c Un programme banal : output O ; S n’a plus d’existence loop signal S in if S then emit O end ; pause ; emit S end signal end loop S S S L’instruction signal se termine, on sort de sa portée G. Berry, Collège de France 21/03/2018 10
Instant 2 d Un programme banal : output O ; loop signal S in if S then emit O end ; pause ; emit S end signal end loop S S S La boucle se termine G. Berry, Collège de France 21/03/2018 11
Instant 2 e Un programme banal : output O ; loop signal S in if S then emit O end ; pause ; emit S end signal end loop S S S La boucle redémarre G. Berry, Collège de France 21/03/2018 12
Instant 2 f Un programme banal : output O ; loop signal S in if S then emit O end ; pause ; emit S end signal end loop S S S est redéclaré et remarqué inconnu (S) G. Berry, Collège de France 21/03/2018 13
Instant 2 g Un programme banal : output O ; loop signal S in if S then emit O end ; pause ; emit S end signal end loop S S S N’ayant pas d’émetteurs accessibles, S est absent G. Berry, Collège de France 21/03/2018 14
Instant 2 h Un programme banal : output O ; loop signal S in if S then emit O end ; pause ; emit S end signal end loop S S S Le test se termine sans émettre O, qui est donc absent G. Berry, Collège de France 21/03/2018 15
Instant 2 i Un programme banal : output O ; loop signal S in if S then emit O end ; pause ; emit S end signal end loop S S S Le pause s’allume, fin de l’instant G. Berry, Collège de France 21/03/2018 16
S est schizophène ! Un programme banal : output O ; loop signal S in if S then emit O end ; pause ; emit S end signal end loop S S S est simultanément présent et absent ! G. Berry, Collège de France 21/03/2018 17
Oubli du cours 4 : boot d’un circuit E 0 E' GO RES SUSP 0 0 KILL E E' GO SEL RES K 0 SUSP KILL p K 1 K 2 K 3. . . SEL K 0 K 1 K 2 K 3. . . GO = 1→ 0 RES = 0→ 1 SUSP = 0 KILL = 0 G. Berry, Collège de France 21/03/2018 18
Circuit trop simple du programme précédent S RES 0 GO res loop if O REG ≈ 0 0 S O S 0 S 1 O O = S = 0→ 1 S 0 = 0→ 1 O=S=0 G. Berry, Collège de France 21/03/2018 19
Les parallèles aussi sont schizophrènes loop { pause || pause } ; emit O end loop programme source instant 1 loop { pause || pause } ; emit O end loop instant 2 a synchro → 0 (terminaison) instant 2 b synchro → 1 (pause) G. Berry, Collège de France 21/03/2018 20
Agenda 1. Pourquoi une étude spéciale des boucles 2. Un programme schizophrène 3. Un programme doublement schizophrène G. Berry, Collège de France 21/03/2018 21
Exemple de double schizophrénie output O loop signal S 1 in trap T in loop signal S 2 in if S 1 then emit S 2 end ; pause ; end signal end loop || pause ; emit S 1 ; exit T end trap end signal end loop G. Berry, Collège de France 21/03/2018 22
Instant 1 a : S 1, S 2 alloués mais inconnus output O; loop signal S 1 in trap T in loop signal S 2 in if S 1 then emit S 2 end ; ? pause ; end signal end loop || pause ; emit S 1 ; exit T end trap end signal end loop S 1 S 2 G. Berry, Collège de France 21/03/2018 23
Instant 1 b : S 1, S 2 absents car non émissibles output O; loop signal S 1 in trap T in loop signal S 2 in if S 1 then emit S 2 end ; pause ; end signal end loop || pause ; emit S 1 ; exit T end trap end signal end loop S 1 S 2 G. Berry, Collège de France 21/03/2018 24
Instant 1 c : fin de la réaction output O; loop signal S 1 in trap T in loop signal S 2 in if S 1 then emit S 2 end ; pause ; end signal end loop || pause ; emit S 1 ; exit T end trap end signal end loop S 1 S 2 G. Berry, Collège de France 21/03/2018 25
Instant 2 a : reprise, S 1 et S 2 inconnus output O; loop signal S 1 in trap T in loop signal S 2 in if S 1 then emit S 2 end ; pause ; end signal end loop || pause ; emit S 1 ; exit T end trap end signal end loop S 1 S 2 G. Berry, Collège de France 21/03/2018 26
Instant 2 b : S 1 présent car émis output O; loop signal S 1 in trap T in loop signal S 2 in if S 1 then emit S 2 end ; pause ; end signal end loop || pause ; emit S 1 ; exit T end trap end signal end loop S 1 S 2 G. Berry, Collège de France 21/03/2018 27
Instant 2 c : S 2 absent, car non émissible output O; S 1 S 2 loop S 1 S 2 signal S 1 in trap T in S 1 S 2 loop signal S 2 in if S 1 then emit S 2 end ; pause ; pas d’émetteur accessible end signal d’ici jusqu’au end signal end loop qui signe la fin de vie de ce S 2 || pause ; emit S 1 ; exit T end trap end signal end loop G. Berry, Collège de France 21/03/2018 28
Instant 2 d : S 2 plus visible output O; loop signal S 1 in trap T in loop signal S 2 in if S 1 then emit S 2 end ; pause ; end signal end loop || pause ; emit S 1 ; exit T end trap end signal end loop S 1 S 2 G. Berry, Collège de France 21/03/2018 29
Instant 2 e : rebouclage et réallocation de S 2 output O; loop signal S 1 in trap T in loop signal S 2 in if S 1 then emit S 2 end ; pause ; end signal end loop || pause ; emit S 1 ; exit T end trap end signal end loop S 1 S 2 S 1 S 2 G. Berry, Collège de France 21/03/2018 30
Instant 2 f : S 2 présent car émis output O; loop signal S 1 in trap T in loop signal S 2 in if S 1 then emit S 2 end ; pause ; end signal end loop || pause ; emit S 1 ; exit T end trap end signal end loop S 1 S 2 S 1 S 2 G. Berry, Collège de France 21/03/2018 31
Instant 2 g : pause output O; loop signal S 1 in trap T in loop signal S 2 in if S 1 then emit S 2 end ; pause ; end signal end loop || pause ; emit S 1 ; exit T end trap end signal end loop S 1 S 2 S 1 S 2 G. Berry, Collège de France 21/03/2018 32
Instant 2 h : sortie de trappe, S 2 plus visible output O; loop signal S 1 in trap T in loop signal S 2 in if S 1 then emit S 2 end ; pause ; end signal end loop || pause ; emit S 1 ; exit T end trap end signal end loop S 1 S 2 S 1 S 2 G. Berry, Collège de France 21/03/2018 33
Instant 2 i : S 1 plus visible output O; loop signal S 1 in trap T in loop signal S 2 in if S 1 then emit S 2 end ; pause ; end signal end loop || pause ; emit S 1 ; exit T end trap end signal end loop S 1 S 2 S 1 S 2 G. Berry, Collège de France 21/03/2018 34
Instant 2 j : rebouclage, S 1 inconnu output O; loop signal S 1 in trap T in loop signal S 2 in if S 1 then emit S 2 end ; pause ; end signal end loop || pause ; emit S 1 ; exit T end trap end signal end loop S 1 S 2 S 1 S 2 S 1 S 2 G. Berry, Collège de France 21/03/2018 35
Instant 2 k : S 1 absent car non émissible output O; loop signal S 1 in trap T in loop signal S 2 in if S 1 then emit S 2 end ; pause ; end signal end loop || pause ; emit S 1 ; exit T end trap end signal end loop S 1 S 2 S 1 S 2 S 1 S 2 G. Berry, Collège de France 21/03/2018 36
Instant 2 l : S 2 inconnu output O; loop signal S 1 in trap T in loop signal S 2 in if S 1 then emit S 2 end ; pause ; end signal end loop || pause ; emit S 1 ; exit T end trap end signal end loop S 1 S 2 S 1 S 2 S 1 S 2 G. Berry, Collège de France 21/03/2018 37
Instant 2 m : S 2 absent car non émissible output O; loop signal S 1 in trap T in loop signal S 2 in if S 1 then emit S 2 end ; pause ; end signal end loop || pause ; emit S 1 ; exit T end trap end signal end loop S 1 S 2 S 1 S 2 S 1 S 2 G. Berry, Collège de France 21/03/2018 38
Instant 2 o: c’est fini ! output O; loop signal S 1 in trap T in loop signal S 2 in if S 1 then emit S 2 end ; pause ; end signal end loop || pause ; emit S 1 ; exit T Deux S 1, trois S 2 end trap trois combinaisons, end signal end loop S 2 doublement schizo ! S 1 S 2 S 1 S 2 S 1 S 2 G. Berry, Collège de France 21/03/2018 39
D’accord, c’est du boulot, mais du boulot d’ordinateur ! La bonne nouvelle : tout cela reste parfaitement sain, car les réallocations se suivent strictement sans jamais interférer entre elles ! G. Berry, Collège de France 21/03/2018 40
Agenda 1. 2. 3. 4. Pourquoi une étude spéciale des boucles Un programme schizophrène Un programme doublement schizophrène Traiter la schizophrénie par duplication du corps G. Berry, Collège de France 21/03/2018 41
Traiter la schizophrénie par duplication du corps loop p end ≈ loop p ; p end loop signal S in if S then emit O end pause ; emit S end signal ; end loop ≈ loop signal S in if S then emit O end pause ; emit S end signal ; signal S in if S then emit O end pause ; emit S end signal end loop G. Berry, Collège de France 21/03/2018 42
Instant 1 : S 0, O absents car non émissible loop p end ≈ loop p ; p end loop signal S 0 in if S 0 then emit O end pause ; emit S 0 end signal ; signal S 1 in if S 1 then emit O end pause ; emit S 1 end signal end loop G. Berry, Collège de France 21/03/2018 43
Instant 2 a : S 0 présent car émis loop p end ≈ loop p ; p end loop signal S 0 in if S 0 then emit O end pause ; emit S 0 end signal ; signal S 1 in if S 1 then emit O end pause ; emit S 1 end signal end loop G. Berry, Collège de France 21/03/2018 44
Instant 2 a : S 0 présent car émis loop p end ≈ loop p ; p end loop signal S 0 in if S 0 then emit O end pause ; emit S 0 end signal ; signal S 1 in if S 1 then emit O end pause ; emit S 1 end signal end loop G. Berry, Collège de France 21/03/2018 45
Instant 2 b : S 0 plus visible, S 1 inconnu loop p end ≈ loop p ; p end loop signal S 0 in if S 0 then emit O end pause ; emit S 0 end signal ; signal S 1 in if S 1 then emit O end pause ; emit S 1 end signal end loop G. Berry, Collège de France 21/03/2018 46
Instant 2 b : S 1, O absents, fin de l’instant loop p end ≈ loop p ; p end loop signal S 0 in if S 0 then emit O end pause ; emit S 0 end signal ; signal S 1 in if S 1 then emit O end pause ; emit S 1 end signal end loop G. Berry, Collège de France 21/03/2018 47
Instant 3 a : S 1 présent car émis loop p end ≈ loop p ; p end loop signal S 0 in if S 0 then emit O end pause ; emit S 0 end signal ; signal S 1 in if S 1 then emit O end pause ; emit S 1 end signal end loop G. Berry, Collège de France 21/03/2018 48
Instant 3 a : S 1 présent car émis loop p end ≈ loop p ; p end loop signal S 0 in if S 0 then emit O end pause ; emit S 0 end signal ; signal S 1 in if S 1 then emit O end pause ; emit S 1 end signal end loop G. Berry, Collège de France 21/03/2018 49
Instant 3 b : S 1 invisible, boucle, S 0 inconnu loop p end ≈ loop p ; p end loop signal S 0 in if S 0 then emit O end pause ; emit S 1 end signal ; signal S 1 in if S 1 then emit O end pause ; emit S 1 end signal end loop G. Berry, Collège de France 21/03/2018 50
Instant 3 b : S 0, O absents, fin de l’instant loop p end ≈ loop p ; p end loop signal S 0 in if S 0 then emit O end pause ; emit S 0 end signal ; signal S 1 in if S 1 then emit O end pause ; emit S 1 end signal end loop G. Berry, Collège de France 21/03/2018 51
Résout le problème, en théorie • Solution simple, qui marche aussi pour le parallèle Mais ne fonctionne pas en pratique : imbrication de boucles, signaux et parallèles �explosion exponentielle du code ! G. Berry, Collège de France 21/03/2018 52
Mais danger : explosion exponentielle ! loop signal S 1 in loop signal S 2 in loop signal S 3 in. . . end signal end loop signal S 1 in loop signal S 2 in loop signal S 3 in. . . end signal ; end loop end signal end loop G. Berry, Collège de France 21/03/2018 53
Mais danger : explosion exponentielle ! loop signal S 1 in loop signal S 2 in loop signal S 3 in. . . end signal end loop signal S 1 in loop signal S 2 in loop signal S 3 in. . . end signal ; end loop end signal ; signal S 2 in loop signal S 3 in. . . end signal ; end loop end signal end loop G. Berry, Collège de France 21/03/2018 54
Mais danger : explosion exponentielle ! loop signal S 1 in loop signal S 2 in loop signal S 3 in. . . end signal end loop signal S 1 in loop signal S 2 in loop signal S 3 in. . . end signal ; end loop end signal ; signal S 2 in loop signal S 3 in. . . end signal ; end loop end signal end loop G. Berry, Collège de France 21/03/2018 55
Agenda 1. 2. 3. 4. 5. Pourquoi une étude spéciale des boucles Un programme schizophrène Un programme doublement schizophrène Traiter la schizophrénie par duplication du corps Plus efficace : réincarner la surface des boucles G. Berry, Collège de France 21/03/2018 56
Un traitement efficace Pour traiter de dédoublement de la personnalité des signaux et parallèles (schizophrénie), comprendre la théorie et la pratique de leurs réincarnations ! G. Berry, Collège de France 21/03/2018 57
Instant 2 : les deux incarnations Un programme banal : output O ; loop signal S in if S then emit O end ; pause ; emit S end signal end loop Matsya Kurma G. Berry, Collège de France 21/03/2018 58
Surface et profondeur d’une instruction output O ; loop signal S in if S then emit O end ; pause ; emit S end signal end loop surface : ce qui est accessible instantanément à partir du début de l’instruction profondeur : le reste, là où sont les pauses des pˆ G. Berry, Collège de France 21/03/2018 59
Surface instantanée, profondeur longue signal S in if S then emit O end ; emit X pause ; emit S ; pause ; emit S end signal G. Berry, Collège de France 21/03/2018 60
surface et profondeur peuvent s’interpénétrer signal S in if S then emit O else pause end ; emit X pause ; emit S ; pause ; emit S end signal Pas de souci particulier �� zone mixte : accessible soit du emit O, soit du pause G. Berry, Collège de France 21/03/2018 61
Tardieu-v 1 : supprimer la boucle output O ; signal S in if S then emit O end ; 1 : pause ; emit S end signal ; signal S in if S then emit O end ; gotopause 1; end signal ; Evite la duplication de la profondeur G. Berry, Collège de France 21/03/2018 62
Tardieu-v 1 : supprimer la boucle output O ; signal S in if S then emit O end ; 1 : pause ; emit S end signal ; signal S in if S then emit O end ; gotopause 1; end signal ; Matsya Kurma Evite la duplication de la profondeur G. Berry, Collège de France 21/03/2018 63
Tardieu-v 2 : dupliquer la surface en tête output O ; signal S in if S then emit O end ; gotopause 1; end signal ; loop signal S in if S then emit O end ; 1 : pause ; emit S end signal end loop G. Berry, Collège de France 21/03/2018 64
Tardieu-v 2 : dupliquer la surface en tête output O ; signal S in if S then emit O end ; gotopause 1; end signal ; loop signal S in if S then emit O end ; 1 : pause ; emit S end signal end loop Matsya Kurma G. Berry, Collège de France 21/03/2018 65
Répliquer la surface → expansion quadratique loop signal S 1 in loop signal S 2 in loop signal S 3 in surface profondeur end signal end loop signal S 1 in signal S 2 in signal S 3 in surface [g/p] end signal ; loop signal S 1 in signal S 2 in signal S 3 in surface [g/p] end signal ; loop signal S 2 in signal S 3 in surface [g/p] end ; loop signal S 3 in surface ; profondeur end end 1×S 1 + 2×S 2 + 3×S 3 + … + n×Sn ≈ n 2 G. Berry, Collège de France 21/03/2018 66
Tardieu : les résultats • v 1, supprimer la boucle : simple • v 2 : réincarner en tête : mieux optimisable • Les deux méthodes sont quadratiques �� • Inconvénient : modifient et allongent le code source (debug…) Thèse d’Olivier Tardieu : présentation algébrique élégante + optimisations subtiles et élégantes G. Berry, Collège de France 21/03/2018 67
Agenda 1. 2. 3. 4. 5. 6. Pourquoi une étude spéciale des boucles Un programme schizophrène Un programme doublement schizophrène Traiter la schizophrénie par duplication du corps Plus efficace : réincarner la surface des boucles Indexer les incarnations G. Berry, Collège de France 21/03/2018 68
Ne pas dupliquer le LCI (Long Code Instantané) LCI ; signal S in loop Surface [gotopause] LCI ; end signal ; signal S in loop Surface ; LCI Profondeur signal S in end signal Surface ; end loop Profondeur end signal LCI n’est pas schizophrène, end loop il ne faut pas le dupliquer ! G. Berry, Collège de France 21/03/2018 69
GB : étiqueter le source output O ; pmax loop /0 LCI 1 ; signal S in /1 0/1 if S then emit O end ; pause ; 1/1 emit S end signal ; /0 LCI 2 end loop surface = 0/1 profondeur =1/1 La schizophrénie n’est pas due à la boucle seule, mais à l’interaction loop / signal (ou loop / ||) ! G. Berry, Collège de France 21/03/2018 70
Les index d’incarnations • Paire d’entiers l/d avec l ≤ d • l : niveau d’incarnation (level) • d : niveau de profondeur (depth) • l = 0. . d− 1 : surfaces de plus en plus profondes • l = d : profondeur • push (l/d) = l/(d+1) exemples : push (1/3) = 1/4, push (3/3) = 3/4 • pop (l/d) = min(l, d− 1)/d− 1 exemples : pop (1/3) = 1/2, pop (2/3) = pop (3/3) = 2/2 • prof (l/d) = d/d G. Berry, Collège de France 21/03/2018 71
GB : étiquetage de la surface 0/0 ; output O pmax push(0/0) 0/0 loop /0 LCI 10/0 ; 0/0 signal 0/0 S 0/1 in /1 if 0/1 S 0/1 then emit 0/1 O 0/0 end 0/1 ; 0/1 pause ; emit S /0 end signal ; LCI 2 end loop Matsya G. Berry, Collège de France 21/03/2018 72
GB : étiquettes de reprise → prof(0/1) = 1/1 0/0 ; output O pmax prof (0, 1) 0/0 loop /0 LCI 10/0 ; 0/0 signal 0/0 S 0/1, 1/1 in /1 if 0/1 S 0/1 then emit 0/1 O 0/1 end 0/1 ; 0/1 pause 1/1 ; 1/1 emit S 1/1 /0 end signal 0/0 ; 0/0 LCI 20/0 end loop 0/0 pop(1, 1) Kurma Pas de duplication des LCI G. Berry, Collège de France 21/03/2018 73
GB : cacher la profondeur dans pmax Matsya O 0 ; pmax output 0 loop /0 LCI 10 ; 0 signal 0 S 0, 1 in /1 if 0 S 0 then emit 0 O 0 end 0 ; 0 0 pause 1 ; 1 emit S 1 /0 end signal 0 ; 0 LCI 20 end loop 0 Kurma Pas de duplication des LCI G. Berry, Collège de France 21/03/2018 74
Instant 1, 0/0 0; output O pmax 0 loop /0 LCI 10 ; 0 signal 0 S 0, 1 in /1 if 0 S 0 then emit 0 O 0 end ; 0 0 pause 1 ; 1 emit 1 S 1 /0 end signal 0 ; 0 LCI 20 end loop 0 S 1 G. Berry, Collège de France 21/03/2018 75
Instant 2 a, reprise avec 1/1 0; output O pmax 0 loop /0 LCI 10 ; 0 signal 0 S 0, 1 in /1 if 0 S 0 then emit 0 O 0 end ; 0 0 pause 1 ; 1 emit 1 S 1 /0 end signal 0 ; 0 LCI 20 end loop 0 S 1 présent S 0 S 1 0 S S G. Berry, Collège de France 21/03/2018 76
Instant 2 b : sortie du signal, pop(1/1)=0/0 0; output O pmax 0 loop /0 LCI 10 ; 0 signal 0 S 0, 1 in /1 if 0 S 0 then emit 0 O 0 end ; 0 0 pause 1 ; 1 emit 1 S 1 /0 end signal 0 ; 0 LCI 20 end loop 0 S 1 S 0 G. Berry, Collège de France 21/03/2018 77
Rebouclage, 0/0 0; output O pmax 0 loop /0 LCI 10 ; 0 signal 0 S 0, 1 in /1 if 0 S 0 then emit 0 O 0 end ; 0 0 pause 1 ; 1 emit 1 S 1 /0 end signal 0 ; 0 LCI 20 end loop 0 S 1 S 0 S 0 clef : S 0 ≠ S 1 G. Berry, Collège de France 21/03/2018 78
Agenda 1. 2. 3. 4. 5. 6. 7. Pourquoi une étude spéciale des boucles Un programme schizophrène Un programme doublement schizophrène Traiter la schizophrénie par duplication du corps Plus efficace : réincarner la surface des boucles Indexer les incarnations Observer la guérison du pire des cas G. Berry, Collège de France 21/03/2018 79
output S 1 and. S 2, S 1 andn. S 2, n. S 1 andn. S 2 ; loop trap T 1 in signal S 1 in pause ; emit S 1 ; exit T 1 || loop trap T 2 in signal S 2 in pause ; emit S 2 ; exit T 2 || loop if case (S 1 and S 2) do emit S 1 and. S 2 case (S 1 and not S 2) do emit S 1 andn. S 2 case (not S 1 and S 2) do emit n. S 1 and. S 2 case (not S 1 and not) S 2 do emit n. S 1 andn. S 2 end if ; pause end loop end signal end trap end loop G. Berry, Collège de France 21/03/2018 80
/0 output S 1 and. S 2, S 1 andn. S 2, n. S 1 andn. S 2 ; /1 /2 /1 /0 loop trap T 1 in signal S 1 in pause ; emit S 1 ; exit T 1 || loop trap T 2 in signal S 2 in pause ; emit S 2 ; exit T 2 || loop if case (S 1 and S 2) do emit S 1 and. S 2 case (S 1 and not S 2) do emit S 1 andn. S 2 case (not S 1 and S 2) do emit n. S 1 and. S 2 case (not S 1 and not) S 2 do emit n. S 1 andn. S 2 end if ; pause end loop end signal end trap end loop G. Berry, Collège de France 21/03/2018 81
/0 output S 1 and. S 20, S 1 andn. S 20, n. S 1 andn. S 20 ; /1 /2 /1 /0 loop trap T 10 in signal S 10, 1 in pause ; emit S 10, 1 ; exit T 10 || loop trap T 20, 1 in signal S 20, 1, 2 in pause ; emit S 20, 1, 2 ; exit T 20, 1 || loop if case (S 10, 1 and S 20, 1, 2) do emit S 1 and. S 20 case (S 10, 1 and not S 20, 1, 2) do emit S 1 andn. S 20 case (not S 10, 1 and S 20, 1, 2) do emit n. S 1 and. S 20 case (not S 10, 1 and not S 20, 1, 2) do emit n. S 1 andn. S 20 end if ; pause end loop end signal end trap end loop G. Berry, Collège de France 21/03/2018 82
/0 output S 1 and. S 20, S 1 andn. S 20, n. S 1 andn. S 20 ; /1 /2 /1 /0 loop trap T 10 in signal S 10, 1 in pause ; emit S 10, 1 ; exit T 10 || Matsya=0 loop trap T 20, 1 in signal S 20, 1, 2 in pause ; emit S 20, 1, 2 ; exit T 20, 1 || loop if case (S 10, 1 and S 20, 1, 2) do emit S 1 and. S 20 case (S 10, 1 and not S 20, 1, 2) do emit S 1 andn. S 20 case (not S 10, 1 and S 20, 1, 2) do emit n. S 1 and. S 20 Kurma=1 case (not S 10, 1 and not S 20, 1, 2) do emit n. S 1 andn. S 20 end if ; pause end loop end signal end trap end loop end signal Varâha=2 end trap end loop G. Berry, Collège de France 21/03/2018 83
/0 output S 1 and. S 20, S 1 andn. S 20, n. S 1 andn. S 20 ; /1 /2 /1 /0 loop 0 trap 0 T 10 in signal 0 S 10, 1 in 0 pause ; emit S 10, 1 ; exit T 10 instant 1 a ||0 loop 0 index 0/0, 0/1 et 0/2 0 0, 1 trap T 2 in quid du if ? signal 0 S 20, 1, 2 in 0 pause ; emit S 20, 1, 2 ; exit T 20, 1 ||0 loop 0 if 0 case (S 10, 1 and S 20, 1, 2) do emit S 1 and. S 20 case (S 10, 1 and not S 20, 1, 2) do emit S 1 andn. S 20 case (not S 10, 1 and S 20, 1, 2) do emit n. S 1 and. S 20 case (not S 10, 1 and not S 20, 1, 2) do emit n. S 1 andn. S 20 end if ; pause end loop end signal end trap end loop G. Berry, Collège de France 21/03/2018 84
/0 output S 1 and. S 20, S 1 andn. S 20, n. S 1 andn. S 20 ; /1 /2 /1 /0 loop 0 trap 0 T 10 in signal 0 S 10, 1 in 0 pause ; emit S 10, 1 ; exit T 10 instant 1 b ||0 0, S 20 absents loop 0 S 1 trap 0 T 20, 1 in 0 � n. S 1 andn. S 2 0 0, 1, 2 signal S 2 in 0 pause ; emit S 20, 1, 2 ; exit T 20, 1 fin de l’instant ||0 loop 0 if 0 case (S 10, 1 and S 20, 1, 2) do emit S 1 and. S 20 case (S 10, 1 and not S 20, 1, 2) do emit S 1 andn. S 20 case (not S 10, 1 and S 20, 1, 2) do emit n. S 1 and. S 20 case (not S 10, 1 and not S 20, 1, 2) do emit n. S 1 andn. S 20 end if 0 ; 0 0 pause end loop end signal end trap end loop G. Berry, Collège de France 21/03/2018 85
/0 output S 1 and. S 20, S 1 andn. S 20, n. S 1 andn. S 20 ; /1 /2 /1 /0 loop 0 trap 0 T 10 in signal 0 S 10, 1 in 0 pause 1 ; emit S 10, 1 ; exit T 10 instant 2 a ||0, 1 loop 0 reprise des pause 0 0, 1 trap T 2 in index 1/1 = prof (0/1) signal 0 S 20, 1, 2 in 0 pause 2 ; emit S 20, 1, 2 ; exit T 20, 1 et 2/2 = prof (0/2) ||0 loop 0 if 0 case (S 10, 1 and S 20, 1, 2) do emit S 1 and. S 20 case (S 10, 1 and not S 20, 1, 2) do emit S 1 andn. S 20 case (not S 10, 1 and S 20, 1, 2) do emit n. S 1 and. S 20 case (not S 10, 1 and not S 20, 1, 2) do emit n. S 1 andn. S 20 end if 0 ; 0 0 pause 2 end loop end signal end trap end loop G. Berry, Collège de France 21/03/2018 86
/0 output S 1 and. S 20, S 1 andn. S 20, n. S 1 andn. S 20 ; /1 /2 /1 /0 loop 0 trap 0 T 10 in signal 0 S 10, 1 in 0 pause 1 ; emit 1 S 10, 1 ; exit T 10 instant 2 b, ||0, 1 loop 0 branche 1 index 1/1 0 0, 1 trap T 2 in 1 émission de S 1 0 0, 1, 2 signal S 2 in 0 pause 2 ; emit S 20, 1, 2 ; exit T 20, 1 ||0 loop 0 if 0 case (S 10, 1 and S 20, 1, 2) do emit S 1 and. S 20 case (S 10, 1 and not S 20, 1, 2) do emit S 1 andn. S 20 case (not S 10, 1 and S 20, 1, 2) do emit n. S 1 and. S 20 case (not S 10, 1 and not S 20, 1, 2) do emit n. S 1 andn. S 20 end if 0 ; 0 0 pause 2 end loop end signal end trap end loop G. Berry, Collège de France 21/03/2018 87
/0 output S 1 and. S 20, S 1 andn. S 20, n. S 1 andn. S 20 ; /1 /2 /1 /0 loop 0 trap 0 T 10 in signal 0 S 10, 1 in 0 pause 1 ; emit 1 S 10, 1 ; exit T 10 instant 2 c, ||0, 1 loop 0 branche 2 index 2/2 0 0, 1 trap T 2 in 2 émission de S 2 0 0, 1, 2 signal S 2 in 0 pause 2 ; emit 2 S 20, 1, 2 ; exit T 20, 1 ||0 loop 0 if 0 case (S 10, 1 and S 20, 1, 2) do emit S 1 and. S 20 case (S 10, 1 and not S 20, 1, 2) do emit S 1 andn. S 20 case (not S 10, 1 and S 20, 1, 2) do emit n. S 1 and. S 20 case (not S 10, 1 and not S 20, 1, 2) do emit n. S 1 andn. S 20 end if 0 ; 0 0 pause 2 end loop end signal end trap end loop G. Berry, Collège de France 21/03/2018 88
/0 output S 1 and. S 20, S 1 andn. S 20, n. S 1 andn. S 20 ; /1 /2 /1 /0 loop 0 trap 0 T 10 in signal 0 S 10, 1 in 0 pause 1 ; emit 1 S 10, 1 ; exit T 10 instant 2 d, ||0, 1 loop 0 branche 3 index 2/2 0 0, 1 trap T 2 in rebouclage signal 0 S 20, 1, 2 in 0 pause 2 ; emit 2 S 20, 1, 2 ; exit T 20, 1 quid du if ? ||0, 2 loop 0, 2 if 0, 2 case (S 10, 1 and S 20, 1, 2) do emit S 1 and. S 20 case (S 10, 1 and not S 20, 1, 2) do emit S 1 andn. S 20 case (not S 10, 1 and S 20, 1, 2) do emit n. S 1 and. S 20 case (not S 10, 1 and not S 20, 1, 2) do emit n. S 1 andn. S 20 end if 0 ; 0 0 pause 2 end loop 2 end signal end trap end loop G. Berry, Collège de France 21/03/2018 89
/0 output S 1 and. S 20, S 1 andn. S 20, n. S 1 andn. S 20 ; /1 /2 /1 /0 loop 0 trap 0 T 10 in signal 0 S 10, 1 in 0 pause 1 ; emit 1 S 10, 1 ; exit T 10 instant 2 e, ||0, 1 if en 2/2 loop 0 1 et S 22 présents trap 0 T 20, 1 in S 1 signal 0 S 20, 1, 2 in 0 pause 2 ; emit 2 S 20, 1, 2 ; exit T 20, 1 �S 1 and. S 20 ||0, 2 et pause 0, 2 loop if 0, 2 case (S 10, 1 and S 20, 1, 2) do emit S 1 and. S 20 case (S 10, 1 and not S 20, 1, 2) do emit S 1 andn. S 20 case (not S 10, 1 and S 20, 1, 2) do emit n. S 1 and. S 20 case (not S 10, 1 and not S 20, 1, 2) do emit n. S 1 andn. S 20 end if 0, 2 ; 0, 2 pause 2 end loop 2 end signal end trap end loop G. Berry, Collège de France 21/03/2018 90
/0 output S 1 and. S 20, S 1 andn. S 20, n. S 1 andn. S 20 ; /1 /2 /1 /0 loop 0 trap 0 T 10 in signal 0 S 10, 1 in 0 pause 1 ; emit 1 S 10, 1 ; exit T 10 instant 2 f, ||0, 1 1 (pop) loop 0 sortie de T 2 trap 0 T 20, 1 in mort de son corps signal 0 S 20, 1, 2 in 0 pause 2 ; emit 2 S 20, 1, 2 ; exit 2 T 20, 1 ||0, 2 loop 0, 2 if 0, 2 case (S 10, 1 and S 20, 1, 2) do emit S 1 and. S 20 case (S 10, 1 and not S 20, 1, 2) do emit S 1 andn. S 20 case (not S 10, 1 and S 20, 1, 2) do emit n. S 1 and. S 20 case (not S 10, 1 and not S 20, 1, 2) do emit n. S 1 andn. S 20 end if 0, 2 ; 0, 2 pause 2 end loop 2 end signal end trap 1 end loop end signal end trap end loop G. Berry, Collège de France 21/03/2018 91
/0 output S 1 and. S 20, S 1 andn. S 20, n. S 1 andn. S 20 ; /1 /2 /1 /0 loop 0 trap 0 T 10 in signal 0 S 10, 1 in 0 pause 1 ; emit 1 S 10, 1 ; exit T 10 instant 2 g, ||0, 1 loop 0, 1 rebouclage 0, 1 trap T 2 in comme instant 1 b signal 0, 1 S 20, 1, 2 in 0, 1 pause 2 ; emit 2 S 20, 1, 2 ; exit 1 T 20, 1 mais avec index 1 ||0, 1, 2 loop 0, 1, 2 if 0, 1, 2 case (S 10, 1 and S 20, 1, 2) do emit S 1 and. S 20 case (S 10, 1 and not S 20, 1, 2) do emit S 1 andn. S 20 case (not S 10, 1 and S 20, 1, 2) do emit n. S 1 and. S 20 case (not S 10, 1 and not S 20, 1, 2) do emit n. S 1 andn. S 20 end if 0, 2 ; 0, 2 0, 1 pause 2 end loop end signal end trap 1 end loop 1 end signal end trap end loop G. Berry, Collège de France 21/03/2018 92
/0 output S 1 and. S 20, S 1 andn. S 20, n. S 1 andn. S 20 ; /1 /2 /1 /0 loop 0 trap 0 T 10 in signal 0 S 10, 1 in 0 pause 1 ; emit 1 S 10, 1 ; exit T 10 instant 2 h, ||0, 1 1 présent loop 0, 1 S 1 trap 0, 1 T 20, 1 in 1 absent S 2 0, 1, 2 signal S 2 in 0, 1 pause 2 ; emit 2 S 20, 1, 2 ; exit 1 T 20, 1 �S 1 andn. S 20 ||0, 1, 2 loop 0, 1, 2 if 0, 1, 2 case (S 10, 1 and S 20, 1, 2) do emit S 1 and. S 20 case (S 10, 1 and not S 20, 1, 2) do emit S 1 andn. S 20 case (not S 10, 1 and S 20, 1, 2) do emit n. S 1 and. S 20 case (not S 10, 1 and not S 20, 1, 2) do emit n. S 1 andn. S 20 end if 0, 2 ; 0, 1, 2 pause 2 end loop 0, 1, 2 end signal end trap 1 end loop 1 end signal end trap end loop G. Berry, Collège de France 21/03/2018 93
/0 output S 1 and. S 20, S 1 andn. S 20, n. S 1 andn. S 20 ; /1 /2 /1 /0 loop 0 trap 0 T 10 in signal 0 S 10, 1 in 0 pause 1 ; emit 1 S 10, 1 ; exit 1 T 10 instant 2 i, ||0, 1 0 (pop (1/1)) loop 0, 1 sortie de T 1 trap 0, 1 T 20, 1 in mort de son corps signal 0, 1 S 20, 1, 2 in 0, 1 pause 2 ; emit 2 S 20, 1, 2 ; exit 1 T 20, 1 sortie de signal S 1 et S 2 ||0, 1, 2 loop 0, 1, 2 if 0, 1, 2 case (S 10, 1 and S 20, 1, 2) do emit S 1 and. S 20 case (S 10, 1 and not S 20, 1, 2) do emit S 1 andn. S 20 case (not S 10, 1 and S 20, 1, 2) do emit n. S 1 and. S 20 case (not S 10, 1 and not S 20, 1, 2) do emit n. S 1 andn. S 20 end if 0, 2 ; 0, 1, 2 pause 2 end loop 0, 1, 2 end signal end trap 1 end loop 1 end signal end trap 0 end loop G. Berry, Collège de France 21/03/2018 94
/0 output S 1 and. S 20, S 1 andn. S 20, n. S 1 andn. S 20 ; /1 /2 /1 /0 loop 0 trap 0 T 10 in signal 0 S 10, 1 in 0 pause 1 ; emit 1 S 10, 1 ; exit 1 T 10 instant 2 j, ||0, 1 loop 0, 1 rebouclage global, 0, 1 trap T 2 in idem premier instant signal 0, 1 S 20, 1, 2 in 0, 1 pause 2 ; emit 2 S 20, 1, 2 ; exit 1 T 20, 1 S 10 et S 20 absents ||0, 1, 2 0 � n. S 1 andn. S 2 0, 1, 2 loop if 0, 1, 2 case (S 10, 1 and S 20, 1, 2) do emit S 1 and. S 20 case (S 10, 1 and not S 20, 1, 2) do emit S 1 andn. S 20 case (not S 10, 1 and S 20, 1, 2) do emit n. S 1 and. S 20 case (not S 10, 1 and not S 20, 1, 2) do emit n. S 1 andn. S 20 end if 0, 2 ; 0, 1, 2 pause 2 end loop 0, 1, 2 end signal end trap 1 end loop 1 end signal end trap 0 end loop 0 G. Berry, Collège de France 21/03/2018 95
/0 output S 1 and. S 20, S 1 andn. S 20, n. S 1 andn. S 20 ; /1 /2 /1 /0 loop 0 trap 0 T 10 in signal 0 S 10, 1 in 0 pause 1 ; emit 1 S 10, 1 ; exit 1 T 10 instant 2 j, ||0, 1 loop 0, 1 rebouclage global, 0, 1 trap T 2 in idem premier instant signal 0, 1 S 20, 1, 2 in 0, 1 pause 2 ; emit 2 S 20, 1, 2 ; exit 1 T 20, 1 S 10 et S 20 absents ||0, 1, 2 0 � n. S 1 andn. S 2 0, 1, 2 loop if 0, 1, 2 case (S 10, 1 and S 20, 1, 2) do emit S 1 and. S 20 case (S 10, 1 and not S 20, 1, 2) do emit S 1 andn. S 20 case (not S 10, 1 and S 20, 1, 2) do emit n. S 1 and. S 20 case (not S 10, 1 and not S 20, 1, 2) do emit n. S 1 andn. S 20 end if 0, 2 ; 0, 1, 2 pause 2 end loop 0, 1, 2 end signal end trap 1 end loop 1 end signal end trap 0 end loop 0 G. Berry, Collège de France 21/03/2018 96
Agenda 1. 2. 3. 4. 5. 6. 7. 8. 9. Pourquoi une étude spéciale des boucles Un programme schizophrène Un programme doublement schizophrène Traiter la schizophrénie par duplication du corps Plus efficace : réincarner la surface des boucles Indexer les incarnations Observer la guérison du pire des cas Optimisations Tardieu fait il aussi bien en plus algébrique ? G. Berry, Collège de France 21/03/2018 97
Agenda 1. 2. 3. 4. 5. 6. 7. 8. Pourquoi une étude spéciale des boucles Un programme schizophrène Un programme doublement schizophrène Traiter la schizophrénie par duplication du corps Plus efficace : réincarner la surface des boucles Indexer les incarnations Observer la guérison du pire des cas Optimisations G. Berry, Collège de France 21/03/2018 98
Eviter les duplications inutiles loop traiter un paquet de boucles comme loop une seule boucle (deux ne peuvent pas boucler … au même instant, sinon boucle instantanée) loop LCI ; signal S 1 in signal S 2 in … end signal … Schizophénie si et seulement end signal si il existe un chemin direct || (ou signal) de la sortie du || (ou signal) signal S 3 in supérieur vers sa propre entrée … end signal end loop G. Berry, Collège de France 21/03/2018 99
Eviter les duplications inutiles Résultat : la duplication est quasi-linéraire en pratique (indispensable pour les vrais programmes) G. Berry, Collège de France 21/03/2018 100
L’optimisation algébrique de Tardieu G. Berry, Collège de France 21/03/2018 101
Conjecture Les traitements de la schizophrénie par GB et Tardieu donnent les mêmes duplications => introduire les index d’incarnation dans dup 4 ! G. Berry, Collège de France 21/03/2018 102
Agenda 1. 2. 3. 4. 5. 6. 7. 8. 9. Pourquoi une étude spéciale des boucles Un programme schizophrène Un programme doublement schizophrène Traiter la schizophrénie par duplication du corps Plus efficace : réincarner la surface des boucles Indexer les incarnations Observer la guérison du pire des cas Optimisations La réincarnation dans les circuits G. Berry, Collège de France 21/03/2018 103
Travailler avec des faisceaux de fils ! E[. . ] GO[0. . d] RES SUSP KILL [0. . d] E’[. . ] E E' GO SEL RES K 0 SUSP K 1 KILL p K 2 K 3. . . dans p SEL K 0[0. . d] K 1[0. . d] K 2[0. . d] K 3[0. . d]. . . non schizophrène : [0. . d] schizophrène : [0. . d+1] Transformer les portes en vecteurs de portes G. Berry, Collège de France 21/03/2018 104
Cablâge de faisceaux dans le cas p schizo push Pour X dans GO, KILL, S X[d. . d] → Xp[d. . d+1] : X[i] → Xp[i] pour tout i ≤ d Xp[d+1] non câblé Pour Y dans les Ki pop Y[0. . d+1] → Yp[0. . d] : Y[i] → Yp[i] pour tout i ≤ d Y[d+1] → Yp[d] G. Berry, Collège de France 21/03/2018 105
Câblage final de pause push Pour X dans GO, KILL, S X[d. . d] → Xp[d. . d+1] : X[i] → Xp[i] pour tout i ≤ d Xp[d+1] non câblé Pour Y dans les Ki pop Y[0. . d+1] → Yp[0. . d] : Y[i] → Yp[i] pour tout i ≤ d Y[d+1] → Yp[d] G. Berry, Collège de France 21/03/2018 106
Conclusion • Traiter la schizophrénie est indispensable pour compiler des programmes de grande taille • Les méthodes GB et Tardieu conduisent à des expansions sublinéaires, et sont peut-être identiques • Et les optimisations BDD améliorent beaucoup les circuits, voir cours 6 G. Berry, Collège de France 21/03/2018 107
- Slides: 107