Skip to content

Conversation

@PhilippOtte
Copy link
Contributor

@PhilippOtte PhilippOtte commented Jul 18, 2018

Following changes were carried out in ompi/mpi/fortran/use-mpi-f08:

  • corrected the intent of the send buffer on most signatures in the Fortran 2008 interface
  • added the ASYNCHRONOUS attribute to send and receive buffers and other array dummy arguments in non-blocking collective calls (also in mod/mpi-f08-interfaces.F90)
  • corrected attributes in the C bindings defined in mpi-f-interfaces-bind.h

Important: I was not able to compile other parts of the code and could not check whether files compile but I think it would be wasted effort not to create a PR

Refs #5442

@ompiteam-bot
Copy link

Can one of the admins verify this patch?

@jsquyres
Copy link
Member

ok to test

@jsquyres
Copy link
Member

@PhilippOtte Thanks for the PR! Please note that we have a "Signed off by" requirement on our commits to indicate that you agree to our contributors declaration: https://github.com/open-mpi/ompi/blob/master/.github/CONTRIBUTING.md#contributors-declaration

! The sizeof interfaces

include "sizeof_f08.h"
! include "sizeof_f08.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to comment this out? That doesn't seem correct.

@ibm-ompi
Copy link

The IBM CI (XL Compiler) build failed! Please review the log, linked below.

Gist: https://gist.github.com/1d987ba950d7a00a542a6a6e1fa75a58

BIND(C, name="ompi_iallgather_f")
implicit none
OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN) :: sendbuf, recvbuf
OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN), ASYNCHRONOUS :: sendbuf, recvbuf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sendbuf and recvbuf cannot be defined twice

Copy link
Member

@jsquyres jsquyres Jul 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw, that too. I'm also getting a compile error that I'm puzzling over:

EDIT: See next comment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops -- I originally pasted in the wrong compile error. This is the right one:

  PPFC     ialltoallw_f08.lo
ialltoallw_f08.F90:35:53:

    call ompi_ialltoallw_f(sendbuf,sendcounts,sdispls,sendtypes(1)%MPI_VAL,&
                                                     1
Error: Rank mismatch in argument ‘sendtypes’ at (1) (rank-1 and scalar)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see the problem. Directed comment coming up...

OMPI_FORTRAN_IGNORE_TKR_TYPE, ASYNCHRONOUS :: recvbuf
INTEGER, INTENT(IN), ASYNCHRONOUS :: sendcounts(*), sdispls(*), recvcounts(*), rdispls(*)
INTEGER, INTENT(IN), ASYNCHRONOUS :: sendtypes(*)
INTEGER, INTENT(IN), ASYNCHRONOUS :: recvtypes(*)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You changed the types of sendtypes and recvtypes from scalars to arrays here. They were specifically scalars (in both ompi_alltoallw_f and ompi_ialltoallw_f) -- see the lengthy comment here: https://github.com/open-mpi/ompi/blob/master/ompi/mpi/fortran/use-mpi-f08/ialltoallw_f08.F90#L24-L33

Yes, it's a hack, but there did not seem to be another performant way to get the values from one call to the other (i.e., without allocating a temporary array from the heap [because this is ialltoallw, and we'll return before sendtypes/recvtypes are finished being used], individually copying all the elements from sendtypes/recvtypes to the temporary array, and then passing the temporary array to the underlying call. Then there will need to be some kind of hook when the request completes to know to free that temporary array, too).

Is there a better way?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fortran allows you to obtain the address of the first element in an array via the intrinsic c_loc which returns a type(c_ptr) which is equivalent to a void pointer in C. There would be no copying involved and you would prevent the compiler from doing any unwanted magic there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add that to this PR? I'm wasn't enough of a Fortran expert to get that to work back when I originally wrote this stuff -- this hack was the best that I could come up with. 😳

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Modern Fortran explained by Metcalf, Reid and Cohen the proposed way of using c_loc may lead to invalid pointers. So, your hack is probably the safer way of doing things.

@PhilippOtte
Copy link
Contributor Author

Is there a safe way of signing off the unsigned commits or should I create a new branch with the changes in it and create a new PR?

