Skip to content

Conversation

@kawashima-fj
Copy link
Member

Cherry-pick of #6159 to the v3.1.x branch.

@bosilca please review.

This commit fixes edge cases of r = 38 and r = 308.

As defined in the MPI standard, TYPE_CREATE_F90_REAL and TYPE_CREATE_F90_COMPLEX must be consistent with the Fortran SELECTED_REAL_KIND function. The SELECTED_REAL_KIND function is defined based on the RANGE function. The RANGE function returns INT(MIN(LOG10(HUGE(X)), -LOG10(TINY(X)))) for a real value X.

The old code considers only INT(LOG10(HUGE(X))) using *_MAX_10_EXP. This commit adds INT(-LOG10(TINY(X))) part using *_MIN_10_EXP.

This bug affected the following p-r combinations.

p r expected returned expected returned
MPI_UNDEFINED 38 REAL8 REAL4 COMPLEX16 COMPLEX8
0 <= p <= 6 38 REAL8 REAL4 COMPLEX16 COMPLEX8
MPI_UNDEFINED 308 REAL16 REAL8 COMPLEX32 COMPLEX16
0 <= p <= 15 308 REAL16 REAL8 COMPLEX32 COMPLEX16

MPICH returns the same result as Open MPI with this fix.

(cherry picked from commit 6fb01f6)

This commit fixes edge cases of `r = 38` and `r = 308`.

As defined in the MPI standard, `TYPE_CREATE_F90_REAL` and
`TYPE_CREATE_F90_COMPLEX` must be consistent with the Fortran
`SELECTED_REAL_KIND` function. The `SELECTED_REAL_KIND` function is
defined based on the `RANGE` function. The `RANGE` function returns
`INT(MIN(LOG10(HUGE(X)), -LOG10(TINY(X))))` for a real value `X`.

The old code considers only `INT(LOG10(HUGE(X)))` using `*_MAX_10_EXP`.
This commit adds `INT(-LOG10(TINY(X)))` part using `*_MIN_10_EXP`.

This bug affected the following `p`-`r` combinations.

| p             | r   | expected  | returned  | expected  | returned  |
| :------------ | --: | :-------- | :-------- | :-------  | :-------- |
| MPI_UNDEFINED |  38 | REAL8     | REAL4     | COMPLEX16 | COMPLEX8  |
| 0 <= p <= 6   |  38 | REAL8     | REAL4     | COMPLEX16 | COMPLEX8  |
| MPI_UNDEFINED | 308 | REAL16    | REAL8     | COMPLEX32 | COMPLEX16 |
| 0 <= p <= 15  | 308 | REAL16    | REAL8     | COMPLEX32 | COMPLEX16 |

MPICH returns the same result as Open MPI with this fix.

Signed-off-by: KAWASHIMA Takahiro <[email protected]>
(cherry picked from commit 6fb01f6)
@kawashima-fj kawashima-fj added this to the v3.1.4 milestone Dec 13, 2018
@kawashima-fj kawashima-fj requested a review from bosilca December 13, 2018 07:54
@jsquyres jsquyres changed the title mpi/c: Fix MPI_TYPE_CREATE_F90_{REAL,COMPLEX} v3.1.x: mpi/c: Fix MPI_TYPE_CREATE_F90_{REAL,COMPLEX} Dec 13, 2018
@bwbarrett bwbarrett merged commit cef3400 into open-mpi:v3.1.x Jan 10, 2019
@kawashima-fj kawashima-fj deleted the pr/v3.1.x/fix-type-create-f90 branch January 15, 2019 10:27
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.

3 participants