scaling pycsp
play

Scaling PyCSP Rune Mllegaard Friborg, John Markus Bjrndalen and - PowerPoint PPT Presentation

Scaling PyCSP Rune Mllegaard Friborg, John Markus Bjrndalen and Brian Vinter CPA 2013, Edinburgh August 25, 2013 1 Python for eScience Applications Flexible Can interface with most programming languages Many scientists already


  1. Scaling PyCSP Rune Møllegaard Friborg, John Markus Bjørndalen and Brian Vinter CPA 2013, Edinburgh August 25, 2013 1

  2. Python for eScience Applications ● Flexible ● Can interface with most programming languages ● Many scientists already know Python ● Faster development cycle ● Compute-intensive parts written in compilable languages are easily integrated ● Forces programmers to write readable code 2

  3. CSP for eScience! ● Synchronized constructs for running a set of processes – In parallel – In sequence ● Synchronized communication through message passing – One-way channels ● Complete Process Isolation – No shared data-structures – No side-effects from processes – Compositional structure – Reuse of processes ● The data flow in scientific applications is often simple to model 3 in CSP.

  4. Introduction to PyCSP ● 2007 - PyCSP is presented. The synchronization model for channel communications is based on JCSP. ● 2009 - A PyCSP with a new synchronization model is presented. It is using the two-phase locking protocol to allow any-to-any channels supporting both input and output guards. ● 2011-2012 - A distributed version of the synchronization model is presented and later implemented in PyCSP 4

  5. We want to run anywhere! ● The user of PyCSP does not need to know anything about the location of the hardware any process might run on ● All channel ends are mobile 5

  6. Basic PyCSP Features 6

  7. Single Any-to-Any Channel A = Channel(“A”) 7

  8. Buffered A = Channel(“A”, buffer=10) 8

  9. Termination through Poisoning / Retiring Cin = A.reader() Cin.poison() # propagate pill right now! Cin.retire() # propagate pill, when all readers on A have invoked retire 9

  10. External Choice # Does not guarantee priority AltSelect(InputGuard(cin), OutputGuard(cout, msg)) 10

  11. External Choice # Guarantees priority, by adding a wait for an acknowledgement PriSelect(InputGuard(cin), OutputGuard(cout, msg)) 11

  12. External Choice # Uses PriSelect to perform a fair choice through reordering of guards, based on past selections FairSelect(InputGuard(cin), OutputGuard(cout, msg)) 12

  13. Declaring Processes # An OS thread @process def Increment(cin, cout): cout(cin() + 1) 13

  14. Declaring Processes # An OS process @multiprocess def Increment(cin, cout): cout(cin() + 1) 14

  15. Starting Processes # Blocking PAR - Natural number generator Parallel( Prefix(C.reader(), A.writer(), 1), Increment(A.reader(), B.writer(), Delta(B.reader(), C.writer(), D.writer()) ) Spawn(processes...) Sequence(processes...) 15

  16. Compositional @process def Counter(cout): Parallel( Prefix(C.reader(), A.writer(), 1), Increment(A.reader(), B.writer(), Delta(B.reader(), C.writer(), cout) ) ) 16

  17. Connecting Channels Host A # Hosting channel A A = Channel(“A”) # Get address print(A.address) ('192.168.1.16', 63550) 17

  18. Connecting Channels Host B # Connect to channel A A = Channel(“A”, connect=('192.168.1.16', 63550)) 18

  19. @clusterprocess 19

  20. Declaring Remote Process # A cluster process @clusterprocess def Increment(cin, cout): cout(cin() + 1) 20

  21. Declaring Remote Process # A cluster process @clusterprocess( cluster_nodefile = <file containing list of nodes>, cluster_pin = <index for node in list>, cluster_hint = <'blocked' or 'strided'> ) def Increment(cin, cout): cout(cin() + 1) 21

  22. Executing Remote Process # Spawn single increment process Spawn(Increment(A.reader(), B.writer())) # or # Spawn 5 increment processes and put them on 5 different hosts if available Spawn( 5 * Increment(A.reader(), B.writer()), cluster_hint = 'strided') 22

  23. Connecting Channels Implicitly # Blocking PAR - Natural number generator # One clusterprocess per host Parallel( Prefix(C.reader(), A.writer(), 1), Increment(A.reader(), B.writer(), Delta(B.reader(), C.writer(), D.writer()), cluster_hint = 'strided' ) 23

  24. Connecting Channels Implicitly @clusterprocess def P1(cin): cin() # read value @clusterprocess def P2(cout): cout(42) # send value A = Channel() Parallel(P1(A.reader()),P2(A.writer())) 24

  25. Connecting Channels Implicitly @clusterprocess def P1(cin): Channels: cin() # read value “A” @clusterprocess def P2(cout): cout(42) # send value A = Channel(“A”) Parallel(P1(A.reader()),P2(A.writer())) 25

  26. Connecting Channels Implicitly P1 cin() @clusterprocess def P1(cin): Channels: cin() # read value “A” @clusterprocess P2 def P2(cout): cout(42) # send value cout() A = Channel(“A”) Parallel(P1(A.reader()),P2(A.writer())) Starting processes on remote hosts using the SSH protocol. PyCSP channels are used to transfer any function parameters 26

  27. Connecting Channels Implicitly P1 cin() @clusterprocess def P1(cin): Channels: cin() # read value “A” @clusterprocess P2 def P2(cout): cout(42) # send value cout() A = Channel(“A”) Parallel(P1(A.reader()),P2(A.writer())) The channel ends cin and cout reconnect to the channel home and registers as they are both new channel ends. 27

  28. Connecting Channels Implicitly P1 cin() read @clusterprocess def P1(cin): Channels: cin() # read value “A” @clusterprocess write 42 P2 def P2(cout): cout(42) # send value cout(42) A = Channel(“A”) Parallel(P1(A.reader()),P2(A.writer())) The channel ends cin and cout now posts a request for communication at the channel home 28

  29. Connecting Channels Implicitly P1 L cin() @clusterprocess def P1(cin): Channels: cin() # read value “A” @clusterprocess P2 def P2(cout): cout(42) # send value L cout() A = Channel(“A”) Parallel(P1(A.reader()),P2(A.writer())) The channel home then probes a read and write request for a potential match. Acquires the process locks and if successful, transfers the messages 29 and notifies the processes

  30. 512 processes (cores) in a ring @clusterprocess def elementP(this_read, next_write): while True: token = this_read() next_write(token + 1) 30

  31. 512 processes (cores) in a ring Does not scale! 31

  32. Possible solutions ● Avoid a channel home completely – Requires a lot more messages for any-to-any channels. The location of all processes connected to a channel must always be known. ● Request the user to redistribute another set of channels, where each channel is hosted evenly on the available hosts – Difficult for the user ● Add mobility to a channel home, such that it may be moved during active use. – Simple for the user. Our choice. 32

  33. Introducing Mobile Channel Homes in PyCSP @clusterprocess def elementP(this_read, next_write): this_read.become_home() while True: token = this_read() next_write(token + 1) 33

  34. Introducing Mobile Channel Homes in PyCSP ● Based on a transition model presented in 2011. – When a channel is poisoned, all active requests (processes) at a channel are notified with a POISON signal – Similarly, when a channel home is moved, all active requests (processes) at a channel are notified with a MOVE signal – Processes then receive the new address of the channel together with the MOVE signal. The processes then withdraws the active request from the “old” channel home and reposts the request at the new channel home. 34

  35. Introducing Mobile Channel Homes in PyCSP ● Based on a transition model presented in 2011 @clusterprocess def elementP( this_read , next_write ): this_read.become_home() while True: token = this_read() next_write( token + 1 ) 35

  36. Introducing Mobile Channel Homes in PyCSP this_read elementP L next_write A main B C this_read elementP L next_write 36

  37. Introducing Mobile Channel Homes in PyCSP this_read elementP L next_write A main B C this_read. become_home() elementP L next_write 37

  38. Introducing Mobile Channel Homes in PyCSP this_read elementP L next_write A main B MOVE B to B_2 C B_2 this_read.become_home() elementP L next_write 38

  39. Introducing Mobile Channel Homes in PyCSP this_read elementP L next_write A main B S e n d s a n y b u f f e r e d m e s C s a g e s B_2 this_read.become_home() elementP L next_write 39

  40. Introducing Mobile Channel Homes in PyCSP this_read elementP L MOVED to B_2 next_write A main B C B_2 this_read elementP L next_write B_2 is now the official channel home of B. If any processes connects 40 to B at main, they will receive the message “MOVED to B_2”

  41. Introducing Mobile Channel Homes in PyCSP this_read elementP L next_write A (moved) main B C B_2 this_read elementP L next_write 41

  42. Introducing Mobile Channel Homes in PyCSP ● The order of posted requests is not stable during a move of a channel home. Thus, priorities can not be guaranteed during this step. ● For most PyCSP applications, this is not expected to be an issue. 42

  43. Results 43

  44. 44

  45. 45

  46. 46

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