Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master grimoire by Pavel Vinogradov (95bac910503bea355cec2fb2b10547faf9819152)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Pavel Vinogradov <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master grimoire by Pavel Vinogradov (95bac910503bea355cec2fb2b10547faf9819152)
  • Date: Wed, 27 Dec 2017 02:10:27 +0000

GIT changes to master grimoire by Pavel Vinogradov <public AT sourcemage.org>:

libs/libmpc/PRE_BUILD | 4
libs/libmpc/mpfr_fmma.patch | 228
+++++++++++++-------------------------------
2 files changed, 71 insertions(+), 161 deletions(-)

New commits:
commit 95bac910503bea355cec2fb2b10547faf9819152
Author: Pavel Vinogradov <public AT sourcemage.org>
Commit: Pavel Vinogradov <public AT sourcemage.org>

libs/libmpc: replaced the patch with slightly modified upstream commit

diff --git a/libs/libmpc/PRE_BUILD b/libs/libmpc/PRE_BUILD
index 557d316..8b2f740 100755
--- a/libs/libmpc/PRE_BUILD
+++ b/libs/libmpc/PRE_BUILD
@@ -1,4 +1,6 @@
default_pre_build &&
cd "${SOURCE_DIRECTORY}" &&

-patch -Np1 < "${SPELL_DIRECTORY}/mpfr_fmma.patch"
+patch -Np1 < "${SPELL_DIRECTORY}/mpfr_fmma.patch" &&
+
+autoreconf
diff --git a/libs/libmpc/mpfr_fmma.patch b/libs/libmpc/mpfr_fmma.patch
index cbad628..f4efed7 100644
--- a/libs/libmpc/mpfr_fmma.patch
+++ b/libs/libmpc/mpfr_fmma.patch
@@ -1,173 +1,81 @@
---- mpc-1.0.3.orig/src/mul.c 2015-02-16 07:37:30.000000000 -0500
-+++ mpc-1.0.3/src/mul.c 2017-12-26 16:14:42.648306427 -0500
-@@ -171,156 +171,6 @@
- }
+From 36a84f43f326de14db888ba07936cc9621c23f19 Mon Sep 17 00:00:00 2001
+From: Paul Zimmermann <Paul.Zimmermann AT inria.fr>
+Date: Sun, 10 Jan 2016 23:19:37 +0100
+Subject: [PATCH] use mpfr_fmma and mpfr_fmms if provided by mpfr
+
+---
+ configure.ac | 16 ++++++++++++++++
+ src/mul.c | 15 ++++++++++++---
+ 2 files changed, 28 insertions(+), 3 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b6fa199..bdb21ff 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -165,6 +165,22 @@ AC_LINK_IFELSE(
+ AC_MSG_ERROR([libmpfr not found or uses a different ABI (including
static vs shared).])
+ ])

