On 2013-07-23 3:17 PM, Ian Harvey wrote:
> On 2013-07-23 1:44 PM, Richard Maine wrote:
>> Ian Harvey <
ian_h...@bigpond.com> wrote:
>>
>>> A question out of gross ignorance...
>>>
>>> For non-atomic things, F2008 says "if a variable is defined on an image
>>> in a segment, it shall not be referenced, defined or become undefined in
>>> a segment on another image unless the segments are ordered."
>>>
>>> Is "variable" considered at the highest level of the object - subobject
>>> "tree", or the lowest level? For example - can you define element i of
>>> an array that is a coarray on one image and element i+1 on another image
>>> without requiring segment ordering?
>>
>> I really know nothing of note about coarray stuff, but I do claim to be
>> able to read standard-speak, so based on that alone...
>>
>> It would apply to all "levels". If X is an array, then doing
>>
>> x(1) = 1
>>
>> defines the variable x(1), but it *ALSO* (partially) defines the
>> variable x. So the restriction would apply to both x(1) and x. It would
>> seem that the restriction on x(1) is redundant, but that's ok. I'd still
>> think that both restrictions apply.
>>
>> Whether that's what was intended for the coarray stuff, I couldn't tell
>> you. But that's how I read the words as you cited them. If that's not
>> what was intended, then those words probably shouldn't say it that way.
Ok... now reading N1824 from the NAG site "Coarrays in the next Fortran
Standard" by John Reid, I now wonder what was intended. On page 17, in
the context of a discussion on the restriction above it says...
It follows that for code in a segment, the compiler is free to
use almost all its normal optimization techniques as if only
one image were present. In particular, code motion optimizations
may be applied, provided calls of atomic subroutines are not
involved. For an example of an optimization that is not
available, consider the code
integer (kind=short) x(8)[*]
:
! Computation that references and alters x(1:7)
Because another image might define x(8) in a segment that is
unordered with respect to this one, the compiler must not
effectively make this replacement:
integer (kind=short) x(8)[*], temp(8)
:
temp(1:8) = x(1:8) ! Faster than temp(1:7) = x(1:7)
! Computation that references and alters temp(1:7)
x(1:8) = temp(1:8)
This implies to me that the author had the expectation that you could
merrily play away with unique subobjects across images.
That would seem to be a bit tricky for processors in terms of the need
to track modifications to subobjects of a coarray on an image by all
images and then splice those changes back in - what if x was
CHARACTER(100000) and during execution of a segment we modified
characters at positions 2, 3, 5, 7, 11, 13, 17, ... etc on one image and
characters at positions 1, 4, 9, 16, 25, ... on another unordered image.
(While on the topic of coarrays - if you want to use coarrays with
polymorphic components you appear to be completely and utterly sunk. If
my understanding is correct that's a pretty major feature omission! Is
my understanding correct? If so, has anyone got ideas on how to work
around this?)