RFC patch: Dependency/alias analysis wir same-image coarray access

Tobias Burnus burnus@net-b.de
Wed Aug 27 06:42:00 GMT 2014


Hi all,

it turned out that one has to be careful with the coarray assignment to 
the same variable such as:
   a(:)[this_image()] = a(:)
Seemingly, MPI_Get/MPI_Put do not like that at all; for that case (and 
this_image() == requested image index), one can escape by using memmove, 
which handles overlaps. As this primarily hinges on this_image() == 
image index, I think it can be handled directly in the library.

However, for code like
   a(n:1:-1)[1] = a(1:n:1)
one needs in general a temporary.

RFC questions:
a) Does it make sense to pass this information to the library? Or should 
the library check itself whether there is an overlap, requiring the use 
of a temporary.

b) What information should the compiler provide?
- It can test whether two variables / derived-type components used in 
expressions may alias or not. (Works reliable, except that for pointers 
one errs on the side of aliasing).
- It can additionally check whether array references are overlapping, 
i.e. a(1:4) and a(6:5) refer to the same variable but do not overlap - 
when that's detectable at compile time; same for a(1::2) and a(2::2).
- It can tell whether the the overlap is identical (a(1:2) = a(1:2)), 
possible without temporary when assigning up or downward (e.g. a(1:5) = 
a(2:6) vs. a(2:6) = a(1:5)).


Thus, the question is whether the library should take care of all alias 
analysis itself or whether the compiler should provide additional 
information; and if the latter, what properties should be passed to the 
library. (The check whether the passed image index refers to the current 
image or not, is in any case responsibility of the library.)

Comments, suggestions?

The attached patch sets the variable to "true", if walking in array 
order, could lead to the requirement for a temporary.
  That is: It is false for identical sections "A(:)[i]=A(:)", for 
nonoverlapping ones "A(1:5)[i]=A(6:10)" but also for forward walking 
ones such as "A(1:3)[i] = A(3:5)". But it is true for backward access 
such as "A(3:1:-1)[i] = A(5:3:-1)" - and when it is not determinable at 
compile time (pointer aliasing, unknown array indexes etc.) Does that 
version make sense?

Note: The .texi wording would have to be tuned. Additionally, be careful 
with applying the patch as the line numbers are off and due to diff -U0, 
"patch" won't be able to correct this.

Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rfc.diff
Type: text/x-patch
Size: 13958 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20140827/d7baf5fe/attachment.bin>


More information about the Fortran mailing list