Skip to content

gfortran 7 regression: no type conversion before coarray put #292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rouson opened this issue Dec 21, 2016 · 11 comments · Fixed by #468
Closed

gfortran 7 regression: no type conversion before coarray put #292

rouson opened this issue Dec 21, 2016 · 11 comments · Fixed by #468

Comments

@rouson
Copy link
Member

rouson commented Dec 21, 2016

This issue is for tracking gfortran bug report 78892, which was first reported in an OpenCoarrays mailing list message. The gfortran bug report contains the following text:

The code below demonstrates a regression in which gfortran 7.0.0 20161215 is not performing a necessary implicit type conversion before putting data on a remote image.  By contrast, the code below works as expected with gfortran 5.4.0 and 6.2.0. 

$ cat convert-before-put.f90 
  real :: a[*]
  integer :: receiver
  associate(me=>this_image())
    if (me == 1) then
      do receiver = 2, num_images()
        a[receiver] = receiver ! implicit real(receiver) needed here
        sync images (receiver) ! notify remote image that data has been put
      end do 
    else
      sync images (1) ! await notification of data put by image 1
      if (a/=real(me)) print *, "Image ",me,": received ",a,", but expected ",real(me)
    end if
  end associate
end 

$ caf convert-before-put.f90 

$ cafrun -np 2 ./a.out
 Image            2 : received    0.00000000     , but expected    2.00000000
@rouson
Copy link
Member Author

rouson commented Dec 22, 2016

Tagging @egiovan to include him in the thread.

@vehre
Copy link
Collaborator

vehre commented Dec 22, 2016

I still have to analyse this in-depth: But I am pretty sure, that the responsibility for the type-conversion is in the caf-library. There are convert-type routines that do the trick. In the put case gfortan might be able to do the type convert, but in the get case it can't. Therefore is it arguable that the responsibility is always with the library to be consistent.

@vehre
Copy link
Collaborator

vehre commented Dec 22, 2016

At the moment I am adding pointer component support for derived typed coarrays, so please give a bit time to take a look.

@rouson
Copy link
Member Author

rouson commented Dec 22, 2016

@vehre, whichever side is responsible, this is a regression from the behavior with gfortran 5 and 6. In the interest of consistency, I assume it's best to keep the responsibility wherever it was prior to gfortran 7 unless there is a strong motivation for changing it. Just so we know how to assign this issue, please confirm whether you wrote the relevant library code that gets invoked when this example is compiled or whether @afanfa wrote it?

@vehre
Copy link
Collaborator

vehre commented Dec 29, 2016

I just have rejected the pr in the gcc-bugtracker, because the responsibility for the type conversion was moved to the library. This way the library has the opportunity to reduce the number of bytes to transfer between the images where applicable. When the compiler does the type conversion, always the destination data type is used. With arrays this means the compiler generates a type conversion loop and the library "loops" again over the data to transfer it (I know you are using chunks and MPI-Datatypes to prevent single item transfer). Nevertheless the responsibility has been moved to the library. The conversion routine is already present (the _by_ref routine convert) so that it just needs to be called in the "old" communication primitives.

I am starting to implement it. Maybe @afanfa can check, that I don't mess up the performance completely.

@vehre
Copy link
Collaborator

vehre commented Sep 10, 2017

The branch vehre/issue-292-type-conversion-during-communication has a preliminary version of a possible fix. It fixes the type conversion before put as long as the dest is contiguously addressed.
Not type conversion support for sendget() and get() yet.

@rouson
Copy link
Member Author

rouson commented Sep 10, 2017

Thanks, @vehre ! Is there any chance you can join the Tuesday call this week to discuss this?

@vehre
Copy link
Collaborator

vehre commented Sep 11, 2017 via email

@rouson
Copy link
Member Author

rouson commented Nov 8, 2017

@vehre Please let us know if you'll have time to work on this soon. @zbeekman and I started work on new contract last month that requires the use of GCC 7. Fortunately, the project doesn't yet use coarrays, but coarrays will be a consideration later in the project so it would be great to get this issue resolved.

@vehre
Copy link
Collaborator

vehre commented Nov 8, 2017 via email

@vehre
Copy link
Collaborator

vehre commented Nov 12, 2017

Hi all,
the latest commit to vehre/issue-292-... branch completes the type and kind conversion for pure put() operations. What is left is doing the same for get() and sendget(). But send() now can act as a template and should enable doing the other two quicker.

send()-features:

  • dedicated code for copy to same image (no lib-calls)
  • kind conversion implemented
  • type conversion implemented
  • and the combination of the both above
  • using a vector as index on the remote image is supported now
  • optimized implementation using mpi-datatypes when no type/kind conversion is needed in use now
    (the preprocessor symbol STRIDED needs to be set!)
  • some tests added

Note: The test send_convert_char_array is failing on travis, because gfortran has a bug. Gfortran >= 7.3 is needed to make the test pass.

zbeekman added a commit that referenced this issue Dec 19, 2017
 - Also, confirmed that Andre's change(s) fixes #292
zbeekman added a commit that referenced this issue Dec 26, 2017
…onversion-during-communication

Fix type conversion during communication for regular get, send, sendget.

Fixes #292 and possibly #427
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants