pvm

39
PVM PVM Prabhaker Mateti Prabhaker Mateti Wright State University Wright State University

Upload: daquan-vaughan

Post on 31-Dec-2015

20 views

Category:

Documents


1 download

DESCRIPTION

PVM. Prabhaker Mateti Wright State University. PVM Resources. Web site www.epm.ornl.gov/pvm/pvm_home.html Book PVM: Parallel Virtual Machine A Users' Guide and Tutorial for Networked Parallel Computing - PowerPoint PPT Presentation

TRANSCRIPT

PVMPVM

Prabhaker MatetiPrabhaker Mateti

Wright State UniversityWright State University

22

PVM ResourcesPVM Resources

Web site Web site www.epm.ornl.gov/pvm/pvm_home.htmlwww.epm.ornl.gov/pvm/pvm_home.html

BookBookPVM: Parallel Virtual MachinePVM: Parallel Virtual MachineA Users' Guide and Tutorial for Networked Parallel Computing A Users' Guide and Tutorial for Networked Parallel Computing

Al Al GeistGeist, , Adam Adam BeguelinBeguelin, , Jack Jack DongarraDongarra, Weicheng Jiang, , Weicheng Jiang, Robert Robert ManchekManchek, , VaidyVaidy SunderamSunderam

www.netlib.org/pvm3/book/pvm-book.htmlwww.netlib.org/pvm3/book/pvm-book.html

33

PVM = Parallel Virtual MachinePVM = Parallel Virtual Machine

Software packageSoftware packageStandard daemon: pvmdStandard daemon: pvmdApplication program interface Application program interface

Network of heterogeneous machinesNetwork of heterogeneous machinesWorkstationsWorkstationsSupercomputersSupercomputersUnix, NT, VMS, OS/2Unix, NT, VMS, OS/2

44

The The pvmd3 pvmd3 process process

Manages each host of vmManages each host of vm Message routerMessage router Create, destroy, … local processesCreate, destroy, … local processes Fault detection Fault detection AuthenticationAuthentication Collects outputCollects output

Inter-host point of contactInter-host point of contact One pvmd3 on each hostOne pvmd3 on each host

Can be started during bootCan be started during boot

55

The program named The program named pvmpvm

Interactive control consoleInteractive control consoleConfiguration of PVMConfiguration of PVMStatus checkingStatus checking

Can start pvmdCan start pvmd

66

The library The library libpvmlibpvm

Linked with application programsLinked with application programsFunctionsFunctions

Compose a messageCompose a messageSendSendReceiveReceive

System calls to pvmdSystem calls to pvmd libpvm3.a, libfpvm3.a, libgpvm3.alibpvm3.a, libfpvm3.a, libgpvm3.a

77

libpvm3.alibpvm3.a

Initiate and terminate processes Initiate and terminate processes Pack, send, and receive messages Pack, send, and receive messages Synchronize via barriers Synchronize via barriers Query and change configuration of the Query and change configuration of the

pvmpvmTalk to local pvmd3Talk to local pvmd3Data format conversion (XDR)Data format conversion (XDR)

88

libfpvm3.alibfpvm3.a

additionally required for Fortran codes additionally required for Fortran codes

99

libgpvm3.alibgpvm3.a

Dynamic groups of processesDynamic groups of processes

1010

1111

PVM: Hello World!PVM: Hello World!

#include <stdio.h>#include <stdio.h>#include "pvm3.h"#include "pvm3.h"

main()main(){{

me = pvm_mytid());me = pvm_mytid());

cc = pvm_spawn("hello_other”, 0, cc = pvm_spawn("hello_other”, 0, 0, "", 1, &tid);0, "", 1, &tid);

… …

pvm_exit();pvm_exit(); exit(0);exit(0);}}

#include "pvm3.h"#include "pvm3.h"

main()main(){{

ptid = pvm_parent();ptid = pvm_parent();

strcpy(buf, "hello, world from strcpy(buf, "hello, world from ");");gethostname(buf + strlen(buf), gethostname(buf + strlen(buf), 64);64);

pvm_initsend(PvmDataDefault);pvm_initsend(PvmDataDefault);pvm_pkstr(buf);pvm_pkstr(buf);pvm_send(ptid, 1);pvm_send(ptid, 1);

pvm_exit();pvm_exit();exit(0);exit(0);

}}

1212

PVM: Hello World!PVM: Hello World!

#include <stdio.h>#include <stdio.h>#include "pvm3.h"#include "pvm3.h"

main()main(){{ cc = pvm_spawn("hello_other", 0, 0, "", 1, cc = pvm_spawn("hello_other", 0, 0, "", 1,

&tid);&tid);

if (cc == 1) {if (cc == 1) { cc = pvm_recv(-1, -1);cc = pvm_recv(-1, -1); pvm_bufinfo(cc, 0, 0, pvm_bufinfo(cc, 0, 0, &tid);&tid); pvm_upkstr(buf);pvm_upkstr(buf); printf("from t%x: %s\n", printf("from t%x: %s\n", tid, buf);tid, buf);

} else …} else …

}}

#include "pvm3.h"#include "pvm3.h"

main()main(){{

int ptid;int ptid;char buf[100];char buf[100];

ptid = pvm_parent();ptid = pvm_parent();

strcpy(buf, "hello, world from ");strcpy(buf, "hello, world from ");gethostname(buf + strlen(buf), 64);gethostname(buf + strlen(buf), 64);

pvm_initsend(PvmDataDefault);pvm_initsend(PvmDataDefault);pvm_pkstr(buf);pvm_pkstr(buf);pvm_send(ptid, 1);pvm_send(ptid, 1);

pvm_exit();pvm_exit();exit(0);exit(0);

}}

1313

PVM: Hello World!PVM: Hello World!

#include <stdio.h>#include <stdio.h>#include "pvm3.h"#include "pvm3.h"

main()main(){{ int cc, tid;int cc, tid; char buf[100];char buf[100];

printf("i'm t%x\n", pvm_mytid());printf("i'm t%x\n", pvm_mytid());

cc = pvm_spawn("hello_other", 0, 0, "", 1, cc = pvm_spawn("hello_other", 0, 0, "", 1, &tid);&tid);

if (cc == 1) {if (cc == 1) { cc = pvm_recv(-1, -1);cc = pvm_recv(-1, -1); pvm_bufinfo(cc, 0, 0, &tid);pvm_bufinfo(cc, 0, 0, &tid); pvm_upkstr(buf);pvm_upkstr(buf); printf("from t%x: %s\n", tid, buf);printf("from t%x: %s\n", tid, buf);

} else} else printf("can't start hello_other\n");printf("can't start hello_other\n");

pvm_exit();pvm_exit(); exit(0);exit(0);}}

#include "pvm3.h"#include "pvm3.h"

main()main(){{

int ptid;int ptid;char buf[100];char buf[100];

ptid = pvm_parent();ptid = pvm_parent();

strcpy(buf, "hello, world from ");strcpy(buf, "hello, world from ");gethostname(buf + strlen(buf), 64);gethostname(buf + strlen(buf), 64);

pvm_initsend(PvmDataDefault);pvm_initsend(PvmDataDefault);pvm_pkstr(buf);pvm_pkstr(buf);pvm_send(ptid, 1);pvm_send(ptid, 1);

pvm_exit();pvm_exit();exit(0);exit(0);

}}

1414

1515

1616

pvm_mytidpvm_mytid

Enrolls the calling process into PVM and Enrolls the calling process into PVM and generates a unique task identifier if this generates a unique task identifier if this process is not already enrolled in PVM. If process is not already enrolled in PVM. If the calling process is already enrolled in the calling process is already enrolled in PVM, this routine simply returns the PVM, this routine simply returns the process's tid. process's tid.

tid = pvm_mytid (); tid = pvm_mytid ();

1717

pvm_spawnpvm_spawn

Starts new PVM processes. The Starts new PVM processes. The programmer can specify the machine programmer can specify the machine architecture and machine name where architecture and machine name where processes are to be spawned. processes are to be spawned.

