-
Notifications
You must be signed in to change notification settings - Fork 280
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
f08: resolve osx link constant issues #5682
Conversation
1b7939e
to
bac5eff
Compare
bac5eff
to
7e5db21
Compare
test:mpich/ch3/tcp all ✔️ |
The Jenkins results don't contain f08 tests. This will probably need a review from Cray before we can merge, as they were the original contributors of this code, and helped write it up in our paper. We should also test with the Cray |
For reference: https://www.mcs.anl.gov/papers/P5139-0514.pdf section 3.3 describes the named constant implementation. |
Only the tests of |
Sure, who should we ask for review? Let me ask on the slack. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hopefully will leave a general comment.
I think the Fortran/C interface routines look fine, but I have sent a sample to Bill Long to check the Fortran, I'm not good at Fortran 2008 either.
The changes in general look good to me, but I don't know python or the python binding script and don't have the time right now to figure it out (and I'm out Friday). I will try and look at this more while we wait for a response from Bill.
My two other questions should not be considered blocking issues.
If you are in a hurry for some reason to merge this PR, I would say merge it (i.e. I approve) if you can build MPICH and pass the F08 regression tests. It would be preferable if you could pass using at least 2 different compilers that support Fortran 2008.
test/mpi/configure.ac
Outdated
no|none - No Fortran support | ||
],,[enable_fortran=f77,f90]) | ||
],,[enable_fortran=all]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So a probably dumb question, but what if someone wants to build MPICH with a Fortran compiler with F08 support? How do they build the tests and run them? Admittedly most compiler are F08 compliant but there might still some out there. Or someone wants to build with an old GNU compiler. I don't care, and I doubt HPE cares, but in the interest of portability and compatibility you might want to reconsider.
Or I might be completely missing the point of this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review! It is not dumb at all. How to match the test suite to the mpich build is tricky. The issue we were having is even though mpich is built with f08, but the tests is not enabled unless we hard code the option into Jenkins' job. We have been missing the test coverage because of this.
Later in the configure there is code to check whether the compiler actually has 2008
support:
Lines 1411 to 1413 in 26cc6a9
if test "$enable_f08" = "yes" ; then | |
PAC_FC_2008_SUPPORT([enable_f08=yes],[enable_f08=no]) | |
fi |
So if the compiler is too "old" (e.g. gcc-8), the tests will be disabled later.
@@ -24,9 +24,6 @@ module mpi_f08_link_constants | |||
type(MPI_Status), bind(C, name="MPIR_F08_MPI_STATUS_IGNORE_OBJ"), target :: MPI_STATUS_IGNORE | |||
type(MPI_Status), dimension(1), bind(C, name="MPIR_F08_MPI_STATUSES_IGNORE_OBJ"), target :: MPI_STATUSES_IGNORE | |||
|
|||
type(c_ptr), bind(C, name="MPIR_C_MPI_STATUS_IGNORE") :: MPIR_C_MPI_STATUS_IGNORE | |||
type(c_ptr), bind(C, name="MPIR_C_MPI_STATUSES_IGNORE") :: MPIR_C_MPI_STATUSES_IGNORE | |||
|
|||
! Though these two variables are required by MPI-3 Standard, they are not used in MPICH | |||
type(c_ptr), bind(C, name="MPI_F08_STATUS_IGNORE") :: MPI_F08_STATUS_IGNORE ! Point to MPI_STATUS_IGNORE | |||
type(c_ptr), bind(C, name="MPI_F08_STATUSES_IGNORE") :: MPI_F08_STATUSES_IGNORE ! Point to MPI_STATUSES_IGNORE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are MPI_F08_STATUS_IGNORE and MPI_F08_STATUSES_IGNORE broken similar to MPIR_C_MPI_STATUS_IGNORE and MPIR_C_MPI_STATUSES_IGNORE? I know MPICH does not use them, but what if the user does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both MPI_F08_STATUS_IGNORE
and MPI_F08_STATUSES_IGNORE
are constants (1
) defined in mpi.h
and they are statically initialized in src/binding/fortran/use_mpi_f08/cdesc.c
. It worked, but it relied on the value being constants defined in mpi.h
. The new mechanism should be more robust.
MPI_F08_STATUS_IGNORE
and MPI_F08_STATUSES_IGNORE
works the same way as MPIR_C_MPI_UNWEIGHTED
and MPIR_C_MPI_WEIGHTS_EMPTY
, but since the symbols on C side is missing MPICH_API_PUBLIC
, thus not exposed, it is likely broken. But there is nothing checks it or make it matter
7e5db21
to
54e7183
Compare
This test is fixed with pmodels#5682. Xfail for now.
This test is fixed with pmodels#5682. Xfail for now.
This test is fixed with pmodels#5682. Xfail for now.
This test is fixed with pmodels#5682. Xfail for now.
This test is fixed with pmodels#5682. Xfail for now.
This test is fixed with pmodels#5682. Xfail for now.
4ecea5a
to
df3a057
Compare
FYI - I am still waiting on a confirmation from Bill Long about the F08 code. I didn't send him enough info first round (my mistake). I unfortunately did not get back to this PR, will try to get to it yet today. |
No worries. Meanwhile, I noticed that on |
df3a057
to
f25b521
Compare
test:mpich/custom/pipeline ✔️ That worked. |
That was part of what I was going to look into (sorry, pulled away again). I wondered why MPI_IN_PLACE and MPI_BOTTOM and possibly others were not affected, I guess they are. I will get to finishing this review at some point. |
F08 has two types of interfaces. For functions with choice buffers, it is directly linked to However, the |
Actually the functions with choice buffer parameters go through both Fortran wrappers and C wrappers, so the status constants are checked in the Fortran wrappers, thus we are good. In fact, we could check |
Alas, we can't. The C wrapper need directly access the choice buffer parameter as |
NOTE: added a commit to cleanup test:mpich/custom/pipeline test:mpich/ch3/most Failed to build f08 tests. Apparently, the linkage of C symbols happens at the stage of linking user program, thus the symbols need be visible. |
test:mpich/ch3/most ✔️ |
@raffenet @SteveO-Cray I don't want this PR to become too stale. Should we try to make a list of concerns (which may include "approval from Bill Long")? |
No other concerns from me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies. I forgot about this PR. I have not heard any further comments/objections from BIll and I think it is long enough to wait. I think you should proceed to merge.
Extend linebreak for general line with comma separations. This is to allow using linebreaking for Fortran declarations.
The mechanism for external linkage of global variable from fortran dynamic library to C dynamic library is fragile despite the fortran specification. For example, currently this mechanism does not work on osx. Rather than adding more hacking and work arounds, avoid the mess by simply getting the symbol using a C function. The f08 interoperability using C functions is fairly robust.
These are due to link constants issues, addressed in this PR.
Both symbols are not used by the C binding and can be contained in the Fortran binding. This avoids the issue of resolving common symbols depending on the behavior of dynamic linker.
Both MPI_F08_STATUS_IGNORE and MPI_F08_STATUSES_IGNORE don't need live in the C Binding since application is not suppose to use them unless the fortran binding is linked. Move them to the fortran binding avoids the linkage dependency on dynamic linker, which appears very fragile and currently does not work on osx. Both symbols are C symbols, thus there is no need to declare them in mpi_f08_link_constants.f90. The original comment -- "Although ..., they are not used in ..." is misleading. The two symbols are for application use, regardless whether implementation use it or not. Define the symbols in mpi.h as external is safe. User is not supposed to use it unless they link with fortran binding, i.e. libmpifort.so, which will resolve the symbol.
This is needed for `HAVE_VISIBILITY` option. It is also necessary to honor the configure for any potential system features.
Use assert to avoid including the whole mpich internal header stack.
Pull Request Description
The old mechanism uses separate symbols, e.g.
MPIR_C_MPI_UNWEIGHTED
, as a "link associated" variable between Fortran and C. However, this mechanism depends on how the system linker and may break, for example, on current osx. Instead, we can simply implement utility C functions to get the actual constant, e.g.MPI_UNWEIGHTED
at runtime. It is more robust and removes the extra complexity of maintaining separate exposed variables.Other constants, such as
MPI_ARGV_NULL
are simple constants. The old mechanism initializes the correspondingMPIR_C_MPI_ARGV_NULL
at compile time. While works, this is based on the knowledge/assumption that these constants are defined inmpi.h
. In this PR, we convert those to use the C utility functions as well for simplification and consistency.Fixes #4374
[skip warnings]
Author Checklist
Particularly focus on why, not what. Reference background, issues, test failures, xfail entries, etc.
Commits are self-contained and do not do two things at once.
Commit message is of the form:
module: short description
Commit message explains what's in the commit.
Whitespace checker. Warnings test. Additional tests via comments.
For non-Argonne authors, check contribution agreement.
If necessary, request an explicit comment from your companies PR approval manager.