From owner-sc22wg5@open-std.org  Thu Jan 22 22:14:04 2009
Return-Path: <owner-sc22wg5@open-std.org>
X-Original-To: sc22wg5-dom7
Delivered-To: sc22wg5-dom7@www2.open-std.org
Received: by www2.open-std.org (Postfix, from userid 521)
	id 80C62CA5FED; Thu, 22 Jan 2009 22:14:04 +0100 (CET)
X-Original-To: sc22wg5@open-std.org
Delivered-To: sc22wg5@open-std.org
Received: from mail.jpl.nasa.gov (sentrion2.jpl.nasa.gov [128.149.139.106])
	by www2.open-std.org (Postfix) with ESMTP id 6192DCA5FE6
	for <sc22wg5@open-std.org>; Thu, 22 Jan 2009 22:14:02 +0100 (CET)
Received: from mprox2.jpl.nasa.gov (mprox2.jpl.nasa.gov [137.78.160.141])
	by mail.jpl.nasa.gov (Switch-3.3.2mp/Switch-3.3.2mp) with ESMTP id n0MLDUSh026272;
	Thu, 22 Jan 2009 21:13:30 GMT
Received: from [137.79.7.57] (math.jpl.nasa.gov [137.79.7.57])
	(authenticated bits=0)
	by mprox2.jpl.nasa.gov (Switch-3.2.6/Switch-3.2.6) with ESMTP id n0MLDS0a029884
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT);
	Thu, 22 Jan 2009 13:13:28 -0800
Subject: Re: [ukfortran] (SC22WG5.3880) (j3.2006) [MPI3	Fortran]	MPI
	non-blocking transfers
From: Van Snyder <Van.Snyder@jpl.nasa.gov>
Reply-To: Van.Snyder@jpl.nasa.gov
To: "N.M. Maclaren" <nmm1@cam.ac.uk>
Cc: WG5 <sc22wg5@open-std.org>
In-Reply-To: <Prayer.1.3.1.0901221006510.28472@hermes-2.csi.cam.ac.uk>
References: <Prayer.1.3.1.0901211104060.5654@hermes-2.csi.cam.ac.uk>
	 <49776DF7.1040900@cray.com> <20090121211748.130A5C178D9@www2.open-std.org>
	 <20090121224014.6CB63C178D9@www2.open-std.org>
	 <20090121234200.4F3BDCA3434@www2.open-std.org>
	 <20090122000407.D5A8ECA3434@www2.open-std.org>
	 <Prayer.1.3.1.0901221006510.28472@hermes-2.csi.cam.ac.uk>
Content-Type: text/plain
Organization: Yes
Date: Thu, 22 Jan 2009 13:13:26 -0800
Message-Id: <1232658808.15119.824.camel@math.jpl.nasa.gov>
Mime-Version: 1.0
X-Mailer: Evolution 2.12.3 (2.12.3-8.el5_2.3) 
Content-Transfer-Encoding: 7bit
X-Source-IP: math.jpl.nasa.gov [137.79.7.57]
X-Source-Sender: Van.Snyder@jpl.nasa.gov
X-AUTH: Authorized
Sender: owner-sc22wg5@open-std.org
Precedence: bulk


On Thu, 2009-01-22 at 02:06 -0800, N.M. Maclaren wrote:
> 
> >Does the problem arise because the buffer doesn't appear as an actual
> >argument in the call to the MPI wait routine, or is there another cause
> >for it?
> 
> There is another, more important, reason.
> 
> It is critical that the buffer is not moved or accessed by copy-in/copy-out
> between the initiation of the transfer and the wait.  The first could apply
> with a compacting garbage collector, for example.  The second is not JUST
> explicit argument passing, but includes compiler-generated procedure calls
> and (as I said) even open code in some implementations.
> 
> That is why a buffer and all 'active' associated entities must be marked as
> ASYNCHRONOUS or equivalent for the whole of that period.

Yes, that's what the ASYNCHRONOUS attribute is for, but if a variable
with the ASYNCHRONOUS attribute doesn't appear, the compiler can't know
not to do something in a context where it might nonetheless be affected
in the ways you describe.

> >Assuming the problem is caused by the buffer not appearing as an actual
> >argument, it's not a defect in Fortran but rather in the design of MPI.
> 
> If that were the whole problem, it would be.  It would also be a defect in
> the design for the Fortran WAIT statement.

Fortran understands the semantics of its WAIT statement, but doesn't
understand the semantics of the MPI wait procedure or MPI handles.  It
can't know that it shouldn't fiddle with the buffer if it or a subobject
of it doesn't appear.  If its address is hiding inside of an MPI handle,
there's no way Fortran will know that.

> >One simple step toward solving the problem is to write an extra
> >interface layer that includes the argument, which then calls the real
> >MPI wait routine, not passing that argument.  Then declaring the buffer
> >and the dummy argument of the wait routine interface layer to be
> >ASYNCHRONOUS ought to work, according to the rules we already have in
> >place for Fortran asynchronous I/O.
> 
> That is the solution which I thought about some time ago, and came to the
> conclusion "don't start from here".

That's too vague to draw any conclusions.  So far, in all my
consideration of this matter, it seems to be the only solution that
works, without enormous amounts of magic that would probably violate
Resolution T7.

-- 
Van Snyder                    |  What fraction of Americans believe 
Van.Snyder@jpl.nasa.gov       |  Wrestling is real and NASA is fake?
Any alleged opinions are my own and have not been approved or
disapproved by JPL, CalTech, NASA, the President, or anybody else.

