[Gmp-commit] /var/hg/gmp: 3 new changesets
mercurial at gmplib.org
mercurial at gmplib.org
Tue Feb 7 14:32:01 UTC 2017
details: /var/hg/gmp/rev/77672da22f0b
changeset: 17227:77672da22f0b
user: Torbjorn Granlund <tg at gmplib.org>
date: Tue Feb 07 15:27:40 2017 +0100
description:
(binvert): New function, computing modular inverse andlow zero count.
(header): Print MP_BASES_BIG_BASE_CTZ_10 and MP_BASES_BIG_BASE_BINVERTED_10.
details: /var/hg/gmp/rev/1ae7f7d21a73
changeset: 17228:1ae7f7d21a73
user: Torbjorn Granlund <tg at gmplib.org>
date: Tue Feb 07 15:28:17 2017 +0100
description:
Use mpn_pi1_bdiv_q_1/mpn_bdiv_q_1 instead of mpn_divexact_1.
details: /var/hg/gmp/rev/ff64a5705a4c
changeset: 17229:ff64a5705a4c
user: Torbjorn Granlund <tg at gmplib.org>
date: Tue Feb 07 15:28:35 2017 +0100
description:
ChangeLog
diffstat:
ChangeLog | 22 ++++++++++++++++++++++
gen-bases.c | 20 ++++++++++++++++++++
mpn/generic/compute_powtab.c | 11 ++++++++++-
3 files changed, 52 insertions(+), 1 deletions(-)
diffs (124 lines):
diff -r ac1ddf728e5b -r ff64a5705a4c ChangeLog
--- a/ChangeLog Mon Feb 06 23:20:36 2017 +0100
+++ b/ChangeLog Tue Feb 07 15:28:35 2017 +0100
@@ -1,3 +1,20 @@
+2017-02-07 Torbjörn Granlund <tg at gmplib.org>
+
+ * mpn/generic/compute_powtab.c: Use mpn_pi1_bdiv_q_1/mpn_bdiv_q_1
+ instead of mpn_divexact_1.
+
+ * gen-bases.c (binvert): New function, computing modular inverse and
+ low zero count.
+ (header): Print MP_BASES_BIG_BASE_CTZ_10 and
+ MP_BASES_BIG_BASE_BINVERTED_10.
+
+2017-02-06 Torbjörn Granlund <tg at gmplib.org>
+
+ * mpn/generic/bdiv_q_1.c: Make return value consistent.
+
+ * mpn/x86/p6/mmx/gmp-mparam.h (SQR_TOOM2_THRESHOLD): Revert to bogus
+ value to accomodate p6/sqr_basecase.asm fragility.
+
2017-01-29 Marco Bodrato <bodrato at mail.dm.unipi.it>
* mpz/and.c: Simplify branches.
@@ -6,6 +23,11 @@
* gen-bases.c: In generated file, include just gmp-impl.h, not gmp.h
+2017-01-29 Torbjörn Granlund <tg at gmplib.org>
+
+ * configure.ac: Don't check if we got a C99 compiler for now (partially
+ revert 2017-01-24 change as C++ compilers become rejected).
+
2017-01-24 Torbjörn Granlund <tg at gmplib.org>
* mpn/generic/compute_powtab.c: New file, providing mpn_compute_powtab
diff -r ac1ddf728e5b -r ff64a5705a4c gen-bases.c
--- a/gen-bases.c Mon Feb 06 23:20:36 2017 +0100
+++ b/gen-bases.c Tue Feb 07 15:28:35 2017 +0100
@@ -33,9 +33,11 @@
int chars_per_limb;
+int big_base_ctz;
mpz_t big_base;
int normalization_steps;
mpz_t big_base_inverted;
+mpz_t big_base_binverted;
mpz_t t;
@@ -51,6 +53,17 @@
}
void
+binvert (int numb_bits)
+{
+ int i;
+ mpz_t bbo;
+
+ mpz_init_set (bbo, big_base);
+ big_base_ctz = mpz_make_odd (bbo);
+ mpz_invert_2exp (big_base_binverted, bbo, numb_bits);
+}
+
+void
generate (int limb_bits, int nail_bits, int base)
{
int numb_bits = limb_bits - nail_bits;
@@ -73,6 +86,8 @@
mpz_mul_2exp (t, t, 2*limb_bits - normalization_steps);
mpz_tdiv_q (big_base_inverted, t, big_base);
mpz_clrbit (big_base_inverted, limb_bits);
+
+ binvert (numb_bits);
}
void
@@ -90,12 +105,16 @@
printf ("\n");
printf ("/* mp_bases[10] data, as literal values */\n");
printf ("#define MP_BASES_CHARS_PER_LIMB_10 %d\n", chars_per_limb);
+ printf ("#define MP_BASES_BIG_BASE_CTZ_10 %d\n", big_base_ctz);
printf ("#define MP_BASES_BIG_BASE_10 CNST_LIMB(0x");
mpz_out_str (stdout, 16, big_base);
printf (")\n");
printf ("#define MP_BASES_BIG_BASE_INVERTED_10 CNST_LIMB(0x");
mpz_out_str (stdout, 16, big_base_inverted);
printf (")\n");
+ printf ("#define MP_BASES_BIG_BASE_BINVERTED_10 CNST_LIMB(0x");
+ mpz_out_str (stdout, 16, big_base_binverted);
+ printf (")\n");
printf ("#define MP_BASES_NORMALIZATION_STEPS_10 %d\n", normalization_steps);
}
@@ -212,6 +231,7 @@
mpz_init (big_base);
mpz_init (big_base_inverted);
+ mpz_init (big_base_binverted);
mpz_init (t);
if (argc != 4)
diff -r ac1ddf728e5b -r ff64a5705a4c mpn/generic/compute_powtab.c
--- a/mpn/generic/compute_powtab.c Mon Feb 06 23:20:36 2017 +0100
+++ b/mpn/generic/compute_powtab.c Tue Feb 07 15:28:35 2017 +0100
@@ -236,7 +236,16 @@
if (digits_in_base != exptab[pi]) /* if ((((un - 1) >> pi) & 2) == 0) */
{
- mpn_divexact_1 (t, t, n, big_base);
+ if (__GMP_LIKELY (base == 10))
+ mpn_pi1_bdiv_q_1 (t, t, n, big_base,
+ MP_BASES_BIG_BASE_BINVERTED_10,
+ MP_BASES_BIG_BASE_CTZ_10);
+ else
+ /* FIXME: We could use _pi1 here if we add big_base_binverted and
+ big_base_ctz fields to struct bases. That would add about 2 KiB
+ to mp_bases.c. */
+ mpn_bdiv_q_1 (t, t, n, big_base);
+
n -= t[n - 1] == 0;
digits_in_base -= chars_per_limb;
}
More information about the gmp-commit
mailing list