# Fri Jul 12 2002 02:34:59AM Thomas Naughton Simple example of a master/slave parallel PVM app. The master prompts for a number of nodes, then spawn that number, sends out the task ids so everyone can figure out who they are and who else is around them. They then send to their neighbor, each summing things as they go along, and finally sending this to the master who prints the final total. This demonstrates how to pack integers for sending and recving data, as well as figuring out how to locate yourself in the list of tasks participating. After setting up your account for use w/ PVM, you'll make the project and then run the pvm program. EXAMPLE: naughton: $ make gcc -I/opt/pvm3/include master.c -L/opt/pvm3/lib/LINUX -lpvm3 -lm -o master /opt/pvm3/lib/LINUX/libpvm3.a(lpvm.o): In function `pvm_tc_conreq': lpvm.o(.text+0x897): the use of `tmpnam' is dangerous, better use `mkstemp' gcc -I/opt/pvm3/include slave.c -L/opt/pvm3/lib/LINUX -lpvm3 -lm -o slave /opt/pvm3/lib/LINUX/libpvm3.a(lpvm.o): In function `pvm_tc_conreq': lpvm.o(.text+0x897): the use of `tmpnam' is dangerous, better use `mkstemp' Don't worry about the tmpname warnings! --tjn naughton: $ make cp2bin Copying the binaries to the PVM bin dir \cp -i master /home/naughton/pvm3/bin/LINUX/ \cp -i slave /home/naughton/pvm3/bin/LINUX/ naughton: $ pvm nodes pvm> quit quit Console: exit handler called pvmd still running. naughton: $ pushd ~/pvm3/bin/LINUX/ ~/pvm3/bin/LINUX ~/add-ints ~/pvm3/bin/LINUX naughton: $ ls master slave naughton: $ ./master Enter number of items (<=20): 20 The sum of the numbers is: 210 naughton: $ popd ~/add-ints ~/pvm3/bin/LINUX naughton: $ make cleanall Deleting local bin files \rm -f *.o master slave Deleting bin files in /home/naughton/pvm3/bin/LINUX... \rm -f /home/naughton/pvm3/bin/LINUX/master \rm -f /home/naughton/pvm3/bin/LINUX/slave naughton: $ ls Makefile master.c nodes README slave.c