1 2 3 partial permutations
play

1 2 3 Partial Permutations top-level actions can be permuted using - PowerPoint PPT Presentation

1 2 3 Partial Permutations top-level actions can be permuted using rules of for example: T 1 = k ? U ; k ! U ; T T 2 = k ! U ; k ? U ; T 1 1 T 1 = k ! U ; k ? U


  1. 1

  2. 2

  3. 3

  4. Partial Permutations top-level actions can be permuted using rules of ≪ for example: T 1 = k ′ ? � U ′ � ; k ! � U � ; T ′ T 2 = k ′ ! � U ′ � ; k ? � U � ; T ′′ 1 1 T ′ 1 = k ! � U � ; k ′ ? � U ′ � ; T ′ T 2 = k ′ ! � U ′ � ; k ? � U � ; T ′′ 1 1 unfoldn � c � m -party session Types Graph types Double buffering References – p. 11 ≪

  5. Partial Permutations top-level actions can be permuted using rules of ≪ for example: T 1 = k ′ ? � U ′ � ; k ! � U � ; T ′ T 2 = k ′ ! � U ′ � ; k ? � U � ; T ′′ 1 1 T ′ 1 = k ! � U � ; k ′ ? � U ′ � ; T ′ T 2 = k ′ ! � U ′ � ; k ? � U � ; T ′′ 1 1 unfoldn � c � m -party session Types Graph types Double buffering References – p. 11 ≪

  6. Partial Permutations top-level actions can be permuted using rules of ≪ for example: T 1 = k ′ ? � U ′ � ; k ! � U � ; T ′ T 2 = k ′ ! � U ′ � ; k ? � U � ; T ′′ 1 1 T ′ 1 = k ! � U � ; k ′ ? � U ′ � ; T ′ T 2 = k ′ ! � U ′ � ; k ? � U � ; T ′′ 1 1 unfoldn � c � m -party session Types Graph types Double buffering References – p. 11 ≪

  7. Partial Permutations top-level actions can be permuted using rules of ≪ T ′ 1 ≪ T 1 for example: T 1 = k ′ ? � U ′ � ; k ! � U � ; T ′ T 2 = k ′ ! � U ′ � ; k ? � U � ; T ′′ 1 1 T ′ 1 = k ! � U � ; k ′ ? � U ′ � ; T ′ T 2 = k ′ ! � U ′ � ; k ? � U � ; T ′′ 1 1 unfoldn � c � m -party session Types Graph types Double buffering References – p. 11 ≪

  8. Partial Permutations top-level actions can be permuted using rules of ≪ T ′ 1 ≪ T 1 for example: T 1 = k ′ ? � U ′ � ; k ! � U � ; T ′ T 2 = k ′ ! � U ′ � ; k ? � U � ; T ′′ 1 1 T ′ 1 = k ! � U � ; k ′ ? � U ′ � ; T ′ T 2 = k ′ ! � U ′ � ; k ? � U � ; T ′′ 1 1 ( OI ) k ! � U � ; k ′ ? � U ′ � ; T ≪ k ′ ? � U ′ � ; k ! � U � ; T unfoldn � c � m -party session Types Graph types Double buffering References – p. 11 ≪

  9. Partial Permutations top-level actions can be permuted using rules of ≪ T ′ 1 ≪ T 1 T ′ 2 �≪ T 2 for example: T 1 = k ′ ? � U ′ � ; k ! � U � ; T ′ T 2 = k ′ ! � U ′ � ; k ? � U � ; T ′′ 1 1 T 1 = k ′ ? � U ′ � ; k ! � U � ; T ′ T ′ 2 = k ? � U � ; k ′ ! � U ′ � ; T ′′ 1 1 No progress unfoldn � c � m -party session Types Graph types Double buffering References – p. 11 ≪

  10. 4

  11. 5

  12. Example: Double Buffering Algorithm Optimisation by overlapping computation and communication Source — Kernel — Sink Source sends data to Kernel Kernel computes on data Kernel sends to Sink Use of 2 buffers at Kernel allows Sink to write in one while Sink reads from the other. x[i] x[i−1] x[i] Source Kernel Sink x[i−1] unfoldn � c � m -party session Types Graph types Double buffering References – p. 20 ≪

  13. Example: Double Buffering Algorithm A A READY COPY READY B B READY (a) (b) A COPY B COPY (c) A A READY COPY READY B B COPY COPY (d) (e) unfoldn � c � m -party session Types Graph types Double buffering References – p. 21 ≪

  14. Types for Double Buffering Original Local Types µ t . r 1 ? �� ; s 1 ! � U � ; r 2 ? �� ; s 2 ! � U � ; t T source = µ t . r 1 ! �� ; s 1 ? � U � ; t 1 ? �� ; u 1 ! � U � ; T kernel = r 2 ! �� ; s 2 ? � U � ; t 2 ? �� ; u 2 ! � U � ; t µ t . t 1 ! �� ; u 1 ? � U � ; t 2 ! �� ; u 2 ? � U � ; t T sink = Optimized Kernel Type r 1 ! �� ; r 2 ! �� ; µ t . s 1 ? � U � ; t 1 ? �� ; u 1 ! � U � ; r 1 ! �� ; T opt = s 2 ? � U � ; t 2 ? �� ; u 2 ! � U � ; r 2 ! �� ; t Theorem T opt � c T kernel unfoldn � c � m -party session Types Graph types Double buffering References – p. 22 ≪

  15. Session C programming: Overview Global Protocol ( G ) Scribble ◮ Top down approach Protocol Projection ◮ Based on multiparty session Endpoint types (MPST) [Honda et al., T Alice T Bob T Carol Scribble Protocol POPL’08] < < Refinement < Refined ◮ Communication should T ′ T ′ T ′ Endpoint Alice Bob Carol Protocol have a dual Conformance ◮ Communication safety and Session C P Alice P Bob P Carol deadlock freedom by typing Program Nicholas Ng, Nobuko Yoshida and Kohei Honda Multiparty Session C: Safe Parallel Programming with Message Optimisation

  16. Session C programming: Key reasoning 1. Design protocol in global view Global Protocol ( G ) Scribble 2. Automatic projection to Protocol Projection endpoint protocol, algorithm Endpoint T Alice T Bob T Carol Scribble preserves safety Protocol < < Refinement < 3. Write program according to Refined T ′ T ′ T ′ Endpoint endpoint protocol Alice Bob Carol Protocol Conformance 4. Check program conforms to Session C P Alice P Bob P Carol protocol Program 5. ⇒ Safe program by design Nicholas Ng, Nobuko Yoshida and Kohei Honda Multiparty Session C: Safe Parallel Programming with Message Optimisation

  17. Session C programming: Key reasoning 1. Design protocol in global view Global Protocol ( G ) Scribble 2. Automatic projection to Protocol Projection endpoint protocol, algorithm Endpoint T Alice T Bob T Carol Scribble preserves safety Protocol < < Refinement < 3. Write program according to Refined T ′ T ′ T ′ Endpoint endpoint protocol Alice Bob Carol Protocol Conformance 4. Check program conforms to Session C P Alice P Bob P Carol protocol Program 5. ⇒ Safe program by design Nicholas Ng, Nobuko Yoshida and Kohei Honda Multiparty Session C: Safe Parallel Programming with Message Optimisation

  18. Session C programming: Key reasoning 1. Design protocol in global view Global Protocol ( G ) Scribble 2. Automatic projection to Protocol Projection endpoint protocol, algorithm Endpoint T Alice T Bob T Carol Scribble preserves safety Protocol < < Refinement < 3. Write program according to Refined T ′ T ′ T ′ Endpoint endpoint protocol Alice Bob Carol Protocol Conformance 4. Check program conforms to Session C P Alice P Bob P Carol protocol Program 5. ⇒ Safe program by design Nicholas Ng, Nobuko Yoshida and Kohei Honda Multiparty Session C: Safe Parallel Programming with Message Optimisation

  19. Session C programming: Key reasoning 1. Design protocol in global view Global Protocol ( G ) Scribble 2. Automatic projection to Protocol Projection endpoint protocol, algorithm Endpoint T Alice T Bob T Carol Scribble preserves safety Protocol < < Refinement < 3. Write program according to Refined T ′ T ′ T ′ Endpoint endpoint protocol Alice Bob Carol Protocol Conformance 4. Check program conforms to Session C P Alice P Bob P Carol protocol Program 5. ⇒ Safe program by design Nicholas Ng, Nobuko Yoshida and Kohei Honda Multiparty Session C: Safe Parallel Programming with Message Optimisation

  20. Asynchronous optimisation ◮ Asynchronous operations can be safely permuted [Mostrous et al., ESOP’09] ◮ Pipelines inefficient in ‘strict’ multiparty session types ◮ Efficient pipelines with asynchronous subtyping of MPST Stage I Stage II Stage III A:send B:send C:send A B C A:recv B:recv C:recv Figure: Asynchronous subtyping. Nicholas Ng, Nobuko Yoshida and Kohei Honda Multiparty Session C: Safe Parallel Programming with Message Optimisation

  21. Jacobi solution for the DPE: Mesh topology ◮ Input segmented to 2D sub-grids ◮ Edge results exchanged between each neighbours ◮ Takes full advantage of asynchronous message optimisation Master North NorthEast West Worker East SouthWest South SouthEast Nicholas Ng, Nobuko Yoshida and Kohei Honda Multiparty Session C: Safe Parallel Programming with Message Optimisation

  22. Benchmark results: highlight 120 Session C (no optimisation) 110 MPI ◮ Jacobi method for the Session C 100 Discrete Poisson Runtime (seconds) 90 Equation 80 70 ◮ Mesh topology 60 ◮ Asynchronous 50 optimisation: 8% 40 30 improvement 20 1600 1800 2000 2200 2400 2600 2800 3000 Array size of sub-grid Nicholas Ng, Nobuko Yoshida and Kohei Honda Multiparty Session C: Safe Parallel Programming with Message Optimisation

  23. 6

Recommend


More recommend