(j3.2006) Pure subroutine musings

Anton Shterenlikht mexas
Tue Aug 22 07:24:22 EDT 2017


On Tue, Aug 22, 2017 at 07:35:38PM +0900, Malcolm Cohen wrote:
> I do not agree with your analysis.  My example would seem to be harmless inside a DO CONCURRENT as no image reads data written by another image.  It?s certainly true that the rest of the DO CONCURRENT cannot then read that data, unless each image reads ?next_image?s? data ? that would not violate the segment rules.  But DO CONCURRENT does not prohibit reading or writing coindexed objects, so you can violate the segment rules there easily, you don?t need pure procedures to do that!
> 
> Anyway, my point was that this constraint does not help.  A pure subroutine can define a coarray, and on another image can read from that coarray!
> 
> That is,
> 
> Example 1: prohibited
>    coarray[1] = 2
> with
>    x = coarray
> 
> Example 2: permitted
>    coarray = 2
> with
>    x = coarray[1]
> 
> The exact same ?possible cross-image communication? is occurring here.  The exact same ?possible segment rule violation? occurs here.  It makes no sense to prohibit (1) and not prohibit (2).  (In fact, I don?t see the reason for prohibiting either ? we trust users to get the indexing right when they define elements of arrays in different pure procedure executions, why don?t we trust them to get the coindexing right when they define coelements of coarrays in different pure procedure executions?)

Ok, I get you now.
Yes, it doesn't seem to make sense
to allow one but prohibit another.
You know the history better than me -
perhaps C1593 was meant to prohibit
both cases, but the language is not quite right?
Are there any parallel performance implications
of allowing case 1? 

> BTW you are quite wrong about PURE procedures, they were added in Fortran 95, DO CONCURRENT did not come along until Fortran 2008.  So analysing PURE only in terms of DO CONCURRENT is taking a very small view.  PURE work hand-in-hand with ELEMENTAL (and FORALL too).  So they are a tool for parallel evaluation in general.

sure, "parallel evaluation in general",
but FORALL is obsolescent in f2015,
and C1599 prohibits coarray dummy arguments
in ELEMENTAL procedures,
(I think your original post said that
only coarray dummy arguments are being discussed)
so I think DO CONCURRENT is the most
important usage area for PURE procedures.

Anton



More information about the J3 mailing list