[mvapich-discuss] MPI continuous send and receive of messages in a loop

Juan Vercellone juanjov at gmail.com
Mon Oct 31 09:06:28 EDT 2011


On Mon, Oct 31, 2011 at 12:56 AM, roger federer <ooops.789 at gmail.com> wrote:
> ohk so i need to place the string==n outside the if loop??? but i see that
> even if i give more number of messages to be sent, it is showing only max of
> 2 messages are sent and it is printing "ONE OF THE PROCESSES TERMINATED
> BADLY: CLEANING UP
> APPLICATION TERMINATED WITH THE EXIT STRING: Terminated (signal 15)
> "
>
> On Mon, Oct 31, 2011 at 12:15 AM, Juan Vercellone <juanjov at gmail.com> wrote:
>>
>> On Sun, Oct 30, 2011 at 10:53 PM, roger federer <ooops.789 at gmail.com>
>> wrote:
>> > well i am trying to do a program, where the process 0 should start the
>> > initialization of sending messages to a random process other than
>> > itself,
>> > then the random process selected should receive the message and send to
>> > another random process. This should happen until the requested number of
>> > messages to be sent is done, which is given by the user as input. I see
>> > that
>> > my program is either sending messages at the max 2 or else even none and
>> > giving me the following error
>> >
>> > ONE OF THE PROCESSES TERMINATED BADLY: CLEANING UP
>> > APPLICATION TERMINATED WITH THE EXIT STRING: Terminated (signal 15)
>> >
>> >
>> > Here is my code, lemme know whats the loop hole in it. The random
>> > generation
>> > part is not included, which is working fine
>> >
>> >
>> >     if(rank==0)
>> >     {
>> >     rnum=rgenerator(rank,size);
>> >     string++;
>> >     MPI_Send(&string, 50, MPI_INT, rnum, rnum, MPI_COMM_WORLD);
>> >     printf("\n process %d sends message to process %d",rank, rnum);
>> >
>> >     //MPI_Recv(&flag, 100, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG,
>> > MPI_COMM_WORLD, &status);
>> >
>> >     }
>> >
>> >         while(flag!=1)
>> >         {
>> >
>> >         if(MPI_Recv(&string, 50, MPI_INT, MPI_ANY_SOURCE, rank,
>> > MPI_COMM_WORLD, &status)==MPI_SUCCESS)
>> >         {
>> >
>> >             printf("\n process %d receives message from process %d count
>> > :
>> > %d",rank, status.MPI_SOURCE, string);
>> >             rnum=rgenerator(rank,size);
>> >             printf("\n Random num generated is %d",rnum);
>> >             string=string+1;
>> >             MPI_Send(&string, 50, MPI_INT, rnum, rnum, MPI_COMM_WORLD);
>> >             count++;
>> >
>> >             printf("\n process %d sends message to process %d", rank,
>> > rnum);
>> >
>> >             //MPI_Bcast(&count, 40, MPI_INT, rank, MPI_COMM_WORLD);
>> >             if(string==n)
>> >             {
>> >                 printf("\n\n Messages reached");
>> >                 flag=1;
>> >
>> >             }
>> >
>> >         }
>> >         else
>> >             flag=0;
>> >         }
>> >
>> >
>> >
>> >
>> > thank you.
>> >
>> > _______________________________________________
>> > mvapich-discuss mailing list
>> > mvapich-discuss at cse.ohio-state.edu
>> > http://mail.cse.ohio-state.edu/mailman/listinfo/mvapich-discuss
>> >
>> >
>>
>> Note that the only process that will be exiting is the one that sends
>> when string == n. All the other processes will keep on executing the
>> program because they will not find the condition string == n, as
>> string continues to be incremented.
>>
>> I think that an exit condition such as string >= n will do, but you
>> need to be aware of the exiting processes in order to avoid sending
>> data to anyone of them.
>>
>> Regards,
>>
>> --
>> ---------- .-
>> VERCELLONE, Juan.
>> (also known as 1010ad1c97efb4734854b6ffd0899401)
>
>

You may also need to check why the MPI_Send and MPI_Recv are sending
50 integers of data.
Is every sending/receiving buffer previously allocated?

-- 
---------- .-
VERCELLONE, Juan.
(also known as 1010ad1c97efb4734854b6ffd0899401)



More information about the mvapich-discuss mailing list