On May 20, 2014, at 6:33 AM, Anton Shterenlikht <[log in to unmask]> wrote:
> Apologies if you have seen this already on comp.lang.fortran.
>
> For this code:
>
> integer :: x(10)[*], imgs, i
> imgs = num_images()
> x = this_image()
> sync all
> if ( this_image() .eq. 1 ) then
> do i=1,imgs
> x = x(:)[i]
> x(:)[i] = x
> end do
> end if
> end
>
> I got a comment from an Intel person that:
>
> "The problem here - CAF remote reads/writes are
> inherently asychronous or 1-sided.
> So the value of X from the read may not have been
> completed by the time you use X in the next statement
> on the RHS of the assignment.
> So the results are unpredictable." [1]
This is not correct.
Remote references and definitions are “1-sided” in the sense that there are no statements executed on the remote image as part of the action. I think the term “asynchronous” could be confusing here. Implementations are allowed to use non-blocking transfers as long as they later wait when completion is required by the language semantics. Within an image, statements are still required to execute “as if” they are executed in the indicated order. I don’t see any problem with the code above. In particular, the assignment sequence
x = x(:)[i]
x(:)[i] = x
is required to execute as if the first statement completed (and the local X is fully defined) before the second one starts. A particularly clever optimizer could deduce that the second statement has no real effect and delete it. But you should not be able to detect this - only that the final value of X on image 1 has the value of imgs in each element. (You should print that out as a test. Otherwise, the compiler could delete the entire code as doing nothing.)
>
> However, my understanding of the standard is
> different. Since the remore read and write
> statements appear in the same segment, they
> must be executed in order, i.e. remote read
> must complete before remote read starts.
>
> I do indeed get strange results with the Intel
> compiler with this code. I haven't got access
> to a Cray system at present, so cannot check.
It works fine on the Cray I tested. The second version (that includes the SYNC ALL before the IF) from the Intel forum discussion noted below also works fine. That SYNC ALL is needed.
Cheers,
Bill
>
> Can anybody comment please
>
> Thanks
>
> Anton
>
> [1] https://software.intel.com/en-us/forums/topic/489052
Bill Long [log in to unmask]
Fortran Technical Suport & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101
|