Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to PVM PVM (Parallel Virtual Machine) is a package of libraries and runtime daemons that enables building parallel apps easily and efficiently.

Similar presentations


Presentation on theme: "Introduction to PVM PVM (Parallel Virtual Machine) is a package of libraries and runtime daemons that enables building parallel apps easily and efficiently."— Presentation transcript:

1 Introduction to PVM PVM (Parallel Virtual Machine) is a package of libraries and runtime daemons that enables building parallel apps easily and efficiently

2 Key attributes of PVM Runs on every UNIX and WNT/W95 Runs over most physical networks (ethernet, FDDI, Myrinet, ATM, Shared-Memory) A heterogeneous collection of machines can be assembled and used as a Super Computer Programming is completely portable The underlying machine and network is transparent to the programmer/user Each user has his/hers own private VM

3 History of PVM Developed at the U. of Tennessee at Knoxville and at the Oak Ridge National Lab (ORNL) Project leader is Jack Dongarra PVM 2.0 released in 1992 PVM 3.3 released in June, 1994 Last stable version is 3.3.11 Latest version is 3.4 beta 7 available for W95 and WNT as well

4 Lets look at a sample application PVM functions are underlined: /* Basic hello world sample program. Spawns a slave and receives a string from it. */ #include main() { int cc, tid; char buf[100]; printf("i'm t%x\n", pvm_mytid()); /* spawn 1 copy of hello_other on any machine */ cc = pvm_spawn("hello_other", (char**)0,PvmTaskDefault, "", 1, &tid); if (cc == 1) { cc = pvm_recv(-1, -1); /* receive a message from any source */ /* get info about the sender */ pvm_bufinfo(cc, (int*)0, (int*)0, &tid); pvm_upkstr(buf); printf("from t%x: %s\n", tid, buf); } else printf("can't start hello_other\n"); pvm_exit(); exit(0); }

5 pvm_mytid int pvm_mytid(); pvm_mytid() returns the tid of the calling task. Each PVM task has a unique (tid) Task ID which is assigned to it when it is created. Each host has a range of 0x40000 tids available. Thus a tid will look like 0x40003 or 0xC001a. pvm_parent int pvm_parent(); pvm_parent() returns the tid of the calling tasks parent, the task which spawned it. In the case where the task wasn’t spawned PvmNoParent (-1) is returned.

6 pvm_spawn() int pvm_spawn(char* task, char** argv, int flag, char* where, int ntask, int *tids) Spawns a task which is a executable with optional command line arguments. Can spawn several copies on several machines depending on the flag argument. The tids of spawned tasks are returned in tids and the number of spawned tasks is returned by the function. The combination flag and where define where the tasks will be spawned: PvmTaskDefault - spawn on any machine PvmTaskHost - spawn on the machine named in where PvmTaskArch - spawn on the architecture named in where PvmTaskDebug - spawn the task in a debugger PvmHostCompl - spawn on any machine except where

7 Receiving a message int pvm_recv(int source, int tag) - Block until a message sent by source with tag arrives. -1 is a wildcard value that receives from any source or tag. Returns the id of the message buffer used. int pvm_upkstr(char* str) - Unpack a string from the message buffer. int pvm_upkint(char* ip, int size, int size) - Unpack size integers, insert them in every other stride place in ip. int pvm_bufinfo(int buf, int* bytes, int* tag, int* tid) - Using buf the buffer id received from pvm_recv(), get the size bytes, tag and tid of the received message.

8 Lets look at the spawned app PVM functions are underlined: /* Slave part of hello world sample program. Sends a string to the task that spawned it. */ #include #define HELLO_TAG 100 main() { int ptid; char buf[100]; ptid = pvm_parent(); strcpy(buf, "hello, world from "); gethostname(buf + strlen(buf), 64); /* send string to parent */ pvm_initsend(PvmDataDefault); pvm_pkstr(buf); pvm_send(ptid, HELLO_TAG); pvm_exit(); exit(0); }

9 Sending a message int pvm_initsend(int encoding) - Init a buffer for sending a message. Encoding defines how the data is packed, use PvmDataDefault for XDR encoding. int pvm_pkstr(char* str) - Pack a string into the buffer. int pvm_pkint(int *ip, int size, int stride) - Pack an array of size integers, pack every other stride integer. int pvm_send(int target, int tag) - Send the buffer to tid target. Identify the message by tag.

10 Message Passing in PVM Asyncronous - pvm_send() doesn’t block pvm_recv() does. Use pvm_trecv(), pvm_nrecv() and pvm_probe() for non-blocking receives. Ordered - Messages from task A to task B are ordered and will arrive in the order sent. Unordered - Messages from tasks A and B to task C will arrive unordered between themselves. Deadlockable - It is very easy to deadlock an application. Multicast - use pvm_mcast().

11 Other groups of functions Task control - pvm_kill(), pvm_exit(). Information - pvm_pstat(), pvm_mstat(), pvm_config(), pvm_tasks(), pvm_tidtohost(). Host control - pvm_addhosts(), pvm_delhosts(), pvm_halt(). Buffer manipulation - pvm_mkbuf(), pvm_freebuf(), pvm_setrbuf(), pvm_setsbuf(), pvm_getrbuf(), pvm_setsbuf().

12 PVM Daemons Called pvmd3 or pvmd Created on every machine added to the Virtual Machine The first daemon created is called the “master daemon”. The daemons are in constant communication with each other and detect failures. A failed slave daemon is deleted, if the master daemon fails the whole VM halts. The daemons are responsible for executing most of the pvm calls. By default all communication is performed via the daemons. It is possible to establish direct links between tasks (see pvm_setopt() ). By default there is only one daemon per user on each machine.


Download ppt "Introduction to PVM PVM (Parallel Virtual Machine) is a package of libraries and runtime daemons that enables building parallel apps easily and efficiently."

Similar presentations


Ads by Google