[Gmp-commit] /var/hg/gmp: 2 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Sat Mar 15 20:28:39 UTC 2014


details:   /var/hg/gmp/rev/03c0799f3dc0
changeset: 16338:03c0799f3dc0
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sat Mar 15 21:26:50 2014 +0100
description:
Retune.

details:   /var/hg/gmp/rev/545e958a592b
changeset: 16339:545e958a592b
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sat Mar 15 21:27:33 2014 +0100
description:
Trivial merge.

diffstat:

 ChangeLog                             |    4 +
 mini-gmp/mini-gmp.c                   |   19 +-
 mini-gmp/mini-gmp.h                   |    3 +-
 mini-gmp/tests/t-pprime_p.c           |    2 +-
 mpn/s390_64/z10/gmp-mparam.h          |  159 +++++++++++++-----------
 mpn/sparc64/ultrasparc34/gmp-mparam.h |  Bin 
 mpn/x86/atom/gmp-mparam.h             |  216 +++++++++++++++++++--------------
 mpn/x86/bd1/gmp-mparam.h              |  208 ++++++++++++++++++++++++++++++++
 mpn/x86/coreihwl/gmp-mparam.h         |  208 ++++++++++++++++++++++++++++++++
 mpn/x86_64/atom/gmp-mparam.h          |  199 +++++++++++++++---------------
 mpn/x86_64/coreihwl/gmp-mparam.h      |  200 ++++++++++++++++---------------
 mpn/x86_64/coreisbr/gmp-mparam.h      |  177 +++++++++++++--------------
 mpn/x86_64/k10/gmp-mparam.h           |  116 +++++++++--------
 13 files changed, 998 insertions(+), 513 deletions(-)

diffs (truncated from 1858 to 300 lines):

diff -r 013f1cd73c4d -r 545e958a592b ChangeLog
--- a/ChangeLog	Fri Mar 14 13:15:24 2014 +0100
+++ b/ChangeLog	Sat Mar 15 21:27:33 2014 +0100
@@ -1,3 +1,7 @@
+2014-02-21 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+	* mini-gmp/mini-gmp.c (mpz_probab_prime_p): Micro-optimisation.
+
 2014-03-12  Torbjorn Granlund  <tege at gmplib.org>
 
 	* mpn/x86/bd2/gmp-mparam.h: New file.