++AC_MSG_CHECKING(for mpfr_fmma)
++LIBS="-lmpfr $LIBS"
++AC_LINK_IFELSE(
++ [AC_LANG_PROGRAM(
++ [[#include "mpfr.h"]],
++ [[mpfr_t x; mpfr_fmma (x, x, x, x, x, 0);]]
++ )],
++ [
++ AC_MSG_RESULT(yes)
++ AC_DEFINE(HAVE_MPFR_FMMA, 1, [mpfr_fmma is present])
++ ],
++ [
++ AC_MSG_RESULT(no)
++ AC_DEFINE(HAVE_MPFR_FMMA, 0, [mpfr_fmma is not present])
++ ])
++
+ # Check for a recent GMP
+ # We only guarantee that with a *functional* and recent enough GMP version,
+ # MPC will compile; we do not guarantee that GMP will compile.
+diff --git a/src/mul.c b/src/mul.c
+index 3c9c0a7..8c4afe4 100644
+--- a/src/mul.c
++++ b/src/mul.c
+@@ -175,8 +175,9 @@ mul_imag (mpc_ptr z, mpc_srcptr x, mpc_srcptr y,
mpc_rnd_t rnd)
+ #define MPFR_EXP(x) ((x)->_mpfr_exp)
+ #define MPFR_LIMB_SIZE(x) ((MPFR_PREC (x) - 1) / GMP_NUMB_BITS + 1)

--static int
++#if HAVE_MPFR_FMMA == 0
+ static int
-mpfr_fmma (mpfr_ptr z, mpfr_srcptr a, mpfr_srcptr b, mpfr_srcptr c,
-- mpfr_srcptr d, int sign, mpfr_rnd_t rnd)
--{
-- /* Computes z = ab+cd if sign >= 0, or z = ab-cd if sign < 0.
-- Assumes that a, b, c, d are finite and non-zero; so any multiplication
-- of two of them yielding an infinity is an overflow, and a
-- multiplication yielding 0 is an underflow.
-- Assumes further that z is distinct from a, b, c, d. */
--
-- int inex;
-- mpfr_t u, v;
--
-- /* u=a*b, v=sign*c*d exactly */
-- mpfr_init2 (u, mpfr_get_prec (a) + mpfr_get_prec (b));
-- mpfr_init2 (v, mpfr_get_prec (c) + mpfr_get_prec (d));
-- mpfr_mul (u, a, b, GMP_RNDN);
-- mpfr_mul (v, c, d, GMP_RNDN);
-- if (sign < 0)
-- mpfr_neg (v, v, GMP_RNDN);
--
-- /* tentatively compute z as u+v; here we need z to be distinct
-- from a, b, c, d to not lose the latter */
-- inex = mpfr_add (z, u, v, rnd);
--
-- if (mpfr_inf_p (z)) {
-- /* replace by "correctly rounded overflow" */
-- mpfr_set_si (z, (mpfr_signbit (z) ? -1 : 1), GMP_RNDN);
-- inex = mpfr_mul_2ui (z, z, mpfr_get_emax (), rnd);
-- }
-- else if (mpfr_zero_p (u) && !mpfr_zero_p (v)) {
-- /* exactly u underflowed, determine inexact flag */
-- inex = (mpfr_signbit (u) ? 1 : -1);
-- }
-- else if (mpfr_zero_p (v) && !mpfr_zero_p (u)) {
-- /* exactly v underflowed, determine inexact flag */
-- inex = (mpfr_signbit (v) ? 1 : -1);
-- }
-- else if (mpfr_nan_p (z) || (mpfr_zero_p (u) && mpfr_zero_p (v))) {
-- /* In the first case, u and v are infinities with opposite signs.
-- In the second case, u and v are zeroes; their sum may be 0 or the
-- least representable number, with a sign to be determined.
-- Redo the computations with mpz_t exponents */
-- mpfr_exp_t ea, eb, ec, ed;
-- mpz_t eu, ev;
-- /* cheat to work around the const qualifiers */
--
-- /* Normalise the input by shifting and keep track of the shifts in
-- the exponents of u and v */
-- ea = mpfr_get_exp (a);
-- eb = mpfr_get_exp (b);
-- ec = mpfr_get_exp (c);
-- ed = mpfr_get_exp (d);
--
-- mpfr_set_exp ((mpfr_ptr) a, (mpfr_prec_t) 0);
-- mpfr_set_exp ((mpfr_ptr) b, (mpfr_prec_t) 0);
-- mpfr_set_exp ((mpfr_ptr) c, (mpfr_prec_t) 0);
-- mpfr_set_exp ((mpfr_ptr) d, (mpfr_prec_t) 0);
--
-- mpz_init (eu);
-- mpz_init (ev);
-- mpz_set_si (eu, (long int) ea);
-- mpz_add_si (eu, eu, (long int) eb);
-- mpz_set_si (ev, (long int) ec);
-- mpz_add_si (ev, ev, (long int) ed);
--
-- /* recompute u and v and move exponents to eu and ev */
-- mpfr_mul (u, a, b, GMP_RNDN);
-- /* exponent of u is non-positive */
-- mpz_sub_ui (eu, eu, (unsigned long int) (-mpfr_get_exp (u)));
-- mpfr_set_exp (u, (mpfr_prec_t) 0);
-- mpfr_mul (v, c, d, GMP_RNDN);
-- if (sign < 0)
-- mpfr_neg (v, v, GMP_RNDN);
-- mpz_sub_ui (ev, ev, (unsigned long int) (-mpfr_get_exp (v)));
-- mpfr_set_exp (v, (mpfr_prec_t) 0);
--
-- if (mpfr_nan_p (z)) {
-- mpfr_exp_t emax = mpfr_get_emax ();
-- int overflow;
-- /* We have a = ma * 2^ea with 1/2 <= |ma| < 1 and ea <= emax, and
-- analogously for b. So eu <= 2*emax, and eu > emax since we have
-- an overflow. The same holds for ev. Shift u and v by as much as
-- possible so that one of them has exponent emax and the
-- remaining exponents in eu and ev are the same. Then carry out
-- the addition. Shifting u and v prevents an underflow. */
-- if (mpz_cmp (eu, ev) >= 0) {
-- mpfr_set_exp (u, emax);
-- mpz_sub_ui (eu, eu, (long int) emax);
-- mpz_sub (ev, ev, eu);
-- mpfr_set_exp (v, (mpfr_exp_t) mpz_get_ui (ev));
-- /* remaining common exponent is now in eu */
-- }
-- else {
-- mpfr_set_exp (v, emax);
-- mpz_sub_ui (ev, ev, (long int) emax);
-- mpz_sub (eu, eu, ev);
-- mpfr_set_exp (u, (mpfr_exp_t) mpz_get_ui (eu));
-- mpz_set (eu, ev);
-- /* remaining common exponent is now also in eu */
-- }
-- inex = mpfr_add (z, u, v, rnd);
-- /* Result is finite since u and v have different signs. */
-- overflow = mpfr_mul_2ui (z, z, mpz_get_ui (eu), rnd);
-- if (overflow)
-- inex = overflow;
-- }
-- else {
-- int underflow;
-- /* Addition of two zeroes with same sign. We have a = ma * 2^ea
-- with 1/2 <= |ma| < 1 and ea >= emin and similarly for b.
-- So 2*emin < 2*emin+1 <= eu < emin < 0, and analogously for v. */
-- mpfr_exp_t emin = mpfr_get_emin ();
-- if (mpz_cmp (eu, ev) <= 0) {
-- mpfr_set_exp (u, emin);
-- mpz_add_ui (eu, eu, (unsigned long int) (-emin));
-- mpz_sub (ev, ev, eu);
-- mpfr_set_exp (v, (mpfr_exp_t) mpz_get_si (ev));
-- }
-- else {
-- mpfr_set_exp (v, emin);
-- mpz_add_ui (ev, ev, (unsigned long int) (-emin));
-- mpz_sub (eu, eu, ev);
-- mpfr_set_exp (u, (mpfr_exp_t) mpz_get_si (eu));
-- mpz_set (eu, ev);
-- }
-- inex = mpfr_add (z, u, v, rnd);
-- mpz_neg (eu, eu);
-- underflow = mpfr_div_2ui (z, z, mpz_get_ui (eu), rnd);
-- if (underflow)
-- inex = underflow;
-- }
--
-- mpz_clear (eu);
-- mpz_clear (ev);
--
-- mpfr_set_exp ((mpfr_ptr) a, ea);
-- mpfr_set_exp ((mpfr_ptr) b, eb);
-- mpfr_set_exp ((mpfr_ptr) c, ec);
-- mpfr_set_exp ((mpfr_ptr) d, ed);
-- /* works also when some of a, b, c, d are not all distinct */
-- }
--
-- mpfr_clear (u);
-- mpfr_clear (v);
--
-- return inex;
--}
--
--
- int
- mpc_mul_naive (mpc_ptr z, mpc_srcptr x, mpc_srcptr y, mpc_rnd_t rnd)
++mpc_fmma (mpfr_ptr z, mpfr_srcptr a, mpfr_srcptr b, mpfr_srcptr c,
+ mpfr_srcptr d, int sign, mpfr_rnd_t rnd)
{
-@@ -337,10 +187,10 @@
+ /* Computes z = ab+cd if sign >= 0, or z = ab-cd if sign < 0.
+@@ -319,6 +320,7 @@
+
+ return inex;
+ }
++#endif
+
+
+ int
+@@ -337,10 +338,17 @@
else
rop [0] = z [0];

-- inex = MPC_INEX (mpfr_fmma (mpc_realref (rop), mpc_realref (x),
mpc_realref (y), mpc_imagref (x),
-- mpc_imagref (y), -1, MPC_RND_RE (rnd)),
++#if HAVE_MPFR_FMMA
+ inex = MPC_INEX (mpfr_fmms (mpc_realref (rop), mpc_realref (x),
mpc_realref (y), mpc_imagref (x),
+ mpc_imagref (y), MPC_RND_RE (rnd)),
- mpfr_fmma (mpc_imagref (rop), mpc_realref (x),
mpc_imagref (y), mpc_imagref (x),
-- mpc_realref (y), +1, MPC_RND_IM (rnd)));
++ mpfr_fmma (mpc_imagref (rop), mpc_realref (x),
mpc_imagref (y), mpc_imagref (x),
+ mpc_realref (y), MPC_RND_IM (rnd)));
++#else
+ inex = MPC_INEX (mpfr_fmma (mpc_realref (rop), mpc_realref (x),
mpc_realref (y), mpc_imagref (x),
+ mpc_imagref (y), -1, MPC_RND_RE (rnd)),
+ mpfr_fmma (mpc_imagref (rop), mpc_realref (x),
mpc_imagref (y), mpc_imagref (x),
+ mpc_realref (y), +1, MPC_RND_IM (rnd)));
++#endif

mpc_set (z, rop, MPC_RNDNN);
if (overlap)
+--
+2.1.4
+



  • [SM-Commit] GIT changes to master grimoire by Pavel Vinogradov (95bac910503bea355cec2fb2b10547faf9819152), Pavel Vinogradov, 12/26/2017

Archive powered by MHonArc 2.6.24.

Top of Page