implementation of orc
play

Implementation of Orc William Cook and Jayadev Misra f cook,misra g - PowerPoint PPT Presentation

D EPARTMENT OF C OMPUTER S CIENCES Implementation of Orc William Cook and Jayadev Misra f cook,misra g @cs.utexas.edu Department of Computer Science University of Texas at Austin Email: web: http://www.cs.utexas.edu/users/psp U NIVERSITY OF T


  1. D EPARTMENT OF C OMPUTER S CIENCES Implementation of Orc William Cook and Jayadev Misra f cook,misra g @cs.utexas.edu Department of Computer Science University of Texas at Austin Email: web: http://www.cs.utexas.edu/users/psp U NIVERSITY OF T EXAS AT A USTIN 0

  2. D EPARTMENT OF C OMPUTER S CIENCES Status of Implementation � Implementation coded in Java. � An Orc program can call Java programs as sites. � A Java program can call an Orc program. Another implementation by Galen Menzel using Concurrent Haskell. U NIVERSITY OF T EXAS AT A USTIN 1

  3. D EPARTMENT OF C OMPUTER S CIENCES Java Calling Orc z : 2 E ( L ) Include in the main (Java) program z is a variable of the main program, E an Orc expression, L a list of actual parameters, where z the first value published by E and terminate. constants and variables of the main program. The effect is: assign to U NIVERSITY OF T EXAS AT A USTIN 2

  4. D EPARTMENT OF C OMPUTER S CIENCES l 0 f , ! f l 0 Implementation Using the Semantic Rules f j g , ! f j g y 0 f , ! f � 0 (S YM 1) f > x > g , ! ( f > x > g ) j [ =x ℄ g (S EQ 1V) [[ E ( q ) � f ℄℄ 2 D � E ( p ) , ! [ p=q ℄ f The expression structure has to change. (D EF ) Each expression has to be instantiated whenever it is called. U NIVERSITY OF T EXAS AT A USTIN 3

  5. D EPARTMENT OF C OMPUTER S CIENCES A simpler strategy � Compile a fixed structure for each expression. � Runtime Dag Traversal: Place tokens at dag nodes. – Compile each expression to a directed acyclic graph (dag). – Each node of the dag has an instruction. � make site/expression call In each step, � create new tokens � publish a value – Pick an appropriate token. – Execute the corresponding instruction, which may U NIVERSITY OF T EXAS AT A USTIN 4

  6. D EPARTMENT OF C OMPUTER S CIENCES � For each defined expression and the goal expression build a dag. Compiler � Each dag has a root and a sink node. � Each node has an instruction: 0 0 � r etur n M ( L ) E ( L ) for expression assig n ( x ) x for silent transition w her e ( x ) to publish a value hok e site call expression call assign to variable for starting a where expression for ending a where expression U NIVERSITY OF T EXAS AT A USTIN 5

  7. D EPARTMENT OF C OMPUTER S CIENCES Recursive Construction of Dag f | g 0 M E τ 0 M E f g τ τ τ τ f>x>g f where x : ε g f>>g where(x) f f f g assign(x) g choke g τ U NIVERSITY OF T EXAS AT A USTIN 6

  8. D EPARTMENT OF C OMPUTER S CIENCES Notes on Dag construction � There is a unique root and sink for each dag. � The instruction at each sink is � . U NIVERSITY OF T EXAS AT A USTIN 7

  9. D EPARTMENT OF C OMPUTER S CIENCES � to: Dag Finalization hok e , if this is the goal dag (i.e., for expression in the main program) r etur n , for all other dags. Change the instruction at each sink, from � instruction, i.e., � -node has a successor. Hence, a sink does not have a Every U NIVERSITY OF T EXAS AT A USTIN 8

  10. D EPARTMENT OF C OMPUTER S CIENCES Construction of Example Dag where(x) S τ M N(x) τ τ τ 0 τ τ choke τ assign(y) ( M j N ( x ) where x : 2 S � 0) > y > G ( y ) G(y) τ choke Figure 1: U NIVERSITY OF T EXAS AT A USTIN 9

  11. � -node Elimination) D EPARTMENT OF C OMPUTER S CIENCES � -node: Dag Optimization ( Eliminate any non-root A B A B τ C D � A where node has a left and a right successor. C D � A site/expression call node has exactly one successor. Restriction U NIVERSITY OF T EXAS AT A USTIN 10

  12. D EPARTMENT OF C OMPUTER S CIENCES Reconstruction of Example Dag where(x) S τ M N(x) 0 choke assign(y) ( M j N ( x ) where x : 2 S � 0) > y > G ( y ) G(y) choke Figure 2: U NIVERSITY OF T EXAS AT A USTIN 11

  13. ( M j N ) > x > ( R j S ( x )) D EPARTMENT OF C OMPUTER S CIENCES Dag Traversal: τ N M assign(x) S(x) R choke U NIVERSITY OF T EXAS AT A USTIN 12

  14. D EPARTMENT OF C OMPUTER S CIENCES : ready token : suspended token τ τ τ N N N M M M assign(x) assign(x) assign(x) S(x) R S(x) R S(x) R choke choke choke (2) (3) (1) τ τ τ N N N M M M assign(x) assign(x) assign(x) R S(x) R S(x) R S(x) x x choke x x choke choke x x (6) (4) (5) U NIVERSITY OF T EXAS AT A USTIN 13

  15. D EPARTMENT OF C OMPUTER S CIENCES Fields of a token � position: the node in the dag. � context: values of variables (such as x in the example) � val: token’s value, which may be returned to the caller. � state: ready, pending, or suspended. U NIVERSITY OF T EXAS AT A USTIN 14

  16. D EPARTMENT OF C OMPUTER S CIENCES z := E ( p; 3) in the Main program and goal dag E ( x; y ) Initialization � Create token t where t: ontext = f ( x; p ’s value ) ; ( y ; 3) g . Given � t:v al = ? . � t:state = r eady . � Put t on the root node of the goal dag. U NIVERSITY OF T EXAS AT A USTIN 15

  17. t ’s instruction � 0 : skip. D EPARTMENT OF C OMPUTER S CIENCES � � : put copies of t at all successor nodes. Process token � Site call M ( x ) : M with parameter value x from t: ontext . t at the successor node. � assig n ( x ) : ( x; t:v al ) to t: ontext . – call t at all successor nodes. – put suspended copy of � hok e : t:v al to the caller. (This will be generalized.) – add – put copies of t after processing. – return – Terminate this computation. Delete U NIVERSITY OF T EXAS AT A USTIN 16

  18. D EPARTMENT OF C OMPUTER S CIENCES Processing expression call: caller’s dag E(p) E(p) E(p) t v v’ v M M M � For ready token t at E ( p ) : v , a pending copy of t , at M . Initially Expression Call E(p) On receiving value t . � On receiving value from E : 0 of v v to get the value. – put v remains pending, to receive more values. – Delete – create ready copy – U NIVERSITY OF T EXAS AT A USTIN 17

  19. E ( x ) : callee’s dag D EPARTMENT OF C OMPUTER S CIENCES Processing expression call � when token t at caller dag calls E ( p ) : put token u at E ’s root. u is ready . u: ontext has ( x; p ’s value from t: ontext ) . u: al l er := v al l er is a field of a token. � To process token t at the sink of the dag, with instruction r etur n : – – v := t: al l er ; – — v :v al := t:v al ; v :state := r eady t – – – delete U NIVERSITY OF T EXAS AT A USTIN 18

  20. Metr onome D EPARTMENT OF C OMPUTER S CIENCES Example: τ Signal Rtimer(1) Metronome Metr onome � S ig nal j R timer (1) � Metr onome return Figure 3: U NIVERSITY OF T EXAS AT A USTIN 19

  21. D EPARTMENT OF C OMPUTER S CIENCES τ τ τ τ 0 Signal Rtimer(1) 0’ Signal 0’’ Rtimer(1) Signal Rtimer(1) Signal Rtimer(1) Metronome Metronome 0’’ Metronome 0’’ Metronome return return 0’ return return 0’ responds to Main τ τ 1 τ τ Signal Rtimer(1) Signal Rtimer(1) Signal Rtimer(1) Signal Rtimer(1) 0’’ Metronome Metronome 1’’ Metronome 1’’ Metronome return return 0’’ 1’ return 0’’ return 0’’0’’ 0’’ receives from Rtimer 1’ returns to 0’’ i’ : on the left, always ready : on the right, ready :on the right, suspended i’’ i’’ U NIVERSITY OF T EXAS AT A USTIN 20

  22. D EPARTMENT OF C OMPUTER S CIENCES 0 and 00 return signals to Main. Token structure in Metronome � 0 0 0 and 00 , 00 . � i i i > 0 , return signals to ( i � 1) 00 is permanently pending; copy 00 created when it receives a signal. � i i U NIVERSITY OF T EXAS AT A USTIN 21

  23. D EPARTMENT OF C OMPUTER S CIENCES Summary (so far) � Compile dag for each expression. � A token has: position, context, val, caller, state. � Put a ready token with parameter values as context at the root of goal � Process any ready token, with instruction: 0 , � , Site/Expr call, assig n ( x ) , r etur n , hok e dag. U NIVERSITY OF T EXAS AT A USTIN 22

  24. D EPARTMENT OF C OMPUTER S CIENCES where expression where(x) f g f where x : 2 g choke τ � Compute f as far as possible. Call to M ( x ) may wait. � Compute g : At hok e Figure 4: x . g – assign value to – terminate U NIVERSITY OF T EXAS AT A USTIN 23

  25. t at w her e ( x ) D EPARTMENT OF C OMPUTER S CIENCES For ready token where(x) u v f g choke � Create ready tokens u and v at left and right successors. τ � Create cell where the value of x will be stored. :v al := ? � Add ( x; ) to u: ontext . U NIVERSITY OF T EXAS AT A USTIN 24

  26. D EPARTMENT OF C OMPUTER S CIENCES Site/Expr call in the left subgraph � For ready token t at site call M ( x ) where ( x; ) is in t: ontext : :v al 6 = ? then call M ( :v al ) ; put copy u of t at successor. r ; u:v al := r ; u:state := r eady u:state := suspended if :v al = ? then t is pending waiting for . – immediate site: receive response � For token t at expr call E ( x ) : proceed as before – deferred site: if t . delete U NIVERSITY OF T EXAS AT A USTIN 25

  27. t at w her e ( x ) , contd. D EPARTMENT OF C OMPUTER S CIENCES For token where(x) u v f g is created at w her e ( x ) : choke τ � All tokens in g are killed at hok e . � Identify all such tokens by cell ; kill all tokens of of cell . Given that cell � v : el l := el l is a new field of a token. — U NIVERSITY OF T EXAS AT A USTIN 26

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend