Newsgroups: comp.parallel.mpi
From: llewins@msmail4.hac.com (Lloyd J Lewins)
Subject: Re: Why MPI_ADDRESS?
Organization: Hughes Aerospace Electronics Co.
Date: 9 May 1996 17:31:43 GMT
Message-ID: <llewins-0905960928050001@x-147-17-222-212.es.hac.com>

In article <318F55F1.41C6@gmd.de>, Erik <erik.brakkee@gmd.de> wrote:

> What exactly is the purpose of MPI_ADDRESS?
> 
> I have been reading the MPI-1 report and stumbled
> on a remark on page 68 (Advice to Users, MPI_ADDRESS).
> 
> I don't see the problem with using the '&' operator
> in C. In ANSI-C pointers are just abstract pointers
> to memory locations which cannot be interpreted as
> memory addresses. Only the difference between
> pointers can be interpreted as a relative address
> (only within an array or structure).

The point of MPI_Address is that it generates the "displacement" of the
variable from MPI_BOTTOM in some notional linear space.

If the machine actually uses a segmented address space, I have no idea how
the implementation maps that into a linear address space, but that's its
problem not mine.

I guess the implementation might know about every relevant segment, and could
logically contatenate them into a notional linear space. However, if segments
were dynamic this would be difficult.

In the book "MPI the Complete Reference", by Snir et al., the authors
suggest another reason for MPI_Address, which is that pointers to
different types of
objects may use different representations, e.g., a pointer to a byte may
be a byte address, while a pointer to a word may be a word address. Thus,
in a 32 bit machine, one would have to multiply a word pointer by 4 to get
a byte displacement. Unfortunately, it is not clear how MPI_Address could
acheive this since it doesn't know the type of the object pointed at by
the pointer!!

> 
> The advantage of using absolute addresses to 
> represent derived data types (paragraph 3.12.2)
> is dubious, since would allow us to send or receive
> instances of such datatypes without passing the
> storage for it to MPI. This is a very dangerous way of
> operating because it assumes that memory locations of
> variables are constant during computation. I wonder if
> this is always true.
> 
> Does this hold for local variables of functions
> between consecutive function calls? And how about
> the case when the system performs swapping during
> computation?
> 

Correct, there are problems with the use of absolute addresses. Certainly
local variables move around, hence it would be unsafe to take the absolute
address of one, and use that during a later call of the function. Its the
same problem as assigning a global pointer to a local variable.

If the system performs swapping, while that may change the physical address
of the location, the virtual address should remain constant, and shouldn't
cause any problems.

If the virtual address of static variables (or local variables during a
function call) changed, the C language would have a hard time keeping the
pointers consistent. It would have to be able to keep track of every
pointer to an object, and update that pointer with the new address. Not a
very likely scenario.

Other problems occur with ensuring that the compiler doesn't optimize accesses
to the variable, around a the call to MPI_Recv which uses the absolute
address.

> So what is the purpose of MPI_ADDRESS besides 
> providing pointer functionality in FORTRAN? 
> 
> Sincerely,
>   Erik
> 
> ===============================================
> Erik Brakkee
> GMD/SCAI, Schloss Birlinghoven      
> D-53754 Sankt Augustin, Germany  
> E-mail: erik.brakkee@gmd.de

--------------------------------------------------------------------------
Lloyd J Lewins                                  Mail Stop: RE/R1/B507
Hughes Aircraft Co.                             P.O. Box 92426
                                                Los Angeles, CA 90009-2426
Email: llewins@msmail4.hac.com                  USA
Tel: 1 (310) 334-1145
Any opinions are not neccessarily mine, let alone my employers!!

