-
Notifications
You must be signed in to change notification settings - Fork 8
Fortran: MPI RMA integer interfaces for AINT arguments #528
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
Comments
@wgropp made the following comment on email:
|
@jeffhammond Is the goal here purely high-level syntactic sugar that redirects to one canonical interface and does not broaden the PMPI interface? If so, there should be appropriate language somewhere that specifies this behavior (and a pointer to that language on every relevant function overload, IMO). Otherwise we force tools to err on the side of caution and account for both F08 overloads (probably unnecessarily, but if the standard doesn't specify...) So at least for the purpose of normative text specifying how this should behave with respect to PMPI, I would like to see a pull request here. |
Did we add such language for large count or did tools using PMPI figure it out? |
We added a great deal of language for large count that specified exactly how the new interfaces, including ones based on Fortran polymorphism, mapped to non-polymorphic names. We also broadened the PMPI interface via the |
@RolfRabenseifner @hritzdorf could one of you look at this and let me know if there are any reasons why we should not continue working on it? |
The proposal does not tell, wether it is for mpi_f08, mpi or mpif.h? I expect, it is only for mpi_f08, because it is only a proposal for new software and that should use mpi_f08. The proposal is technically wrong, because it does not include a concept for new specific procedure names, see MPI-4.0 Sect. 19.1.5, Table 19.1 on page 799 plus the "_c" specific name portions for large count versions as described in MPI-4.0 Sect. 19.2, page 839 line - p.840 line 13. The proposal should show the several interfaces with the same Fortran interface name, as you can see in MPI-4.0 page 571 in the Fortran 2008 binding for MPI_Put. Similar to _c and the comment !(_c), you should specify _i and !(_i) for these integer versions and a new section corresponding to section 19.2. My personal opinion: |
This proposal is not needed and only complicating the implementation of MPI libraries and tools.
Maybe not needed, but “sorely wanted”.
Fortran users may know that 0_MPI_ADDRESS_KIND and integer(0,MPI_ADDRESS_KIND) is such a long integer constant with value 0.
I’d have to see what my compiler says about a literal zero, but I seem to recall that it took me quite a bit of searching the first time I ran into this. Fortran users may indeed know, but I fear they may not. So why not make life a little more logical for them?
Looking at it purely from a user perspective.
Victor.
|
It would be cheaper to add nice examples at prominent places, for example on MPI_Put. Or/and you may add two Advice to users in 2.6.2 (mentioning the 0_MPI_ADDRESS_KIND notation) and 2.6.3 (mentioning the automatic cast for call-by-value-arguments). You may look at my MPI course, |
@RolfRabenseifner So you would rather add non-normative text to the standard to explain Fortran casting rules, which most users will never read, than add text to the standard that requires implementers to make this "just work" in the same way that C does, without them having to know anything? How many other new user-friendly features will you reject because we can instead provide an example of how to solve the problem by writing more code? |
In any case, @RolfRabenseifner, it already says this feature only applies to mpi_f08.mod here:
|
Also, the difference between |
If all MPI implementors and all tools implementors say that they are happy with implementing this enhancement, I have no problem with it, as long as this non-trivial enhancement is correctly added to the MPI standard, see my hints above. Because it is not trivial, a reference implementations would be need to be 100% sure that the amended MPI standard is consistent. And same sentence for the tools side. I'm not against. |
As long as MPI does not provide a solution, and as long as it is mainly about such long zeros, you may define a very short constant, e.g. ZL, which is of type |
This is an example of the kinds of issues that any Fortran library is facing, in order to make the Fortran API as easy and as natural to use in Fortran. Speaking as a Fortran user, the most natural for a foundational library such as MPI is to provide the same interface as any other "native" Fortran functions, such as We face the same issues with Fortran's stdlib, we handle it by auto generating such interfaces, see an example here: https://github.com/fortran-lang/stdlib/blob/6957436c1b3c99901ff5fefe0948453ad7a57c2b/src/stdlib_linalg.fypp, we autogenerate such functions for all kinds. It's tedious from the library developer's perspective and that's unfortunate. We have started brainstorming some ways to improve the Fortran language itself to make this easier, see e.g.: j3-fortran/fortran_proposals#128. If anybody here can help us figure out a good solution, that would be very highly appreciated. Until then, the interfaces must be autogenerated. As a user, that is what I would like. If users are forced to write things like This brings a broader question whether MPI should design its Fortran interface to be as "native" and "natural" and to use "modern Fortran". As to me, I would say absolutely yes! However, as shown above, it does add some extra work for the MPI implementations. If the answer is "we do not have the cycles to support a modern Fortran interface", then the answer might be "no". In that case, why not just provide a good C interface, and perhaps recommend some third party community maintained modern Fortran interface that builds on top of this C interface? |
@dholmes-epcc-ed-ac-uk correctly notes there is a similar inconsistency with |
@dholmes-epcc-ed-ac-uk @jeffhammond Could you outline the inconsistency with |
The principle that was (mostly) followed during the Large Count effort was: we provide exactly two overloads (separate procedures for C, specific procedures inside an interface for Fortran) -- one which has all small parameters and another that has all big parameters. This principle, in the absence of precedent from MPI-3.1 (as before), should have meant that one of the overloads required an array of |
My preference is to add interfaces that permit integer values. These don't require corresponding C routines - permitting shorter integer scalars is a convenience for users, not a new capability. They can be added following the same language used for the _c versions, though limited only to the integer scalars. |
Notes from the WG meeting:
|
I will not be able to work on this for 4.1 due to a) a lack of cycles and b) not being sufficiently versed in Fortran to deliberate on its type system. If @VictorEijkhout wants to pick it up I'll be happy to help but I won't drive it. |
I can produce the text but don't know how to implement in latex. |
Send me the text and any notes on how you want it to appear. |
Problem
RMA absolutely did the right thing with
MPI_Aint
size and displacement arguments.In C, it is no problem to pass 32b integers to these arguments when AINT is 64b, because C type promotion rules just work.
In Fortran, I cannot do this, because an integer literal is not compatible with an AINT argument. I find it tedious to have to declare a variable just for this, or to explicitly cast with
integer(100,MPI_ADDRESS_KIND)
.Fortran
C
Proposal
Use Fortran polymorphism and add subroutine declarations for default integer arguments where appropriate.
Changes to the Text
Add the following interfaces.
The rule here is: for all
INTENT(IN)
instances ofINTEGER(KIND=MPI_ADDRESS_KIND)
that describe a count-like argument (size or displacement), add a default integer interface.Obviously, there are cases where size and displacement need to larger than
INTEGER
but obviously the programmer is going to have to use an AINT there, so there is no potential for misuse. Any time the argument is an AINT, the proper interface will be used. Only when the argument fits into anINTEGER
will that interface be used.MPI_Alloc_mem
MPI_Win_create
MPI_Win_allocate
MPI_Win_allocate_shared
MPI_Win_attach
MPI_Put
And so forth for all other RMA communication operations where
TARGET_DISP
isINTEGER(KIND=MPI_ADDRESS_KIND)
.Impact on Implementations
Fortran 2008 modules in MPI implementation will need to add these interfaces. One hopes the interfaces will be automatically generated, such that the effort required here is minimal.
Impact on Users
This makes RMA easy to use because applications can call RMA functions with integer literals and default integer arguments, rather than having to do explicit casting or create variables just to hold integers in the right type.
This also reduces the mental overhead of switching from C/C++ to Fortran, because no overloads are required in C/C++ due to the way integer casting works (and because scalars are passed by value rather than reference).
References and Pull Requests
No pull request. This can be automatically generated by someone who understands who the interface generation stuff works.
The text was updated successfully, but these errors were encountered: