Newsgroups: comp.parallel.pvm
Path: ukc!uknet!doc.ic.ac.uk!news.sys.uea.ac.uk!radon.sys.uea.ac.uk!pga
From: pga@radon.sys.uea.ac.uk (P.G. Andrews CMP PG)
Subject: size IS everything!
Message-ID: <CJvxsC.6CB@sys.uea.ac.uk>
Keywords: small messages
Sender: news@sys.uea.ac.uk
Organization: University of East Anglia, NORWICH, ENGLAND.
Date: Wed, 19 Jan 1994 16:29:00 GMT
Lines: 78

Hi there fellow PVM-People,

	I'm working on using PVM to solve Operational Research calculations (namely 
D. Bersekas's Auction Algorithm).  At the moment I'm using a system of two (soon to be 
four) SUN-Sparc Stations to do it.  Each slave has to, repeatedly, perform calculations
until the optimal solution is reached.  In order to prevent the slave exiting I send
a control number as the first packed integer of each message.  All master-slave
communication is done with a message type of zero, and so the slave receives a message,
unpacks the first integer and if it's also a zero then it unpacks the rest, otherwise
it finds a two and exits, as below:


	/*	pvm_slave code		*/
	do{
		pvm_recv( -1, 0);
		pvm_upkint(&msgtype, 1, 1);
		if (msgtype==0) {
				/* unpack rest of message and perform calculations	*/
				/* send results back to master	*/
				}
		}
	while (msgtype!=2);
 	/* Program finished. Exit PVM before stopping */
    	pvm_exit();


	All seems fine until I came to time the program and found that it was taking
twice as long to perform the code below (the "tell slaves to exit_pvm") than is was
to do the rest of the program!  This made me think that there was something drastically
wrong somewhere.


	I re-wrote the code using pvm_send and pvm_mcast (as well as dabbling with
pvm_sendSig!).  I do realise that I'm only toying with trivial sized problems at the 
moment (the code below is done with the number of processors (n_proc) equal to three!)
but still, it shouldn't take approx. 20,000 uSecs to perform - especially when the total
program time is less than 30,000 uSecs!


	/*	Tell slaves to exit_pvm	*/
	msgtype = 2;
	for (j=0 ; j<nproc; j++) {
		pvm_initsend(PvmDataDefault);
		pvm_pkint(&msgtype, 1, 1);
		pvm_send(tids[j], 0);
		}


	/*	Tell slaves to exit_pvm	*/
	msgtype = 2;
	pvm_initsend(PvmDataDefault);
	pvm_pkint(&msgtype, 1, 1);
	pvm_mcast(tids, nproc, 0);


	I'm coming to the conclusion that it's the size that's effecting it as I've heard
on this newsgroup that the network sometimes holds back on sending small messages until it
can send a larger one and this message, being only four bytes long is a ripe candidate for
this.  I'd welcome any advice or comments about this, please feel free to Email me and if 
there is enough interest I'll post my findings to the newsgroup.

Many thanks in anticipation,

Pete.

(Quick thought:  why is abbreviation such a long word?)

The views in this message reflect the opinions of the author and do not, necessarily,
reflect those of the School of Information Systems nor the University of East Anglia,
Norwich, ENGLAND.

UU  UU   EEEE   AAAA                  Snail mail: Peter G. Andrews BSc.(hons),
UU  UU  EE     AAAAAA                             School of Information Systems,
UU  UU  EEEEE  AA  AA                             University of East Anglia,
UUUUUU  EE     AAAAAA                             NORWICH,     NORFOLK.
 UUUU    EEEE  AA  AA                             NR4  7TJ.    ENGLAND.

 N  O  R  W  I  C  H                  Email:      pga@sys.uea.ac.uk