diff -r 013f1cd73c4d -r 545e958a592b mini-gmp/mini-gmp.c
--- a/mini-gmp/mini-gmp.c	Fri Mar 14 13:15:24 2014 +0100
+++ b/mini-gmp/mini-gmp.c	Sat Mar 15 21:27:33 2014 +0100
@@ -3363,7 +3363,7 @@
 gmp_millerrabin (const mpz_t n, const mpz_t nm1, mpz_t y,
 		 const mpz_t q, mp_bitcnt_t k)
 {
-  mp_bitcnt_t i;
+  assert (k > 0);
 
   /* Caller must initialize y to the base. */
   mpz_powm (y, y, q, n);
@@ -3371,12 +3371,15 @@
   if (mpz_cmp_ui (y, 1) == 0 || mpz_cmp (y, nm1) == 0)
     return 1;
 
-  for (i = 1; i < k; i++)
+  while (--k > 0)
     {
       mpz_powm_ui (y, y, 2, n);
       if (mpz_cmp (y, nm1) == 0)
 	return 1;
-      if (mpz_cmp_ui (y, 1) == 0)
+      /* y == 1 means that the previous y was a non-trivial square root
+	 of 1 (mod n). y == 0 means that n is a power of the base.
+	 In either case, n is not prime. */
+      if (mpz_cmp_ui (y, 1) <= 0)
 	return 0;
     }
   return 0;
@@ -3427,21 +3430,21 @@
   mpz_init (y);
 
   /* Find q and k, where q is odd and n = 1 + 2**k * q.  */
-  mpz_abs (nm1, n);
-  mpz_sub_ui (nm1, nm1, 1);
+  nm1->_mp_size = mpz_abs_sub_ui (nm1, n, 1);
   k = mpz_scan1 (nm1, 0);
   mpz_tdiv_q_2exp (q, nm1, k);
   
-  for (j = 0, is_prime = 1; is_prime && j < reps; j++)
+  for (j = 0, is_prime = 1; is_prime & (j < reps); j++)
     {
       mpz_set_ui (y, (unsigned long) j*j+j+41);
       if (mpz_cmp (y, nm1) >= 0)
 	{
-	  /* Don't try any further bases. */
+	  /* Don't try any further bases. This "early" break does not affect
+	     the result for any reasonable reps value (<=5000 was tested) */
 	  assert (j >= 30);
 	  break;
 	}
-      is_prime &= gmp_millerrabin (n, nm1, y, q, k);
+      is_prime = gmp_millerrabin (n, nm1, y, q, k);
     }
   mpz_clear (nm1);
   mpz_clear (q);
diff -r 013f1cd73c4d -r 545e958a592b mini-gmp/mini-gmp.h
--- a/mini-gmp/mini-gmp.h	Fri Mar 14 13:15:24 2014 +0100
+++ b/mini-gmp/mini-gmp.h	Sat Mar 15 21:27:33 2014 +0100
@@ -215,8 +215,7 @@
 void mpz_fac_ui (mpz_t, unsigned long);
 void mpz_bin_uiui (mpz_t, unsigned long, unsigned long);
 
-int
-mpz_probab_prime_p (const mpz_t, int);
+int mpz_probab_prime_p (const mpz_t, int);
 
 int mpz_tstbit (const mpz_t, mp_bitcnt_t);
 void mpz_setbit (mpz_t, mp_bitcnt_t);
diff -r 013f1cd73c4d -r 545e958a592b mini-gmp/tests/t-pprime_p.c
--- a/mini-gmp/tests/t-pprime_p.c	Fri Mar 14 13:15:24 2014 +0100
+++ b/mini-gmp/tests/t-pprime_p.c	Sat Mar 15 21:27:33 2014 +0100
@@ -93,7 +93,7 @@
 
   mpz_init (n);
 
-  for (i = 0; i < 300; i++)
+  for (i = 0; i < 1700; i++)
     {
       mpz_set_si (n, i);
       check_pn (n, isprime (i));
diff -r 013f1cd73c4d -r 545e958a592b mpn/s390_64/z10/gmp-mparam.h
--- a/mpn/s390_64/z10/gmp-mparam.h	Fri Mar 14 13:15:24 2014 +0100
+++ b/mpn/s390_64/z10/gmp-mparam.h	Sat Mar 15 21:27:33 2014 +0100
@@ -32,7 +32,7 @@
 #define GMP_LIMB_BYTES 8
 
 /* 4400 MHz IBM z10 */
-/* FFT tuning limit = 5000000 */
+/* FFT tuning limit = 15000000 */
 /* Generated by tuneup.c, 2014-03-12, gcc 4.7 */
 
 #define DIVREM_1_NORM_THRESHOLD              0  /* always */
@@ -77,57 +77,61 @@
 #define MULMOD_BNM1_THRESHOLD                9
 #define SQRMOD_BNM1_THRESHOLD                9
 
-#define MUL_FFT_MODF_THRESHOLD             252  /* k = 5 */
+#define MUL_FFT_MODF_THRESHOLD             220  /* k = 5 */
 #define MUL_FFT_TABLE3                                      \
-  { {    252, 5}, {      9, 6}, {      5, 5}, {     11, 6}, \
-    {      6, 5}, {     13, 6}, {      7, 5}, {     15, 6}, \
+  { {    220, 5}, {      7, 4}, {     15, 5}, {      9, 6}, \
+    {      5, 5}, {     11, 6}, {      6, 5}, {     13, 6}, \
     {     11, 7}, {      6, 6}, {     13, 7}, {      7, 6}, \
-    {     15, 7}, {      9, 8}, {      5, 7}, {     13, 8}, \
-    {      7, 7}, {     15, 8}, {      9, 7}, {     19, 8}, \
-    {     11, 7}, {     23, 8}, {     13, 9}, {      7, 8}, \
-    {     15, 7}, {     31, 8}, {     19, 9}, {     11, 8}, \
-    {     23,10}, {      7, 9}, {     15, 8}, {     33, 9}, \
+    {     15, 7}, {     13, 8}, {      7, 7}, {     16, 8}, \
+    {      9, 7}, {     19, 8}, {     11, 7}, {     23, 8}, \
+    {     13, 9}, {      7, 8}, {     15, 7}, {     31, 8}, \
+    {     19, 9}, {     11, 8}, {     23,10}, {      7, 9}, \
+    {     15, 8}, {     33, 9}, {     19, 8}, {     39, 9}, \
     {     27,10}, {     15, 9}, {     39,10}, {     23,11}, \
     {     15,10}, {     31, 9}, {     67,10}, {     39, 9}, \
-    {     79, 8}, {    159,10}, {     47,11}, {     31,10}, \
-    {     63, 9}, {    127, 8}, {    255,10}, {     71, 9}, \
-    {    143, 8}, {    287, 7}, {    575,10}, {     79, 9}, \
-    {    159,11}, {     47,12}, {     31,11}, {     63,10}, \
-    {    127, 9}, {    255, 8}, {    511,10}, {    143, 9}, \
-    {    287, 8}, {    575,11}, {     79,10}, {    159, 9}, \
-    {    319,10}, {    175, 9}, {    351, 8}, {    703, 7}, \
+    {     83,10}, {     47,11}, {     31,10}, {     63, 9}, \
+    {    127, 8}, {    255, 7}, {    511,10}, {     71, 9}, \
+    {    143, 8}, {    287, 7}, {    575,10}, {     79,11}, \
+    {     47,12}, {     31,11}, {     63,10}, {    127, 9}, \
+    {    255, 8}, {    511,10}, {    143, 9}, {    287, 8}, \
+    {    575,11}, {     79,10}, {    159, 9}, {    319, 8}, \
+    {    639,10}, {    175, 9}, {    351, 8}, {    703, 7}, \
     {   1407, 6}, {   2815,10}, {    191, 9}, {    383, 8}, \
-    {    767, 9}, {    415,10}, {    223, 9}, {    447, 8}, \
-    {    895,12}, {     63,11}, {    127,10}, {    255, 9}, \
-    {    511,11}, {    143,10}, {    287, 9}, {    575, 8}, \
-    {   1151,11}, {    159,10}, {    319, 9}, {    639,11}, \
-    {    175,10}, {    351, 9}, {    703, 8}, {   1407, 7}, \
-    {   2815,11}, {    191,10}, {    383, 9}, {    767,10}, \
-    {    415,11}, {    223,10}, {    447, 9}, {    895, 8}, \
-    {   1791,11}, {    239,13}, {     63,12}, {    127,11}, \
-    {    255,10}, {    511,11}, {    287,10}, {    575, 9}, \
-    {   1151,12}, {    159,11}, {    319,10}, {    703, 9}, \
+    {    767, 9}, {    415,11}, {    111,10}, {    223, 9}, \
+    {    447, 8}, {    895,12}, {     63,11}, {    127,10}, \
+    {    255, 9}, {    511,11}, {    143,10}, {    287, 9}, \
+    {    575, 8}, {   1151,10}, {    319, 9}, {    639,11}, \
+    {    175, 9}, {    703, 8}, {   1407, 7}, {   2815,11}, \
+    {    191,10}, {    415, 9}, {    831,11}, {    223,13}, \
+    {     63,12}, {    127,11}, {    255,10}, {    511,11}, \
+    {    287,10}, {    575, 9}, {   1151,12}, {    159,11}, \
+    {    319,10}, {    639,11}, {    351,10}, {    703, 9}, \
     {   1407, 8}, {   2815,12}, {    191,11}, {    383,10}, \
-    {    767,11}, {    415,10}, {    831,12}, {    223,11}, \
-    {    447,10}, {    895, 9}, {   1791, 8}, {   3583,11}, \
-    {    479,10}, {    959, 9}, {   1919,13}, {    127,12}, \
-    {    255,11}, {    511,12}, {    287,11}, {    575,10}, \
-    {   1151,12}, {    319,11}, {    639,12}, {    351,11}, \
-    {    703,10}, {   1407, 9}, {   2815,13}, {    191,12}, \
-    {    383,11}, {    767,12}, {    415,11}, {    831,10}, \
-    {   1663,12}, {    447,11}, {    895,10}, {   1791, 9}, \
-    {   3583,12}, {    479,11}, {    959,10}, {   1919,14}, \
-    {    127,13}, {    255,12}, {    511,11}, {   1023,12}, \
-    {    575,11}, {   1151,13}, {    319,12}, {    639,11}, \
-    {   1279,12}, {    703,11}, {   1407,10}, {   2815,13}, \
-    {    383,12}, {    767,11}, {   1535,12}, {    831,11}, \
-    {   1663,13}, {    447,12}, {    895,11}, {   1791,10}, \
-    {   3583,12}, {    959,11}, {   1919,14}, {    255,13}, \
-    {    511,12}, {   1023,13}, {    575,12}, {   1151,13}, \
-    {   8192,14}, {  16384,15}, {  32768,16}, {  65536,17}, \
-    { 131072,18}, { 262144,19}, { 524288,20}, {1048576,21}, \
-    {2097152,22}, {4194304,23}, {8388608,24} }
-#define MUL_FFT_TABLE3_SIZE 191
+    {    767,11}, {    415,10}, {    831,12}, {    223,10}, \
+    {    895, 9}, {   1791,11}, {    479,13}, {    127,12}, \
+    {    255,11}, {    511,10}, {   1023,12}, {    287,11}, \
+    {    575,10}, {   1151,12}, {    319,11}, {    639,12}, \
+    {    351,11}, {    703,10}, {   1407, 9}, {   2815,13}, \
+    {    191,12}, {    383,11}, {    767,12}, {    415,11}, \
+    {    831,10}, {   1663,12}, {    447,11}, {    895,10}, \
+    {   1791, 9}, {   3583,12}, {    479,14}, {    127,13}, \
+    {    255,12}, {    511,11}, {   1023,12}, {    575,11}, \
+    {   1151,13}, {    319,12}, {    703,11}, {   1407,10}, \
+    {   2815,13}, {    383,12}, {    767,11}, {   1535,12}, \
+    {    831,11}, {   1663,13}, {    447,12}, {    895,11}, \
+    {   1791,10}, {   3583,14}, {    255,13}, {    511,12}, \
+    {   1023,13}, {    575,12}, {   1151,13}, {    639,12}, \
+    {   1279,13}, {    703,12}, {   1407,11}, {   2815,14}, \
+    {    383,13}, {    767,12}, {   1535,13}, {    831,12}, \
+    {   1663,13}, {    895,12}, {   1791,11}, {   3583,15}, \
+    {    255,14}, {    511,13}, {   1151,14}, {    639,13}, \
+    {   1279,12}, {   2559,13}, {   1407,12}, {   2815,13}, \
+    {   1471,14}, {    767,13}, {   1663,14}, {    895,13}, \
+    {   1791,12}, {   3583,13}, {   8192,14}, {  16384,15}, \
+    {  32768,16}, {  65536,17}, { 131072,18}, { 262144,19}, \
+    { 524288,20}, {1048576,21}, {2097152,22}, {4194304,23}, \
+    {8388608,24} }
+#define MUL_FFT_TABLE3_SIZE 205
 #define MUL_FFT_THRESHOLD                 1728
 
 #define SQR_FFT_MODF_THRESHOLD             212  /* k = 5 */
@@ -147,36 +151,43 @@
     {     31,11}, {     63,10}, {    127, 9}, {    255, 8}, \
     {    511,10}, {    143, 9}, {    287, 8}, {    575,11}, \
     {     79,10}, {    159, 9}, {    319, 8}, {    639,10}, \
-    {    175, 9}, {    351, 8}, {    703, 7}, {   1407,11}, \
-    {     95,10}, {    191, 9}, {    383, 8}, {    767,10}, \
-    {    207,11}, {    111,12}, {     63,11}, {    127,10}, \
-    {    255, 9}, {    511,11}, {    143,10}, {    287, 9}, \
-    {    575, 8}, {   1151,11}, {    159,10}, {    319, 9}, \
-    {    639,11}, {    175,10}, {    351, 9}, {    703, 8}, \
-    {   1407,11}, {    191,10}, {    383, 9}, {    767,11}, \
-    {    223,13}, {     63,12}, {    127,11}, {    255,10}, \
-    {    511,11}, {    287,10}, {    575, 9}, {   1151,12}, \
-    {    159,11}, {    319,10}, {    639,11}, {    351,10}, \
-    {    703, 9}, {   1407, 8}, {   2815,12}, {    191,11}, \
-    {    383,10}, {    767,11}, {    415,12}, {    223,11}, \
-    {    447,10}, {    895, 9}, {   1791,11}, {    479,13}, \
-    {    127,12}, {    255,11}, {    511,12}, {    287,11}, \
-    {    575,10}, {   1151,12}, {    319,11}, {    639,12}, \
-    {    351,11}, {    703,10}, {   1407, 9}, {   2815,13}, \
+    {    175, 9}, {    351, 8}, {    703,10}, {    191, 9}, \
+    {    383, 8}, {    767,10}, {    207,11}, {    111,12}, \
+    {     63,11}, {    127,10}, {    255, 9}, {    511,11}, \
+    {    143,10}, {    287, 9}, {    575, 8}, {   1151,11}, \
+    {    159,10}, {    319, 9}, {    639,11}, {    175,10}, \
+    {    351, 9}, {    703,12}, {     95,11}, {    191,10}, \
+    {    383, 9}, {    767,11}, {    207,10}, {    415,13}, \
+    {     63,12}, {    127,11}, {    255,10}, {    511,11}, \
+    {    287,10}, {    575, 9}, {   1151,12}, {    159,11}, \
+    {    319,10}, {    639,11}, {    351,10}, {    703, 9}, \
+    {   1407,12}, {    191,11}, {    383,10}, {    767,11}, \
+    {    415,12}, {    223,11}, {    447,10}, {    895, 9}, \
+    {   1791,13}, {    127,12}, {    255,11}, {    511,12}, \
+    {    287,11}, {    575,10}, {   1151,12}, {    319,11}, \
+    {    639,12}, {    351,11}, {    703,10}, {   1407,13}, \
     {    191,12}, {    383,11}, {    767,12}, {    415,11}, \
     {    831,10}, {   1663,12}, {    447,11}, {    895,10}, \
-    {   1791,12}, {    479,11}, {    959,14}, {    127,13}, \
-    {    255,12}, {    511,11}, {   1023,12}, {    575,11}, \
-    {   1151,13}, {    319,12}, {    639,11}, {   1279,12}, \
-    {    703,11}, {   1407,10}, {   2815,13}, {    383,12}, \
-    {    767,11}, {   1535,12}, {    831,11}, {   1663,13}, \
-    {    447,12}, {    895,11}, {   1791,10}, {   3583,12}, \
-    {    959,11}, {   1919,14}, {    255,13}, {    511,12}, \
-    {   1023,13}, {    575,12}, {   1151,13}, {   8192,14}, \
-    {  16384,15}, {  32768,16}, {  65536,17}, { 131072,18}, \
-    { 262144,19}, { 524288,20}, {1048576,21}, {2097152,22}, \
-    {4194304,23}, {8388608,24} }
-#define SQR_FFT_TABLE3_SIZE 174
+    {   1791, 9}, {   3583,12}, {    479,11}, {    959,10}, \
+    {   1919,14}, {    127,13}, {    255,12}, {    511,11}, \
+    {   1023,12}, {    575,11}, {   1151,13}, {    319,12}, \
+    {    639,11}, {   1279,12}, {    703,11}, {   1407,10}, \
+    {   2815,13}, {    383,12}, {    767,11}, {   1535,12}, \
+    {    831,11}, {   1663,13}, {    447,12}, {    895,11}, \
+    {   1791,12}, {    959,11}, {   1919,14}, {    255,13}, \
+    {    511,12}, {   1023,13}, {    575,12}, {   1151,13}, \
+    {    639,12}, {   1279,13}, {    703,12}, {   1407,11}, \
+    {   2815,14}, {    383,13}, {    767,12}, {   1535,13}, \
+    {    831,12}, {   1663,13}, {    895,12}, {   1791,11}, \
+    {   3583,13}, {    959,12}, {   1919,15}, {    255,14}, \
+    {    511,13}, {   1023,12}, {   2047,13}, {   1151,14}, \
+    {    639,13}, {   1279,12}, {   2559,13}, {   1407,12}, \
+    {   2815,14}, {    767,13}, {   1663,14}, {    895,13}, \
+    {   1791,12}, {   3583,13}, {   8192,14}, {  16384,15}, \
+    {  32768,16}, {  65536,17}, { 131072,18}, { 262144,19}, \
+    { 524288,20}, {1048576,21}, {2097152,22}, {4194304,23}, \
+    {8388608,24} }
+#define SQR_FFT_TABLE3_SIZE 201
 #define SQR_FFT_THRESHOLD                 1728
 
 #define MULLO_BASECASE_THRESHOLD             0  /* always */
diff -r 013f1cd73c4d -r 545e958a592b mpn/sparc64/ultrasparc34/gmp-mparam.h
Binary file mpn/sparc64/ultrasparc34/gmp-mparam.h has changed
diff -r 013f1cd73c4d -r 545e958a592b mpn/x86/atom/gmp-mparam.h
--- a/mpn/x86/atom/gmp-mparam.h	Fri Mar 14 13:15:24 2014 +0100
+++ b/mpn/x86/atom/gmp-mparam.h	Sat Mar 15 21:27:33 2014 +0100
@@ -1,6 +1,6 @@
 /* Intel Atom/32 gmp-mparam.h -- Compiler/machine parameter header file.
 
-Copyright 1991, 1993, 1994, 2000-2011 Free Software Foundation, Inc.
+Copyright 1991, 1993, 1994, 2000-2011, 2014 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -31,133 +31,171 @@
 #define GMP_LIMB_BITS 32
 #define GMP_LIMB_BYTES 4


More information about the gmp-commit mailing list