[Gmp-commit] /var/hg/gmp: 4 new changesets
mercurial at gmplib.org
mercurial at gmplib.org
Thu May 10 18:32:41 CEST 2012
details: /var/hg/gmp/rev/16fe1e017f02
changeset: 14960:16fe1e017f02
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Thu May 10 18:24:30 2012 +0200
description:
mpz/bin_uiui.c: Remove unused elements from tables.
details: /var/hg/gmp/rev/bedb87f4b16c
changeset: 14961:bedb87f4b16c
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Thu May 10 18:25:34 2012 +0200
description:
Rename __gmpn_cpuvec.initialized to __gmpn_cpuvec_initialized
details: /var/hg/gmp/rev/ac1851d4c556
changeset: 14962:ac1851d4c556
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Thu May 10 18:26:36 2012 +0200
description:
mpn/generic/toom[23]*: Override global __gmpn_cpuvec_initialized with a local constant.
details: /var/hg/gmp/rev/240c6d87f9d2
changeset: 14963:240c6d87f9d2
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Thu May 10 18:30:22 2012 +0200
description:
Changelog
diffstat:
ChangeLog | 12 ++++++++++++
gmp-impl.h | 4 ++--
mpn/generic/toom22_mul.c | 1 +
mpn/generic/toom2_sqr.c | 1 +
mpn/generic/toom33_mul.c | 1 +
mpn/generic/toom3_sqr.c | 1 +
mpn/x86/fat/fat.c | 3 ++-
mpn/x86_64/fat/fat.c | 3 ++-
mpz/bin_uiui.c | 26 +++++++++++++-------------
tests/mpn/t-fat.c | 5 +++--
10 files changed, 38 insertions(+), 19 deletions(-)
diffs (234 lines):
diff -r 0a2a35bcc665 -r 240c6d87f9d2 ChangeLog
--- a/ChangeLog Wed May 09 16:18:18 2012 +0200
+++ b/ChangeLog Thu May 10 18:30:22 2012 +0200
@@ -1,3 +1,15 @@
+2012-05-10 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+ * gmp-impl.h (__gmpn_cpuvec_initialized): Was __gmpn_cpuvec.initialized
+ * mpn/x86/fat/fat.c: Use separated _initialized variable.
+ * mpn/x86_64/fat/fat.c: Likewise.
+ * tests/mpn/t-fat.c: Likewise.
+
+ * mpn/generic/toom2_sqr.c: Override global __gmpn_cpuvec_initialized.
+ * mpn/generic/toom22_mul.c: Likewise.
+ * mpn/generic/toom3_sqr.c: Likewise.
+ * mpn/generic/toom33_mul.c: Likewise.
+
2012-05-09 Marco Bodrato <bodrato at mail.dm.unipi.it>
* mini-gmp/mini-gmp.c: merge mpz_rootrem and mpz_sqrtrem.
diff -r 0a2a35bcc665 -r 240c6d87f9d2 gmp-impl.h
--- a/gmp-impl.h Wed May 09 16:18:18 2012 +0200
+++ b/gmp-impl.h Thu May 10 18:30:22 2012 +0200
@@ -4539,7 +4539,6 @@
DECL_sub_n ((*sub_n));
DECL_sublsh1_n ((*sublsh1_n));
DECL_submul_1 ((*submul_1));
- int initialized;
mp_size_t mul_toom22_threshold;
mp_size_t mul_toom33_threshold;
mp_size_t sqr_toom2_threshold;
@@ -4547,6 +4546,7 @@
mp_size_t bmod_1_to_mod_1_threshold;
};
__GMP_DECLSPEC extern struct cpuvec_t __gmpn_cpuvec;
+__GMP_DECLSPEC extern int __gmpn_cpuvec_initialized;
#endif /* x86 fat binary */
__GMP_DECLSPEC void __gmpn_cpuvec_init (void);
@@ -4554,7 +4554,7 @@
/* Get a threshold "field" from __gmpn_cpuvec, running __gmpn_cpuvec_init()
if that hasn't yet been done (to establish the right values). */
#define CPUVEC_THRESHOLD(field) \
- ((LIKELY (__gmpn_cpuvec.initialized) ? 0 : (__gmpn_cpuvec_init (), 0)), \
+ ((LIKELY (__gmpn_cpuvec_initialized) ? 0 : (__gmpn_cpuvec_init (), 0)), \
__gmpn_cpuvec.field)
diff -r 0a2a35bcc665 -r 240c6d87f9d2 mpn/generic/toom22_mul.c
--- a/mpn/generic/toom22_mul.c Wed May 09 16:18:18 2012 +0200
+++ b/mpn/generic/toom22_mul.c Thu May 10 18:30:22 2012 +0200
@@ -80,6 +80,7 @@
mp_srcptr bp, mp_size_t bn,
mp_ptr scratch)
{
+ const int __gmpn_cpuvec_initialized = 1;
mp_size_t n, s, t;
int vm1_neg;
mp_limb_t cy, cy2;
diff -r 0a2a35bcc665 -r 240c6d87f9d2 mpn/generic/toom2_sqr.c
--- a/mpn/generic/toom2_sqr.c Wed May 09 16:18:18 2012 +0200
+++ b/mpn/generic/toom2_sqr.c Thu May 10 18:30:22 2012 +0200
@@ -59,6 +59,7 @@
mp_srcptr ap, mp_size_t an,
mp_ptr scratch)
{
+ const int __gmpn_cpuvec_initialized = 1;
mp_size_t n, s;
mp_limb_t cy, cy2;
mp_ptr asm1;
diff -r 0a2a35bcc665 -r 240c6d87f9d2 mpn/generic/toom33_mul.c
--- a/mpn/generic/toom33_mul.c Wed May 09 16:18:18 2012 +0200
+++ b/mpn/generic/toom33_mul.c Thu May 10 18:30:22 2012 +0200
@@ -79,6 +79,7 @@
mp_srcptr bp, mp_size_t bn,
mp_ptr scratch)
{
+ const int __gmpn_cpuvec_initialized = 1;
mp_size_t n, s, t;
int vm1_neg;
mp_limb_t cy, vinf0;
diff -r 0a2a35bcc665 -r 240c6d87f9d2 mpn/generic/toom3_sqr.c
--- a/mpn/generic/toom3_sqr.c Wed May 09 16:18:18 2012 +0200
+++ b/mpn/generic/toom3_sqr.c Thu May 10 18:30:22 2012 +0200
@@ -68,6 +68,7 @@
mp_srcptr ap, mp_size_t an,
mp_ptr scratch)
{
+ const int __gmpn_cpuvec_initialized = 1;
mp_size_t n, s;
mp_limb_t cy, vinf0;
mp_ptr gp;
diff -r 0a2a35bcc665 -r 240c6d87f9d2 mpn/x86/fat/fat.c
--- a/mpn/x86/fat/fat.c Wed May 09 16:18:18 2012 +0200
+++ b/mpn/x86/fat/fat.c Thu May 10 18:30:22 2012 +0200
@@ -176,6 +176,7 @@
0
};
+int __gmpn_cpuvec_initialized = 0;
/* The following setups start with generic x86, then overwrite with
specifics for a chip, and higher versions of that chip.
@@ -454,5 +455,5 @@
/* Set this once the threshold fields are ready.
Use volatile to prevent it getting moved. */
- ((volatile struct cpuvec_t *) &__gmpn_cpuvec)->initialized = 1;
+ *((volatile int *) &__gmpn_cpuvec_initialized) = 1;
}
diff -r 0a2a35bcc665 -r 240c6d87f9d2 mpn/x86_64/fat/fat.c
--- a/mpn/x86_64/fat/fat.c Wed May 09 16:18:18 2012 +0200
+++ b/mpn/x86_64/fat/fat.c Thu May 10 18:30:22 2012 +0200
@@ -162,6 +162,7 @@
0
};
+int __gmpn_cpuvec_initialized = 0;
/* The following setups start with generic x86, then overwrite with
specifics for a chip, and higher versions of that chip.
@@ -352,5 +353,5 @@
/* Set this once the threshold fields are ready.
Use volatile to prevent it getting moved. */
- ((volatile struct cpuvec_t *) &__gmpn_cpuvec)->initialized = 1;
+ *((volatile int *) &__gmpn_cpuvec_initialized) = 1;
}
diff -r 0a2a35bcc665 -r 240c6d87f9d2 mpz/bin_uiui.c
--- a/mpz/bin_uiui.c Wed May 09 16:18:18 2012 +0200
+++ b/mpz/bin_uiui.c Thu May 10 18:30:22 2012 +0200
@@ -146,11 +146,11 @@
typedef mp_limb_t (* mulfunc_t) (mp_limb_t);
-static const mulfunc_t mulfunc[] = {0,mul1,mul2,mul3,mul4,mul5,mul6,mul7,mul8};
-#define M (numberof(mulfunc)-1)
+static const mulfunc_t mulfunc[] = {mul1,mul2,mul3,mul4,mul5,mul6,mul7,mul8};
+#define M (numberof(mulfunc))
/* Number of factors-of-2 removed by the corresponding mulN functon. */
-static const unsigned char tcnttab[] = {0,0,1,1,2,2,4,4,6};
+static const unsigned char tcnttab[] = {0, 1, 1, 2, 2, 4, 4, 6};
#if 1
/* This variant is inaccurate but share the code with other functions. */
@@ -237,11 +237,11 @@
while (kmax != 0 && kn < SOME_THRESHOLD)
{
- jjj = mulfunc[kmax] (j);
+ jjj = mulfunc[kmax - 1] (j);
j += kmax; /* number of factors used */
count_trailing_zeros (cnt, jjj); /* count low zeros */
jjj >>= cnt; /* remove remaining low zeros */
- j2cnt += tcnttab[kmax] + cnt; /* update low zeros count */
+ j2cnt += tcnttab[kmax - 1] + cnt; /* update low zeros count */
cy = mpn_mul_1 (kp, kp, kn, jjj); /* accumulate new factors */
kp[kn] = cy;
kn += cy != 0;
@@ -253,11 +253,11 @@
while (numfac != 0)
{
nmaxnow = MIN (nmax, numfac);
- iii = mulfunc[nmaxnow] (i);
+ iii = mulfunc[nmaxnow - 1] (i);
i += nmaxnow; /* number of factors used */
count_trailing_zeros (cnt, iii); /* count low zeros */
iii >>= cnt; /* remove remaining low zeros */
- i2cnt += tcnttab[nmaxnow] + cnt; /* update low zeros count */
+ i2cnt += tcnttab[nmaxnow - 1] + cnt; /* update low zeros count */
cy = mpn_mul_1 (np, np, nn, iii); /* accumulate new factors */
np[nn] = cy;
nn += cy != 0;
@@ -275,11 +275,11 @@
break;
numfac = j;
- jjj = mulfunc[kmax] (j);
+ jjj = mulfunc[kmax - 1] (j);
j += kmax; /* number of factors used */
count_trailing_zeros (cnt, jjj); /* count low zeros */
jjj >>= cnt; /* remove remaining low zeros */
- j2cnt += tcnttab[kmax] + cnt; /* update low zeros count */
+ j2cnt += tcnttab[kmax - 1] + cnt; /* update low zeros count */
}
/* Put back the right number of factors of 2. */
@@ -320,17 +320,17 @@
i = n - k + 1;
nmax = MIN (nmax, k);
- rp[0] = mulfunc[nmax] (i);
+ rp[0] = mulfunc[nmax - 1] (i);
rn = 1;
i += nmax; /* number of factors used */
- i2cnt = tcnttab[nmax]; /* low zeros count */
+ i2cnt = tcnttab[nmax - 1]; /* low zeros count */
numfac = k - nmax;
while (numfac != 0)
{
nmax = MIN (nmax, numfac);
- iii = mulfunc[nmax] (i);
+ iii = mulfunc[nmax - 1] (i);
i += nmax; /* number of factors used */
- i2cnt += tcnttab[nmax]; /* update low zeros count */
+ i2cnt += tcnttab[nmax - 1]; /* update low zeros count */
cy = mpn_mul_1 (rp, rp, rn, iii); /* accumulate new factors */
rp[rn] = cy;
rn += cy != 0;
diff -r 0a2a35bcc665 -r 240c6d87f9d2 tests/mpn/t-fat.c
--- a/tests/mpn/t-fat.c Wed May 09 16:18:18 2012 +0200
+++ b/tests/mpn/t-fat.c Thu May 10 18:30:22 2012 +0200
@@ -66,7 +66,7 @@
/* dummies when not a fat binary */
#if ! WANT_FAT_BINARY
struct cpuvec_t {
- int initialized;
+ int dummy;
};
struct cpuvec_t __gmpn_cpuvec;
#define ITERATE_FAT_THRESHOLDS() do { } while (0)
@@ -285,10 +285,11 @@
{
#define ITERATE(name,field) \
do { \
+ __gmpn_cpuvec_initialized = 0; \
memcpy (&__gmpn_cpuvec, &initial_cpuvec, sizeof (__gmpn_cpuvec)); \
ASSERT_ALWAYS (name != 0); \
ASSERT_ALWAYS (name == __gmpn_cpuvec.field); \
- ASSERT_ALWAYS (__gmpn_cpuvec.initialized); \
+ ASSERT_ALWAYS (__gmpn_cpuvec_initialized); \
} while (0)
ITERATE_FAT_THRESHOLDS ();
More information about the gmp-commit
mailing list