Title: PVM: Parallel Virtual Machine A Users' Guide and Tutorial for Networked Parallel Computing
1?????
- PVM Parallel Virtual Machine A Users' Guide and
Tutorial for Networked Parallel Computing - Program Examples
- ????? ???
2Contents
Program Examples Fork-Join Fork Join Example
Dot Product Example program PSDOT.F FailureÂ
Example program failure.c Matrix MultiplyÂ
Example program mmult.c One-Dimensional Heat
Equation Example program heat.c Example
program heatslv.c Different Styles of
Communication Â
3Overview
- The first example
- forkjoin.c
- Show how to spawn off processes and synchronize
with them - The second example
- A Fortran dot product program
- PSDOT.F
- The third example
- failure.c
- Use the pvm_notify() call to create fault
tolerant applications
4Fork-Join
- To spawn PVM tasks and synchronize with them
- The program spawns several tasks
- Three by default
- Three steps
- The children then synchronize by sending a
message to their parent task - The parent receives a message from each of the
spawned tasks - Print out information about the message from the
child tasks
5Fork-Join
- The fork-join program contains the code for both
the parent and the child tasks - See the source code of the Fork-Join example
6Fork-Join
- The output of running forkjoin
forkjoin t10001c t40149 tc0037 Length 4, Tag
11, Tid t40149 Length 4, Tag 11, Tid tc0037
Length 4, Tag 11, Tid t10001 c forkjoin 4
t10001e t10001d t4014b tc0038 Length 4, Tag 11,
Tid t4014b Length 4, Tag 11, Tid tc0038 Length
4, Tag 11, Tid t10001d Length 4, Tag 11, Tid
t10001e
7Failure
- The failure example demonstrates
- how one can kill tasks
- How one can find out when tasks exit or fail
- Fining out when a task fails
- Call pvm_notify() after spawning the tasks
- The pvm_notify() call can tells PVM to send the
calling task a message when certain tasks exit
8Failure
- The task calling pvm_notify() will receive the
notification, not the tasks given in the task id
array - The notify call can also be used to a task when a
new host has been added or deleted from the
virtual machine
9Failure
- After requesting notification, the parent task
then kills one of the children - After killing one of the spawned tasks, the
parent waits on a pvm_recv(-1, TASKDIED) for the
message notifying it the task has died - The process unpacks the dead tasks id and prints
it out
10Failure
- See the source code of the Failure example
11Different Styles of Communication
- These example demonstrate various ways of writing
PVM programs - In some cases messages are used for
synchronization - In others the master processes simply kill of the
workers when they are no longer needed
12Quiz
- 1210000
- Distribute the above calculation to several PVM
tasks, for example n tasks - Kill the middle task, i.e. n/2
- Try to obtain the correct calculating result from
the remaining n-1 tasks
13Reference
- A Beginners Guide to PVM Virtual Machine,
available through http//www.itec.uni-klu.ac.at/h
arald/PVM/pvm_guide.html