@ibm-ompi
Copy link

The IBM CI (XL Compiler) build failed! Please review the log, linked below.

Gist: https://gist.github.com/f6d76331dd80495c769a46dabc151ac3

@jsquyres
Copy link
Member

You can git rebase -i origin/master to edit the existing commits on this PR. You'll then need to force-push back up to your branch (because you changed git history) -- that's just about the only socially-acceptable time to git-force-push.

image

@PhilippOtte PhilippOtte force-pushed the corrections_F08_signatures_collectives branch from 7f4db0b to f2398a8 Compare July 19, 2018 08:36
@PhilippOtte
Copy link
Contributor Author

@ggouaillardet do you still request changes?

Copy link
Member

@jsquyres jsquyres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably squash the last 3 commits into the earlier commit(s). I.e., there's no real point in having a PR that makes change X in a commit, and then in a later commit on the same PR, removes change X.

@jsquyres
Copy link
Member

jsquyres commented Aug 2, 2018

Sorry -- meant to say: squash the last 2 commits.

@PhilippOtte PhilippOtte force-pushed the corrections_F08_signatures_collectives branch from f2398a8 to 4d92c89 Compare August 3, 2018 08:43
@PhilippOtte PhilippOtte force-pushed the corrections_F08_signatures_collectives branch from 4d92c89 to be6bb2a Compare August 28, 2018 13:46
Copy link
Member

@jsquyres jsquyres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gah -- this PR fell off my radar (because github doesn't mail us upon force pushes). Doh! This all looks good to me now. @ggouaillardet can you review? (you have a negative review on this PR, but I think everything is fixed now)

@jsquyres
Copy link
Member

@ggouaillardet Can you re-review? All the problems have been fixed.

@gpaulsen
Copy link
Member

@ggouaillardet Can you please re-review?

@gpaulsen
Copy link
Member

@PhilippOtte Can you please rebase (again)?

@jsquyres jsquyres force-pushed the corrections_F08_signatures_collectives branch from be6bb2a to d632969 Compare September 24, 2018 19:36
@jsquyres
Copy link
Member

I just rebased -- we're now good. Just need a new review from @ggouaillardet

@gpaulsen
Copy link
Member

Question, is this going to break binary compatibility with the older compiled apps? Even if this is more correct, if it breaks binary compatibility, this might trigger a new major release version bump.

@jsquyres
Copy link
Member

I'm not going to swear to it, but I don't think INTENT affects the resulting symbol.

A Fortran expert should chime in here...

(too funny: Firefox underlines Fortran like it's misspelled! 😆)

@ggouaillardet
Copy link
Contributor

the same changes have to be applied to ompi/mpi/fortran/use-mpi-f08/profile too. I will prepare a PR from now.

Should this PR make it for v4.0.0 ?

PhilippOtte and others added 2 commits September 25, 2018 11:16
Corrected the signatures of the collectives used by the Fortran 2008
interface to state correct intent for inout arguments and use the
ASYNCHRONOUS attribute in non-blocking collective calls. Also corrected
the C-bindings in Fortran accordingly

Signed-off-by: Philipp Otte <philipp.j.otte@googlemail.com>
Corrected the signatures of the collectives used by the Fortran 2008
interface to state correct intent for inout arguments and use the
ASYNCHRONOUS attribute in non-blocking collective calls.

Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>
@ggouaillardet ggouaillardet force-pushed the corrections_F08_signatures_collectives branch from d632969 to f750c69 Compare September 25, 2018 02:18
@ggouaillardet
Copy link
Contributor

@jsquyres I fixed the signatures for the PMPI subroutines and fixed MPI_Ireduce_scatter[_block]() parameters too. As far as I am concerned, this is good for primetime.

@gpaulsen
Copy link
Member

gpaulsen commented Sep 27, 2018

First round of answers from Fortran experts here say:

As far as I know, the intent attribute does not change the calling convention and the signature of the procedure. It should not cause binary incompatibilities.

@ggouaillardet
Copy link
Contributor

@gpaulsen is this something stated in the standard ? I might be a bit too paranoid/pedantic here, but unless stated in the standard, we should theoretically verify this technical choice was made on all supported compilers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants