sourceryinstitute / OpenCoarrays

A parallel application binary interface for Fortran 2018 compilers.
http://www.opencoarrays.org
BSD 3-Clause "New" or "Revised" License
243 stars 58 forks source link

Defect: Remote Image Accessing Causes Data Shift #738

Open evansste12432 opened 2 years ago

evansste12432 commented 2 years ago

System information including:

To help us debug your issue please explain:

What you were trying to do (and why)

I'm trying to transfer a matrix from one coarray image, to another.

I wrote a parallel program that is designed to sort data sets and build an array of numbers. Those numbers are based on similarities in the sets that it processes. The resulting array will be used for further analysis in another program.

What happened (include command output, screenshots, logs, etc.)

During the gathering portion of the program, which collects information from different images, the program behaves unexpectedly. When reading information from other images, the program seems to shift the data, to the left, by one column. For example, in my program, a similar command like this: newplace = oldplace(:,:)[3] will put oldplace(:,2:)[3] into newplace, with unexpected, strange numbers in the right-most column.

I wrote a similar program that is supposed to print out nine rows of 1-4. The following link shows a screenshot of what is printed out, instead, when that program is run:

http://boolengine.com/badindex_output.png

What you expected to happen

I expected the program to copy the data to the targeted image without shifting it, and therefore print out nine rows of 1-4.

Step-by-step reproduction instructions to reproduce the error/bug

My shorter program is shown below. If you compile and run it, it will produce the shifted result that I'm talking about. If you run the program with 3 cores, it will produce the result that is shown in the screenshot, above.

Here is that program:

`program badindex use iso_fortran_env

implicit none

integer, dimension(:,:), codimension[:], allocatable :: drop
integer, dimension(:,:), allocatable :: A, intermediate
integer, codimension[*], save :: here, tohere
integer :: n, height, width, dropheight

width = 4
dropheight = 3
height = dropheight*num_images()
allocate(A(height,width))
allocate(drop(dropheight,width) [*])
drop = 0
A = 0

here = (this_image()-1)*dropheight+1
tohere = this_image()*dropheight    

do n = 1,dropheight
    drop(n,:) = [1, 2, 3, 4]
end do
sync all

if (this_image() == 1) then
    do n = 1,num_images()
        intermediate = drop(:,:)[n]
        A(here[n]:tohere[n],:) = intermediate           
    end do
end if
sync all

if (this_image() == 1) then
    do n = 1,height
        print *, A(n,:)
    end do
end if

end program badindex`