-
Notifications
You must be signed in to change notification settings - Fork 871
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
mpi_f08: fix Fortran-8-byte-INTEGER vs. C-4-byte-int issue #7921
mpi_f08: fix Fortran-8-byte-INTEGER vs. C-4-byte-int issue #7921
Conversation
It is important to have the mpi_f08 Type(MPI_Status) be the same length (in bytes) as the mpif.h status (which is an array of MPI_STATUS_SIZE INTEGERs). The reason is because MPI_Status_ctof() basically does the following: MPI_Fint *f_status = ...; int *s = (int*) &c_status; for i=0..sizeof(MPI_Status)/sizeof(int) f_status[i] = c_status[i]; Meaning: the Fortran status needs to be able to hold as many INTEGERs are there are C int's that can fit in sizeof(MPI_Status) bytes. This is because a Fortran INTEGER may be larger than a C int (e.g., Fortran 8 bytes vs. C 4 bytes). Hence, the assignment on the Fortran side will take sizeof(INTEGER) bytes for each sizeof(int) bytes in the C MPI_Status. This commit pads out the mpi_f08 Type(MPI_Status) with enough INTEGERs to make it the same size as an array of MPI_TYPE_SIZE INTEGERs. Hence, MPI_Status_ctof() will work properly, regardless of whether it is assinging to an mpi_f08 Type(MPI_Status) or an mpif.h array of MPI_STATUS_SIZE INTEGERs. Thanks to @ahaichen for reporting the issue. Signed-off-by: Jeff Squyres <[email protected]>
@jsquyres on top of my head
note we could/should use macros to skip the |
Yes, it is. The 2 members that I removed were private members, anyway. I think we added them here in OMPI just as a matter of course (i.e., parity with the C struct). But this doesn't take into account the "Integers larger than ints" case.
Yes. Perhaps we should do this simple solution on master only, and do something like your proposal on the v4.x branches...?
Ugh, yes, this is probably a good solution for the release branches. This will touch a LOT of code, though (i.e., everywhere we use a status). ...alternatively, we could state that this is known not to work on the v4.x release. We could add a configure check for INTEGER=8 bytes + int=4 bytes and refuse to build (i.e., abort configure). If this has never worked in the v4.x series, then this is technically not a regression -- we would just be making the failure occur sooner (i.e., during configure).
If we actually fix this in v4.x, 👍 |
bot:aws:retest |
that looks fair to me
|
I updated the commit message to indicate that this is an ABI break. @ggouaillardet Can you review so that I can merge? (we keep getting weird SSL failures in AWS CI... trying again...) bot:aws:retest |
bot:aws:retest |
It is important to have the mpi_f08 Type(MPI_Status) be the same
length (in bytes) as the mpif.h status (which is an array of
MPI_STATUS_SIZE INTEGERs). The reason is because MPI_Status_ctof()
basically does the following:
Meaning: the Fortran status needs to be able to hold as many INTEGERs
are there are C int's that can fit in sizeof(MPI_Status) bytes.
This is because a Fortran INTEGER may be larger than a C int (e.g.,
Fortran 8 bytes vs. C 4 bytes). Hence, the assignment on the Fortran
side will take sizeof(INTEGER) bytes for each sizeof(int) bytes in the
C MPI_Status.
This commit pads out the mpi_f08 Type(MPI_Status) with enough INTEGERs
to make it the same size as an array of MPI_TYPE_SIZE INTEGERs.
Hence, MPI_Status_ctof() will work properly, regardless of whether it
is assinging to an mpi_f08 Type(MPI_Status) or an mpif.h array of
MPI_STATUS_SIZE INTEGERs.
Thanks to @ahaichen for reporting the issue.
Signed-off-by: Jeff Squyres [email protected]
Refs #7918