[OpenCoarrays] RFC patch: Dependency/alias analysis wir same-image coarray access
Alessandro Fanfarillo
alessandro.fanfarillo@gmail.com
Wed Aug 27 16:08:00 GMT 2014
The compiler participation could be useful for performance purposes.
The idea is:
1) the library checks if source and destination are the same and if
the compiler finds an aliasing.
2) If the compiler does not find anything, the library just applies memmove.
3) If the compiler find an aliasing, the library does not do anything.
On Wed, Aug 27, 2014 at 12:42 AM, Tobias Burnus <burnus@net-b.de> wrote:
> 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
>
> --
> You received this message because you are subscribed to the Google Groups
> "OpenCoarrays" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to opencoarrays+unsubscribe@googlegroups.com.
> Visit this group at http://groups.google.com/group/opencoarrays.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/opencoarrays/53FD7DDA.4020808%40net-b.de.
> For more options, visit https://groups.google.com/d/optout.
--
Alessandro Fanfarillo
More information about the Fortran
mailing list