Newsgroups: comp.parallel.mpi
From: gropp@godzilla.mcs.anl.gov (William Gropp)
Subject: Re: collective communications
Organization: MCS, Argonne National Laboratory
Date: Mon, 23 Sep 1996 14:56:54 GMT
Message-ID: <843490614747@godzilla.mcs.anl.gov>

In article <51s1sl$1rpg@www.univie.ac.at>,
 <hejc@apap2.pap.univie.ac.at> wrote:
>I have a question about collective communications and
>what is meant by matching arguments in that case:
>
>Source code example:
> int a;
> int *b;
> int rank;
> ...
> MPI_Comm_rank( MPI_COMM_WORLD, &rank );
> if( rank == 0 )
>    {
>    b = (int *)malloc( 100 * sizeof( int ));
>    }
> MPI_Gather( &a, 1, MPI_INT, b, 100, MPI_INT, 0,
>             MPI_COMM_WORLD );
> ...
>Is this code correct or not in the sense of portability?
>Collective communications must have matching arguments
>for all processes in the communicator given to them.
>The pointer b has only a valid address for process 0, for all
>other processes it is a NULL pointer. 
>Should a portable code better use 
> int b[100];
>instead of a pointer, which points to a valid memory address 
>only for the process who receives the data. 

The standard specifically states that the receive fields (recvbuf, 
recvcount, recvtype) are significant only at root.  An implementation 
should allow any values for these arguments at non-root processes.

Bill