numt = pvm_spawn numt = pvm_spawn ("worker",0,PvmTaskDefault,"",1,&tids[i]);("worker",0,PvmTaskDefault,"",1,&tids[i]);

numt = pvm_spawn numt = pvm_spawn ("worker",0,PvmTaskArch,"RS6K",1,&tid[i]); ("worker",0,PvmTaskArch,"RS6K",1,&tid[i]);

1818

pvm_exitpvm_exit

Tells the local pvmd that this process is Tells the local pvmd that this process is leaving PVM. This routine should be called leaving PVM. This routine should be called by all PVM processes before they exit. by all PVM processes before they exit.

1919

pvm_addhostspvm_addhosts

Add hosts to the virtual machine. The Add hosts to the virtual machine. The names should have the same syntax as names should have the same syntax as lines of a pvmd hostfile. lines of a pvmd hostfile.

pvm_addhosts (hostarray,4,infoarray);pvm_addhosts (hostarray,4,infoarray);

2020

pvm_delhostpvm_delhost

Deletes hosts from the virtual machine. Deletes hosts from the virtual machine. pvm_delhosts (hostarray,4);pvm_delhosts (hostarray,4);

2121

pvm_pkdatatypepvm_pkdatatype

Pack the specified data type into the active Pack the specified data type into the active send buffer. Should match a send buffer. Should match a corresponding unpack routine in the corresponding unpack routine in the receive process. Structure data types must receive process. Structure data types must be packed by their individual data be packed by their individual data elements.elements.

2222

pvm_upkdatatypepvm_upkdatatype

Unpack the specified data type into the Unpack the specified data type into the active receive buffer. Should match a active receive buffer. Should match a corresponding pack routine in the sending corresponding pack routine in the sending process. Structure data types must be process. Structure data types must be unpacked by their individual data unpacked by their individual data elements.elements.

2323

pvm_sendpvm_send

Immediately sends the data in the Immediately sends the data in the message buffer to the specified message buffer to the specified destination task. This is a blocking, send destination task. This is a blocking, send operation. Returns 0 if successful, < 0 operation. Returns 0 if successful, < 0 otherwise. otherwise.

pvm_send (tids[1],MSGTAG);pvm_send (tids[1],MSGTAG);

2424

pvm_psendpvm_psend

Both packs and sends message with a Both packs and sends message with a single call. Syntax requires specification of single call. Syntax requires specification of a valid data type. a valid data type.

2525

pvm_mcastpvm_mcast

Multicasts a message stored in the active Multicasts a message stored in the active send buffer to tasks specified in the tids[]. send buffer to tasks specified in the tids[]. The message is not sent to the caller even The message is not sent to the caller even if listed in the array of tids. if listed in the array of tids.

pvm_mcast (tids,ntask,msgtag);pvm_mcast (tids,ntask,msgtag);

2626

pvm_recvpvm_recv

Blocks the receiving process until a Blocks the receiving process until a message with the specified tag has arrived message with the specified tag has arrived from the specified tid. The message is from the specified tid. The message is then placed in a new active receive buffer, then placed in a new active receive buffer, which also clears the current receive which also clears the current receive buffer. buffer.

pvm_recv (tid,msgtag);pvm_recv (tid,msgtag);

2727

pvm_nrecvpvm_nrecv

Same as pvm_recv, except a non-blocking Same as pvm_recv, except a non-blocking receive operation is performed. If the specified receive operation is performed. If the specified message has arrived, this routine returns the message has arrived, this routine returns the buffer id of the new receive buffer. If the buffer id of the new receive buffer. If the message has not arrived, it returns 0. If an error message has not arrived, it returns 0. If an error occurs, then an integer < 0 is returned. occurs, then an integer < 0 is returned.

pvm_nrecv (tid,msgtag);pvm_nrecv (tid,msgtag);

2828

PVM Collective CommunicationPVM Collective Communication

2929

pvm_barrierpvm_barrier

Blocks the calling process until all Blocks the calling process until all processes in a group have called processes in a group have called pvm_barrier(). pvm_barrier().

pvm_barrier ("worker",5 );pvm_barrier ("worker",5 );

3030

pvm_bcastpvm_bcast

