[mpiwg-rma] Memory model and source code portability

Rolf Rabenseifner rabenseifner at hlrs.de
Tue Sep 30 11:23:18 CDT 2014


The follwing discussion is (partially) independent from RMA.
The example is about MPI_Irecv and MPI_Wait.

> Comment (by gropp):
> 
>  I fully agree with Dave.  As I've said before, MPI should only talk about
>  MPI.  What the compiler might to with non-MPI is not in scope for us.
>  Yes, this makes it difficult to provide examples that are guaranteed to
>  work; that's part of the point of Boehm's article.  But that doesn't
>  change the fact that the MPI Forum must not specify the behavior of C (or
>  Fortran) codes that happen to be accessing shared memory.
> 
> --
> Ticket URL:
> <https://svn.mpi-forum.org/trac/mpi-forum-web/ticket/456#comment:16>


For me it looks like that you give up with the important goal
that the MPI standard should provide source code portability.

I mean source code portability for MPI applications written in 
one of the supported language bindings.

For me, the MPI standard has to specify all that is needed that
a source code that is consistent with the MPI standard is 
portable from one MPI library with companion compiler 
to another MPI library with its companion compiler.

With MPI-3.0 and the new Fortran interface, 
we tried to achieve this goal. Maybe that further
investigation is needed.

People always thought that there is no such problem with C.

MPI-3.0 Section 17.1.20 "Comparison with C" tries to say this.

As I learned in this discussion, such expectation about 
brave C is completely wrong, as seen in 
https://svn.mpi-forum.org/trac/mpi-forum-web/ticket/456#comment:13

There is no source code portability for the MPI C Interface
if C = C99 or older:
 
Such a small code

  for(...)
  {
    MPI_Irecv(&buf,...,&rq)
    MPI_Wait(&rq,...)
    print(...) buf
  }

may be compiled by C99 (not C11) into

  reg0=buf;
  for(...)
  {
    buf=reg0;
    MPI_Irecv(&buf,...,&rq)
    reg0=buf;

    buf=reg0;
    MPI_Wait(&rq,...) with internally: buf=received_value
    reg0=buf;

    print(...) reg0
  } 
  buf=reg0;

And with an MPI library making progress between MPI_Irecv and MPI_Wait,
the outcome may be

  reg0=buf;
  for(...)
  {
    buf=reg0;
    MPI_Irecv(&buf,...,&rq)
    reg0=buf;

    with internally by the MPI lib progress engine: 
    buf=received_value

    buf=reg0;  /* i.e. the received value is 
                  overwritten by the old value!!! */ 
    MPI_Wait(&rq,...) 
    reg0=buf;

    print(...) reg0
  } 
  buf=reg0;

Or in other words, according to
 - MPI-3.0 Section 17.1.20, and
 - https://svn.mpi-forum.org/trac/mpi-forum-web/ticket/456#comment:13
already MPI-1.1 for C required the C11/C11++ memory model, 
which does not allow such optimizations.

This has direct influence on the wording we use in MPI-3.0 Section 2.6.

Saying "ISO C is enough" is outdated, i.e., closing the eyes 
in front of the knowledge that exists.

I would like that the MPI Forum gets this right, in C and Fortran.

Rolf



-- 
Dr. Rolf Rabenseifner . . . . . . . . . .. email rabenseifner at hlrs.de
High Performance Computing Center (HLRS) . phone ++49(0)711/685-65530
University of Stuttgart . . . . . . . . .. fax ++49(0)711 / 685-65832
Head of Dpmt Parallel Computing . . . www.hlrs.de/people/rabenseifner
Nobelstr. 19, D-70550 Stuttgart, Germany . . . . (Office: Room 1.307)



More information about the mpiwg-rma mailing list