Title: A Beginners Guide to PVM Parallel Virtual Machine
1?????
- A Beginners Guide to PVM Parallel Virtual
Machine - ????? ???
2Contents
- Introduction
- Installing PVM
- Writing PVM Applications
- Running PVM Applications
3Introduction
- Heterogeneous distributed computing
- Treat the resulting systems as a single virtual
machine
4Introduction
- Network
- LAN connecting machines
- The Internet connecting machines
- Divide a problem into subtasks
- Assign each one to be executed
5Introduction
- Based on the message-passing model
- Uers tasks
- Initiate, terminate, send, and receive data
- Dynamic
- Can be started or killed during the execution of
a program
6Installing PVM
- No special privileges
- Download
- http//www.netlib.org/pvm3
- The most recent version of PVM was pvm3.4
- The environment variable
- PVM_ROOT
- PVM can find various files
7Configuration
export PVM_ROOT/usr/lib/pvm3 export
PVM_DPATHPVM_ROOT/lib/pvmd export
MANPATHMANPATHPVM_ROOT/man export
PATHPATHPVM_ROOT/libPVM_ROOT/include
8Configuration
- Make a file .rhosts in your HOME directory and
write in it
The machines lpc1, lpc2, lpc4 and lpc5 and the
medusa can be used as machines for the PVM
platform. The users are pardb1 --
pardb7. lpc1.itec.uni-klu.ac.at harald
lpc2.itec.uni-klu.ac.at harald
9Writing PVM Applications
- Almost all PVM calls in C
- Start with pvm_ (e.g., mytid pvm_mytid())
10Writing PVM Applications
C Code myprog.c include "pvm3.h" define
NTASKS 5 main() int mytid, info
mytid pvm_mytid() / enroll in PVM /
/ Possibly do some work here ... /
printf("Hello from task d", mytid)
info pvm_exit() / exit from PVM /
exit()
11Writing PVM Applications
- Compiling in C
- Running the execution
- Start the PVM
- Quit to the console
- Run one copy of the executable
cc -o myprog myprog.c -IPVM_ROOT/include
-LPVM_ROOT/lib/LINUX -lpvm3 -lnsl
12(asteroid) pvm pvmgt conf 1 host, 1 data format
HOST DTID
ARCH SPEED
asteroid 40000 LINUX 1000 pvmgt
quit myprog Hello from task 262146 pvm
pvmgt spawn -3 -gt myprog 1 3 successful
t40004 t40005 t40006 1t40005 Hello from
task 262149 1t40005 EOF 1t40006 Hello
from task 262150 1t40006 EOF 1t40004
Hello from task 262148 1t40004 EOF 1
finished pvmgt halt
13Detailed Examples
- Master/worker paradigm
- Master is designated to be the coordinator
- Handling the spawning of the other tasks
- Multiple tasks are spawned from the command line
or the console - Each PVM tasks receives a unique tid from the PVM
daemon
14Detailed Examples
- Illustrate a master/worker code
- Sums up the value of an integer array
- The master task
- Spawn off five worker tasks
- Send each of the workers a portion of array to be
summed up - Receive the partial totals from each of the
workers - Add those up for the final total
15Detailed Examples
- The worker tasks
- Receive an array of integers
- Add up all the values in the array
- Send the total back to the master process
16(No Transcript)
17(No Transcript)
18Detailed Examples
- The worker processes are spawned
- task - a string containing the name of the
executable file to be run - argv - arguments are required by the task
- flag possible values for flag are
int numt pvm_spawn(char task, char argv, int
flag, char where, int ntask, int tids)
PvmTaskDefault -- PVM chooses where this task is
spawned to. PvmTaskHost -- the where string
argument specifies the particular machine.
PvmTaskArch -- the where string indicates the
architecture type.
19Detailed Examples
- ntask specify the number of copies of the task
to be spawned - tid a pointer to an integer array that will
contain the task ids - numt return the number of tasks that were
successfully created
20Detailed Examples
- To send a message from one task to another
- encoding
int bufid pvm_initsend (int encoding)
PvmDataDefault different data represent to
exchange PvmDataRaw no encoding of the message
data PvmDataInPlace leaves the data in memory
instead of copying it to the send buffer
21Detailed Examples
- Send buffer needs to be packed with data to be
sent - pvm_pkXXX()
The data types supported by PVM (and their XXXX
function designation) are byte (byte), complex
(cplx), double complex (dcplx), double (double),
float (float), integer (int), long (long) and
short(short).
22Detailed Examples
- The example code packs integers and uses the
function pvm_pkint() - np a pointer to the data to be packed
- nitem the total number of items to be packed
- stride step size
int info pvm_pkint (int np, int nitem, int
stride)
23Detailed Examples
- The function to send a message is pvm_send()
- tid the task id
- msgtag arbitrary integer that can be used to
distinguish between different messages
int info pvm_send (int tid, int msgtag)
24Detailed Examples
- The master program must receive from each of the
worker processes - The unpacking functions are pvm_upkXXXX()
-
int bufid pvm_recv (int tid, int msgtag)
int info pvm_upkint (int np, int nitem, int
stride)
25Detailed Examples
- Our example
- Unpack each partial result received into a
different element of the results array - After the sum is completed
- Print the master task
- Exit from the virtual machine
int info pvm_exit()
26Detailed Examples
- As for the worker program
- Using the -1 wild cards in the pvm_recv()
- Indicate that the task does not care what task
the message was sent from nor message label was
used - Task id of the parent task
int parent_id pvm_parent()
27Detailed Examples
- The compilation process for our example codes
would be
cc -o master master.c -IPVM_ROOT/include
-LPVM_ROOT/lib/LINUX -lpvm3 lnsl cc -o worker
worker.c -IPVM_ROOT/include -LPVM_ROOT/lib/LINUX
-lpvm3 -lnsl
28Detailed Examples
- Complete details for all PVM library functions
can be found in - PVM3 Users Guide and Reference Manual
- http//www.netlib.org/pvm3/book/node1.html
29Running PVM Applications
- The conf command lists the current virtual
machine configuration
30Running PVM Applications
- Use the add and delete commands to add and remove
computers from your virtual machine
31Running PVM Applications
- The quit command only exits the console program
- all the daemons and PVM tasks are left running
- Terminate all PVM daemons by using the halt
command
32Reference
- A Beginners Guide to PVM Virtual Machine,
available through http//www.itec.uni-klu.ac.at/h
arald/PVM/pvm_guide.html