Newsgroups: comp.parallel.pvm
From: Thulasiraman Jeyaraman <tram@silver.cs.umanitoba.ca>
Subject: Re: pvm_nrecv fails to get large messages
Organization: The University of Manitoba
Date: Mon, 11 Dec 1995 10:59:56 -0600
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Message-ID: <Pine.SUN.3.91.951211104145.11106B-100000@silver.cs.umanitoba.ca>

On 8 Dec 1995, Hans Georg Krauthaeuser wrote:

> I have a spmd program running with pvm3.3.9 on a HPPA arch. In this program 
> the master process (number 0) should get some messages from the other 
> processes. When the message size is large pvm_nrecv did not find all 
> messages. The return value from pvm_send is zero. What am I doing wrong?
> 
>      int msgtag = 4;
>      int i,j, bufid;
>      dest = pvm_gettid("foo", 0);
> 
>      printf ("Me=%d: begining!\n", me);
> 
>      if( me == 0 )
>      { 
>        for(j=0; j<1000;j++)
> 	 {
> 	 for (i=0; i<10000; i++)
> 	   {
> 	     i++;
> 	     i--;
> 	   }
> 	 }
>        while (bufid = pvm_nrecv( -1, msgtag ))
> 	 {
> 	   pvm_upkint (&token,count,stride);
> 	   printf("token=%d\n", token);
> 	  }
>      }

The above while loop does not guarantee that the master task waits for 
all the slave tasks to send messages. pvm_nrecv returns bufid=0 when it 
finds no outstanding messages. 

When SIZE=1000 some of the slave messages reached earlier than the master 
completed the forloop. So, it read all the messages to be read.

When SIZE=10000 the master task finishes computation faster than the 
message arrival from slave task. In this case, pvm_nrecv returns 0 and 
while loop is exited - no messages read.

Solution:

   count = 0;
   while (1) {
     bufid = pvm_nrecv(-1, msgtag);
     if (bufid == 0) continue;
     if (bufid < 0) pvm_perror("master: recv");
     else {
	  pvm_upkint (&token,count,stride);   
          printf("token=%d\n", token);
	  count++;
	  if (count == num_of_slave_tasks_spawned) break;
     }
   }