Asynchronously broadcasts the data in the Asynchronously broadcasts the data in the active send buffer to a group of processes. active send buffer to a group of processes. The broadcast message is not sent back The broadcast message is not sent back to the sender. to the sender.

pvm_bcast ("worker",msgtag);pvm_bcast ("worker",msgtag);

3131

pvm_gatherpvm_gather

A specified member receives messages from A specified member receives messages from each member of the group and gathers these each member of the group and gathers these messages into a single array. All group messages into a single array. All group members must call pvm_gather(). members must call pvm_gather().

pvm_gather pvm_gather (&getmatrix,&myrow,10,PVM_INT,msgtag,"work(&getmatrix,&myrow,10,PVM_INT,msgtag,"workers",root);ers",root);

3232

pvm_scatterpvm_scatter

Performs a scatter of data from the specified Performs a scatter of data from the specified root to each of the members of the group, root to each of the members of the group, including itself. All group members must call including itself. All group members must call pvm_scatter(). Each receives a portion of the pvm_scatter(). Each receives a portion of the data array from the root in their local result array. data array from the root in their local result array.

pvm_scatter (&getmyrow,&matrix,10,PVM_INT,pvm_scatter (&getmyrow,&matrix,10,PVM_INT,msgtag,"workers",root);msgtag,"workers",root);

3333

pvm_reducepvm_reduce

Performs a reduce operation over members of Performs a reduce operation over members of the group. All group members call it with their the group. All group members call it with their local data, and the result of the reduction local data, and the result of the reduction operation appears on the root. Users can define operation appears on the root. Users can define their own reduction functions or the predefined their own reduction functions or the predefined PVM reductionsPVM reductions

pvm_reduce pvm_reduce (PvmMax,&myvals,10,PVM_INT,msgtag,"worker(PvmMax,&myvals,10,PVM_INT,msgtag,"workers",root);s",root);

3434

Prepare to Execute Your PVM Prepare to Execute Your PVM sessionsession

PVM expects executables to be located in ~/pvm3/bin/$PVM_ARCH PVM expects executables to be located in ~/pvm3/bin/$PVM_ARCH

% ln -s $PVM_ROOT/lib ~/pvm3/lib % ln -s $PVM_ROOT/lib ~/pvm3/lib

%% cc -o myprog myprog.c -I$PVM_ROOT/include cc -o myprog myprog.c -I$PVM_ROOT/include

-L$PVM_ROOT/lib/$PVM_ARCH -lpvm3-L$PVM_ROOT/lib/$PVM_ARCH -lpvm3

3535

Create your PVM hostfile Create your PVM hostfile

PVM hostfile defines your parallel virtual PVM hostfile defines your parallel virtual machine. It contains the names of all machine. It contains the names of all desired machines, one per line.desired machines, one per line.

3636

Create Your $HOME/.rhosts file Create Your $HOME/.rhosts file

Example .rhosts file Example .rhosts file

mamma.cs.wright.edu user02mamma.cs.wright.edu user02

fr2s02.mhpcc.edu user02fr2s02.mhpcc.edu user02

beech.tc.cornell.edu jdoebeech.tc.cornell.edu jdoe

machine.mit.edu user02machine.mit.edu user02

3737

Start pvmd3Start pvmd3

% pvmd3 hostfile &% pvmd3 hostfile &

This starts up daemons on all other This starts up daemons on all other machines (remote) specified in your machines (remote) specified in your hostfile. hostfile.

PVM console can be started after pvmd3 PVM console can be started after pvmd3 by typing "pvm". by typing "pvm".

3838

Execute your application Execute your application

% myprog% myprog

3939

Quitting PVM Quitting PVM

Application components must include call of Application components must include call of pvm_exit(). pvm_exit().

Halting the master pvmd3 will automatically kill Halting the master pvmd3 will automatically kill all other pvmd3s and all processes enrolled in all other pvmd3s and all processes enrolled in this PVM. this PVM.

In pvm console: "halt"In pvm console: "halt" Running in the background: enter console mode Running in the background: enter console mode

by typing "pvm" and halt. by typing "pvm" and halt.