Skip to content
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

update MPFR to v4.1.0 #36776

Merged
merged 1 commit into from
Aug 4, 2020
Merged

update MPFR to v4.1.0 #36776

merged 1 commit into from
Aug 4, 2020

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Jul 23, 2020

Includes build fixes to ensure it is built thread-safe. Fixes #35796 regression.

@JeffBezanson
Copy link
Member

Backport?

@vtjnash
Copy link
Member Author

vtjnash commented Jul 24, 2020

Seems like AArch64 is having problems computing pi with this update. I might need someone with access to a machine to investigate.

@JeffBezanson
Copy link
Member

Can we try 4.0.2 with threading enabled?

@vtjnash
Copy link
Member Author

vtjnash commented Jul 24, 2020

I assume I just need to rerun the Yggdrasil builder in a branch

@vtjnash
Copy link
Member Author

vtjnash commented Jul 30, 2020

Looking deeply into this, seems like something it going very badly. I see we're crashing on this copy/zero:

    if (MPFR_UNLIKELY (_destprec >= _srcprec))                              \
      {                                                                     \
        _srcs  = MPFR_PREC2LIMBS (_srcprec);                                \
        _dests = MPFR_PREC2LIMBS (_destprec) - _srcs;                       \
        MPN_COPY (_destp + _dests, srcp, _srcs);                            \
        MPN_ZERO (_destp, _dests);                                          \
        inexact = 0;                                                        \
      }                                                                     \

Where we know that _destprec == 32 and _srcprec == 32 + 63!

getting called from
MPFR_RNDRAW (inexact, a, tmp, bq + cq, rnd_mode, sign, ax2++); (mul.c:1086)
getting called from
mpfr_mul (bound_emin, bound_emin, e, MPFR_RNDD); (exp.c:119)

@vtjnash
Copy link
Member Author

vtjnash commented Jul 31, 2020

I'm almost certain this is a gcc (4.8.5) bug happening on some new code in mpfr-4.1.0 (prior code didn't have the cast to int)

   1084   /* b1 is 0 or 1 (most significant bit from the raw product) */
   1085   ax2 = ax + ((int) b1 - 1);
   1086   MPFR_RNDRAW (inexact, a, tmp, bq + cq, rnd_mode, sign, ax2++);

Where the round-down macro contains the if (_destprec >= _srcprec) { bad } else { good } I mention above.

The assembly though appears to have re-written that into:

if (b1 == 0) {
  ax2 = ax - 1;
  bad;
}
else {
  ax2 = ax + 0;
  good;
}

So either staying on 4.0.2 with the new flags or using a less ancient version of gcc (June 23, 2015) should resolve that.

@giordano
Copy link
Contributor

Is gcc v5 less ancient enough?

@vtjnash
Copy link
Member Author

vtjnash commented Jul 31, 2020

I don't have gcc 4 installed to compare, but gcc 5 seems to be generating sensible code for me.

Includes build fixes to ensure it is built thread-safe. Fixes #35796 regression.
@KristofferC KristofferC mentioned this pull request Aug 3, 2020
25 tasks
@vtjnash vtjnash merged commit 193b21b into master Aug 4, 2020
@vtjnash vtjnash deleted the jn/mpfr-4.1.0 branch August 4, 2020 01:23
yuyichao added a commit that referenced this pull request Aug 4, 2020
This was missed from #36756 and was deleted in #36776 .
yuyichao added a commit that referenced this pull request Aug 6, 2020
This was missed from #36756 and was deleted in #36776 .
KristofferC pushed a commit that referenced this pull request Aug 10, 2020
Includes build fixes to ensure it is built thread-safe. Fixes #35796 regression.

(cherry picked from commit 193b21b)
simeonschaub pushed a commit to simeonschaub/julia that referenced this pull request Aug 11, 2020
Includes build fixes to ensure it is built thread-safe. Fixes JuliaLang#35796 regression.
simeonschaub pushed a commit to simeonschaub/julia that referenced this pull request Aug 11, 2020
KristofferC pushed a commit that referenced this pull request Aug 18, 2020
Includes build fixes to ensure it is built thread-safe. Fixes #35796 regression.

(cherry picked from commit 193b21b)
KristofferC pushed a commit that referenced this pull request Aug 19, 2020
Includes build fixes to ensure it is built thread-safe. Fixes #35796 regression.

(cherry picked from commit 193b21b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compile MPFR and GMP to be thread safe
5 participants