LAM/MPI logo

LAM/MPI General User's Mailing List Archives

  |   Home   |   Download   |   Documentation   |   FAQ   |   all just in this list

From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2005-06-30 20:07:00


This is true that the problem a) violates MPI and b) completes
"successfully" in LAM (and other MPI implementations). In this case,
the program is erroneous, and its behavior is undefined. Hence, the
standard says that the MPI implementation is free to do whatever it
wants (complete "successfully" in this case). This program is a bit of
an exception -- it will usually give the answer that you expect, at
least with LAM's implementation. But that is not always the case when
aliasing like this -- concurrently sending and receiving from the same
buffer may give nondeterministic results.

As for whether LAM should display a warning/error, sure, in a perfect
world. So should other MPI's (LAM is not alone in not displaying this
as an erroneous program). :-) But MPI implementations are judged on
latency, so we do *some* checking, but not *all possible* checks. This
is, unfortunately, simply not one of the checks that we look for.

On Jun 30, 2005, at 7:43 PM, Anthony Chan wrote:

> While porting some profiling libraries to LAM/MPI, I notice the
> following C program is able to run and finish without any error
> under LAM/MPI-7.1.2b22.
>
> *****************************************************
> #include "mpi.h"
> #include <stdio.h>
>
> int main( int argc, char *argv[] )
> {
> int rank, size;
> int namelen;
> char processor_name[MPI_MAX_PROCESSOR_NAME];
>
> MPI_Init( &argc, &argv );
> MPI_Comm_size( MPI_COMM_WORLD, &size );
> MPI_Comm_rank( MPI_COMM_WORLD, &rank );
> MPI_Get_processor_name( processor_name, &namelen );
>
> fprintf( stdout,"Process %d on %s\n", rank, processor_name );
>
> /* The following MPI call violates MPI-1.1, section 2.2 */
> MPI_Allreduce( &rank, &rank, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD );
>
> fprintf( stdout, "Maximum rank is %d\n", rank );
>
> MPI_Finalize();
> return 0;
> }
> *****************************************************
>
> The way the send(IN) and receive(OUT) buffers is used in MPI_Allreduce
> in the sample code violates MPI-1.1, section 2.2, or
> http://www.mpi-forum.org/docs/mpi-11-html/node10.html#Node10
> Since the standard prohibits aliasing of arguments, should LAM/MPI
> signal
> this as an error ?

-- 
{+} Jeff Squyres
{+} jsquyres_at_[hidden]
{+} http://www.lam-mpi.org/