Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Science and Engineering Parallel and Distributed Processing CSE 8380 February 22 2005 Session 12.

Similar presentations


Presentation on theme: "Computer Science and Engineering Parallel and Distributed Processing CSE 8380 February 22 2005 Session 12."— Presentation transcript:

1 Computer Science and Engineering Parallel and Distributed Processing CSE 8380 February 22 2005 Session 12

2 Computer Science and Engineering Parallel Virtual Machine (PVM)  Review  Communication  Synchronization  Reduction operations  Work Assignments

3 Computer Science and Engineering Main Constructs in PVM  Task Creation  Communication  Synchronization  Others

4 Computer Science and Engineering PVM Software  Two Components:  Library of PVM routines  Daemon

5 Computer Science and Engineering PVM Application  A number of sequential programs, each of which will correspond to one or more processes in a parallel program

6 Computer Science and Engineering Application Structure  Start graph  Tree

7 Computer Science and Engineering To Create a child, you must specify: 1. The machine on which the child will be started 2. A path to the executable file on the specified machine 3. The number of copies of the child to be created 4. An array of arguments to the child tasks

8 Computer Science and Engineering Pvm_spawn num = pvm_spawn(child, arguments, flag, where, howmany, &tids)

9 Computer Science and Engineering Communication among Tasks User application Library Daemon 1 23 4 User application Library Daemon 5 6 7 8 Sending TaskReceiving Task

10 Computer Science and Engineering Standard PVM asynchronous communication  A sending task issues a send command (point 1)  The message is transferred to the daemon (point 2)  Control is returned to the user application (points 3 & 4)  The daemon will transmit the message on the physical wire sometime after returning control to the user application (point 3)

11 Computer Science and Engineering Standard PVM asynchronous communication (cont.) The receiving task issues a receive command (point 5) at some other time In the case of a blocking receive, the receiving task blocks on the daemon waiting for a message (point 6). After the message arrives, control is returned to the user application (points 7 & 8) In the case of a non-blocking receive, control is returned to the user application immediately (points 7 & 8)

12 Computer Science and Engineering Send (3 steps) 1.A send buffer must be initialized 2.The message is packed into the buffer 3.The completed message is sent to its destination(s)

13 Computer Science and Engineering Receive (2 steps) 1.The message is received 2.The received items are unpacked

14 Computer Science and Engineering Message Buffers Buffer Creation (before packing) Bufid = pvm_initsend(encoding_option) Bufid = pvm_mkbuf(encoding_option) Encoding optionMeaning 0XDR 1No encoding 2Leave data in place

15 Computer Science and Engineering Message Buffers (cont.) Data Packing pvm_pk*() pvm_pkstr() – one argument pvm_pkstr(“This is my data”); Others – three arguments 1. Pointer to the first item 2. Number of items to be packed 3. Stride pvm_pkint(my_array, n, 1); Packing functions can be called multiple times to pack data into a single message

16 Computer Science and Engineering Sending a message Point to point (one receiver) info = pvm_send(tid, tag) broadcast (multiple receivers) info = pvm_mcast(tids, n, tag) info = pvm_bcast(group_name, tag) Pack and Send (one step) info = pvm_psend(tid, tag, my_array, length, data type)

17 Computer Science and Engineering Receiving a message Blocking bufid = pvm_recv(tid, tag) -1  wild card in either tid or tag Nonblocking bufid = pvm_nrecv(tid, tag) bufid = 0 (no message was received) Timeout bufid = pvm_trecv(tid, tag, timeout) bufid = 0 (no message was received)

18 Computer Science and Engineering Different Receive in PVM Pvm_recv() wait Time Funciton is called Time is expired Message arrival Blocking Pvm_nrecv() Continue execution Non-blocking Pvm_trecv() wait Timeout Resume execution

19 Computer Science and Engineering Data unpacking pvm_upk*() pvm_upkstr() – one argument pvm_upkstr(string); Others – three arguments 1. Pointer to the first item 2. Number of items to be unpacked 3. Stride pvm_upkint(my_array, n, 1);

20 Computer Science and Engineering Task Synchronization  Synchronization constructs are used to force a certain order of execution among the activities in a parallel program.  Synchronization Constructs  Blocking Receive  Barriers

21 Computer Science and Engineering Blocking Receive pvm_recv(100,tag)g()f()pvm_send(200,tag) T0 TID = 100 T1 TID = 200 g() in T1 is not executed until f() in T0 has finished

22 Computer Science and Engineering Group Barrier in PVM pvm_barrier(“slave”, 3) proceed wait pvm_barrier(“slave”, 3) proceed wait pvm_barrier(“slave”, 3) proceed T2T0T1 Group: slave Synchronization Point

23 Computer Science and Engineering Reduction Operation info = pvm_reduce(func, data, n, datatype, tag, group_name, root) Example info = pvm_reduce(PvmSum, dataarray, 5, PVM_INT, tag, “slave”, root) T010,5,20,8,3010,5,20,8,30 T1(root)2,15,4,12,620,45,30,30,50 T28,25,6,10,148,25,6,10,14 Before reductionafter reduction

24 Computer Science and Engineering Work Assignment (different programs) info1 = pvm_spawn(“/user/rewini/worker1”, 0, 1, “lpc01”, 1, &tid1) info2 = pvm_spawn(“/user/rewini/worker2”, 0, 1, “lpc02”, 1, &tid2) info3 = pvm_spawn(“/user/rewini/worker3”, 0, 1, “lpc03”, 1, &tid3) info4 = pvm_spawn(“/user/rewini/worker4”, 0, 1, “lpc04”, 1, &tid4)

25 Computer Science and Engineering Work Assignment (Same Program) If we know that the IDs are 1, 2,.., n-1 Switch (my_id) { case 1: /* Work assigned to the worker whose id number is 1 */ break; case 2: /* Work assigned to the worker whose id number is 2 */ break; … case n-1: /* Work assigned to the worker whose id number is n-1 */ break; default:;} /* end switch */

26 Computer Science and Engineering Using task ID array to get my_id  The supervisor sends an array containing the TIDs of all the tasks to all the workers.  The supervisor’s TID is saved in the zero element of the array and the workers are saved in elements 1 to n-1.  Each worker searchers for its own TID and the index can be used to identify the corresponding worker.

27 Computer Science and Engineering Using task groups to get my_id  All the tasks join one group and the instance numbers are used as the new task identifiers.  The supervisor is the first one to join the group and gets instance number 0.  The workers get instance numbers in the range from 1 to n-1


Download ppt "Computer Science and Engineering Parallel and Distributed Processing CSE 8380 February 22 2005 Session 12."

Similar presentations


Ads by Google