A Beginners Guide to PVM Parallel Virtual Machine - PowerPoint PPT Presentation

1 / 32
About This Presentation
Title:

A Beginners Guide to PVM Parallel Virtual Machine

Description:

Can be started or killed during the execution of a program ... Exit from the virtual machine. int info = pvm_exit() Detailed Examples. As for the worker program ... – PowerPoint PPT presentation

Number of Views:241
Avg rating:3.0/5.0
Slides: 33
Provided by: tainc
Category:

less

Transcript and Presenter's Notes

Title: A Beginners Guide to PVM Parallel Virtual Machine


1
?????
  • A Beginners Guide to PVM Parallel Virtual
    Machine
  • ????? ???

2
Contents
  • Introduction
  • Installing PVM
  • Writing PVM Applications
  • Running PVM Applications

3
Introduction
  • Heterogeneous distributed computing
  • Treat the resulting systems as a single virtual
    machine

4
Introduction
  • Network
  • LAN connecting machines
  • The Internet connecting machines
  • Divide a problem into subtasks
  • Assign each one to be executed

5
Introduction
  • 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

6
Installing 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

7
Configuration
  • Example - .bashrc

export PVM_ROOT/usr/lib/pvm3 export
PVM_DPATHPVM_ROOT/lib/pvmd export
MANPATHMANPATHPVM_ROOT/man export
PATHPATHPVM_ROOT/libPVM_ROOT/include
8
Configuration
  • 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
9
Writing PVM Applications
  • Almost all PVM calls in C
  • Start with pvm_ (e.g., mytid pvm_mytid())

10
Writing PVM Applications
  • First Example

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()
11
Writing 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
13
Detailed 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

14
Detailed 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

15
Detailed 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)
18
Detailed 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.
19
Detailed 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

20
Detailed 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
21
Detailed 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).
22
Detailed 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)
23
Detailed 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)
24
Detailed 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)
25
Detailed 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()
26
Detailed 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()
27
Detailed 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
28
Detailed 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

29
Running PVM Applications
  • The conf command lists the current virtual
    machine configuration

30
Running PVM Applications
  • Use the add and delete commands to add and remove
    computers from your virtual machine

31
Running 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

32
Reference
  • A Beginners Guide to PVM Virtual Machine,
    available through http//www.itec.uni-klu.ac.at/h
    arald/PVM/pvm_guide.html
Write a Comment
User Comments (0)
About PowerShow.com