From bleikamp@mozart.convex.com  Wed Apr 17 22:55:48 1996
Received: from convex.convex.com (convex.convex.com [130.168.1.1]) by dkuug.dk (8.6.12/8.6.12) with ESMTP id WAA23603 for <sc22wg5@dkuug.dk>; Wed, 17 Apr 1996 22:55:27 +0200
Received: from mozart.convex.com by convex.convex.com (8.6.4.2/1.35)
	id PAA09167; Wed, 17 Apr 1996 15:56:04 -0500
Received: from localhost by mozart.convex.com (8.6.4/1.28)
	id PAA15835; Wed, 17 Apr 1996 15:53:20 -0500
From: bleikamp@mozart.convex.com (Richard Bleikamp)
Message-Id: <199604172053.PAA15835@mozart.convex.com>
Subject: Re: (SC22WG5.1067) Question on Implementation Benefits of Fortran POINTER Feature
To: Craig.Dedo@mixcom.com (Craig Dedo)
Date: Wed, 17 Apr 96 15:53:19 CDT
Cc: sc22wg5@dkuug.dk
In-Reply-To: <199604171915.VAA22780@dkuug.dk>; from "Craig Dedo" at Apr 17, 96 1:19 pm
X-Mailer: ELM [version 2.3 PL11]

'Craig Dedo' wrote:
> 
> Dear Members of the WG5 Mailing List:
>     The past week or so people have asked me to explain the implementation 
> benefits of the Fortran POINTER feature, especially as compared to the pointer 
> facilities of C and C++.  I do not have a clear idea as to what the advantages 
> are and I would like to give some intelligent answers to these questions.
> 
>     - Why is it necessary for a target of a pointer to have either the POINTER
> or TARGET attribute?

This tells the optimizer what possible aliasing exists.  By restricting
aliasing, the optimizer can do a better job of:
  - leaving values in registers instead of always storing and reloading from
    memory
  - vectorizing and parallelizing loops.  If the optimizer can't tell if there
    are any overlaps between the objects assigned and referenced, in a loop,
    it cannot safely vectorize or parallelize the loop.  Lack of good
    aliasing information would effectively mean that any use an object
    which "might" be a TARGET would inhibit many optimizations.

> 
>     - What kinds of optimizations can you do with Fortran POINTERs that is 
> either difficult or impossible with either C or C++?

Mostly those described above.  In addition, the "type safeness" of Fortran
pointers allows more alias analysis than "old" C, although I think ANSI C
may have addressed some of this, particularly with restricted pointers.


>     - How does the way that the Fortran pointer facility is defined make 
> implementation easier than with other types of pointer models?

It doesn't.  It makes the users life safer, mostly.  And easier
once they discard the "C" notion of what a pointer is.  Arrays are one of
Fortrans best features, and one of C's worst.  So Pointers to arrays in
fortran works well.  Not so in C.  

> 
>     - How does the way that the Fortran pointer facility is defined make 
> implementation more difficult than with other types of pointer models?

Lots more information is carried around, a fairly large descriptor, which
is why assumed shape arrays work pretty nice.

> 
>     - Can anyone recommend any good references that I might read that will 
> explain these issues in more detail?  Remember, I am NOT an implementor and I 
> do NOT have any training in compiler technology.

I don't know of any.

> 
>     I have been invited to give a talk to a group of graduate students at the 
> University of Wisconsin-Madison on May 2.  These students are specializing in 
> programming languages and compilers and want to know about various technical 
> issues with respect to Fortran.  I KNOW that these questions will come up and 
> I would like to be prepared.

If they are all C users, then the whole concept of Fortran pointers will
seem very bizarre to them.  Such is life.

