[Gmp-commit] /home/hgfiles/gmp: 2 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Tue Dec 22 03:47:50 CET 2009


details:   /home/hgfiles/gmp/rev/2a46c0efecb5
changeset: 13175:2a46c0efecb5
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Tue Dec 22 03:42:37 2009 +0100
description:
With Niels: Add redzones.  Get itch function calls right.

details:   /home/hgfiles/gmp/rev/573e6a2019e4
changeset: 13176:573e6a2019e4
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Tue Dec 22 03:47:42 2009 +0100
description:
Increase some tests/mpn iteration counts.

diffstat:

 ChangeLog               |   6 ++++
 tests/mpn/t-bdiv.c      |  59 +++++++++++++++++++++++++++++++++++++++++-------
 tests/mpn/t-invert.c    |   2 +-
 tests/mpn/t-matrix22.c  |   2 +-
 tests/mpn/t-mullo.c     |   2 +-
 tests/mpn/t-toom33.c    |   2 +-
 tests/mpn/t-toom44.c    |   2 +-
 tests/mpn/toom-shared.h |   2 +-
 8 files changed, 62 insertions(+), 15 deletions(-)

diffs (208 lines):

diff -r 1374ef68341b -r 573e6a2019e4 ChangeLog
--- a/ChangeLog	Tue Dec 22 02:32:45 2009 +0100
+++ b/ChangeLog	Tue Dec 22 03:47:42 2009 +0100
@@ -1,11 +1,17 @@
 2009-12-22  Torbjorn Granlund  <tege at gmplib.org>
 
+	* tests/mpn/t-bdiv.c: Get itch function calls right.
+
 	* mpn/generic/mu_bdiv_q.c (mpn_mu_bdiv_q_itch): Rewrite.
 	* mpn/generic/mu_bdiv_qr.c (mpn_mu_bdiv_qr_itch): Simplify.
 
 	* mpn/generic/bdiv_qr.c (mpn_bdiv_qr): Simplify, don't allocate.
 	(mpn_bdiv_qr_itch): Conditionalise on MU_BDIV_QR_THRESHOLD.
 
+2009-12-18  Niels Möller  <nisse at lysator.liu.se>
+
+	* tests/mpn/t-bdiv.c: Add redzones.
+
 2009-12-21  Torbjorn Granlund  <tege at gmplib.org>
 
 	* mpn/generic/sbpi1_div_q.c: Fix fixup code for to work for qn = 0.
diff -r 1374ef68341b -r 573e6a2019e4 tests/mpn/t-bdiv.c
--- a/tests/mpn/t-bdiv.c	Tue Dec 22 02:32:45 2009 +0100
+++ b/tests/mpn/t-bdiv.c	Tue Dec 22 03:47:42 2009 +0100
@@ -74,16 +74,16 @@
   return cy == rh && c == 0;
 }
 
-#define SIZE_LOG 10
+#define SIZE_LOG 11
 #define MAX_DN (1L << SIZE_LOG)
 #define MAX_NN (1L << (SIZE_LOG + 1))
 
-#define COUNT 100
+#define COUNT 500
 int
 main (int argc, char **argv)
 {
   mp_ptr np, dp, qp, rp, scratch;
-  mp_size_t itch;
+  mp_size_t max_qr_itch, max_q_itch, max_itch;
   int count = COUNT;
   int test;
   gmp_randstate_ptr rands;
@@ -111,14 +111,19 @@
 
   /* Claim larger nn that we'll use, to allow for a large quotient.
      FIXME: This probably isn't the right way. */
-  itch = mpn_bdiv_qr_itch (MAX_NN + MAX_DN, MAX_DN);
-  scratch = TMP_ALLOC_LIMBS (itch);
+  max_qr_itch = mpn_bdiv_qr_itch (MAX_NN + MAX_DN, MAX_DN);
+  max_q_itch = mpn_bdiv_q_itch (MAX_NN + MAX_DN, MAX_DN);
+  max_itch = MAX (max_qr_itch, max_q_itch);
+  scratch = 1 + TMP_ALLOC_LIMBS (max_itch + 2);
 
   for (test = 0; test < count; test++)
     {
       unsigned size_range;
       mp_size_t nn, dn;
+      mp_size_t itch;
       mp_limb_t rh;
+      mp_limb_t s_before;
+      mp_limb_t s_after;
 
       /* We generate dn in the range 1 <= dn <= (1 << size_range). */
       size_range = 1
@@ -132,10 +137,17 @@
       mpn_random2 (np, nn);
       dp[0] |= 1;
 
-      ASSERT_ALWAYS (mpn_bdiv_q_itch (nn, dn) <= itch);
+      itch = mpn_bdiv_q_itch (nn, dn);
+      ASSERT_ALWAYS (itch <= max_itch);
+
+      mpn_random (scratch - 1, itch + 2);
+      s_before = scratch[-1];
+      s_after = scratch[itch];
 
       mpn_bdiv_q (qp, np, nn, dp, dn, scratch);
-      if (!bdiv_q_valid_p (np, nn, dp, dn, qp))
+      if (!bdiv_q_valid_p (np, nn, dp, dn, qp)
+	  || s_before != scratch[-1]
+	  || s_after != scratch[itch])
 	{
 	  gmp_printf ("bdiv_q test %d failed, nn = %d, dn = %d:\n"
 		      "n = %Nx\n"
@@ -143,13 +155,31 @@
 		      "q = %Nx\n",
 		      test, nn, dn,
 		      np, nn, dp, dn, qp, nn);
+	  if (scratch[-1] != s_before)
+	    {
+	      printf ("before scratch:"); mpn_dump (scratch-1, 1);
+	      printf ("keep:   "); mpn_dump (&s_before, 1);
+	    }
+	  if (scratch[itch] != s_after)
+	    {
+	      printf ("after scratch:"); mpn_dump (scratch + itch, 1);
+	      printf ("keep:   "); mpn_dump (&s_after, 1);
+	    }
+
 	  abort();
 	}
 
-      ASSERT_ALWAYS (mpn_bdiv_qr_itch (nn, dn) <= itch);
+      itch = mpn_bdiv_qr_itch (nn, dn);
+      ASSERT_ALWAYS (itch <= max_itch);
+
+      mpn_random (scratch - 1, itch + 2);
+      s_before = scratch[-1];
+      s_after = scratch[itch];
 
       rh = mpn_bdiv_qr (qp, rp, np, nn, dp, dn, scratch);
-      if (!bdiv_qr_valid_p (np,nn, dp, dn, qp, rp, rh))
+      if (!bdiv_qr_valid_p (np,nn, dp, dn, qp, rp, rh)
+	  || s_before != scratch[-1]
+	  || s_after != scratch[itch])
 	{
 	  gmp_printf ("bdiv_qr test %d failed, nn = %d, dn = %d:\n"
 		      "n = %Nx\n"
@@ -159,6 +189,17 @@
 		      test, nn, dn,
 		      np, nn, dp, dn, qp, nn - dn,
 		      rh, rp, dn);
+
+	  if (scratch[-1] != s_before)
+	    {
+	      printf ("before scratch:"); mpn_dump (scratch-1, 1);
+	      printf ("keep:   "); mpn_dump (&s_before, 1);
+	    }
+	  if (scratch[itch] != s_after)
+	    {
+	      printf ("after scratch:"); mpn_dump (scratch + itch, 1);
+	      printf ("keep:   "); mpn_dump (&s_after, 1);
+	    }
 	  abort();
 	}
     }
diff -r 1374ef68341b -r 573e6a2019e4 tests/mpn/t-invert.c
--- a/tests/mpn/t-invert.c	Tue Dec 22 02:32:45 2009 +0100
+++ b/tests/mpn/t-invert.c	Tue Dec 22 03:47:42 2009 +0100
@@ -33,7 +33,7 @@
 #endif
 
 #ifndef COUNT
-#define COUNT 300
+#define COUNT 1000
 #endif
 
 #define MAX_N (1L << SIZE_LOG)
diff -r 1374ef68341b -r 573e6a2019e4 tests/mpn/t-matrix22.c
--- a/tests/mpn/t-matrix22.c	Tue Dec 22 02:32:45 2009 +0100
+++ b/tests/mpn/t-matrix22.c	Tue Dec 22 03:47:42 2009 +0100
@@ -185,7 +185,7 @@
   matrix_init (&B, MAX_SIZE);
   mpz_init (bs);
 
-  for (i = 0; i < 17; i++)
+  for (i = 0; i < 1000; i++)
     {
       mp_size_t an, bn;
       mpz_urandomb (bs, rands, 32);
diff -r 1374ef68341b -r 573e6a2019e4 tests/mpn/t-mullo.c
--- a/tests/mpn/t-mullo.c	Tue Dec 22 02:32:45 2009 +0100
+++ b/tests/mpn/t-mullo.c	Tue Dec 22 03:47:42 2009 +0100
@@ -31,7 +31,7 @@
 #endif
 
 #ifndef COUNT
-#define COUNT 5000
+#define COUNT 10000
 #endif
 
 #define MAX_N (1L << SIZE_LOG)
diff -r 1374ef68341b -r 573e6a2019e4 tests/mpn/t-toom33.c
--- a/tests/mpn/t-toom33.c	Tue Dec 22 02:32:45 2009 +0100
+++ b/tests/mpn/t-toom33.c	Tue Dec 22 03:47:42 2009 +0100
@@ -6,6 +6,6 @@
 #define MIN_AN MUL_TOOM33_THRESHOLD
 #define MIN_BN(an) (1 + 2*(((an)+2)/(size_t) 3))
 
-#define COUNT 100
+#define COUNT 1000
 
 #include "toom-shared.h"
diff -r 1374ef68341b -r 573e6a2019e4 tests/mpn/t-toom44.c
--- a/tests/mpn/t-toom44.c	Tue Dec 22 02:32:45 2009 +0100
+++ b/tests/mpn/t-toom44.c	Tue Dec 22 03:47:42 2009 +0100
@@ -4,6 +4,6 @@
 #define MIN_AN MUL_TOOM44_THRESHOLD
 #define MIN_BN(an) (1 + 3*(((an)+3)>>2))
 
-#define COUNT 100
+#define COUNT 1000
 
 #include "toom-shared.h"
diff -r 1374ef68341b -r 573e6a2019e4 tests/mpn/toom-shared.h
--- a/tests/mpn/toom-shared.h	Tue Dec 22 02:32:45 2009 +0100
+++ b/tests/mpn/toom-shared.h	Tue Dec 22 03:47:42 2009 +0100
@@ -35,7 +35,7 @@
 #endif
 
 #ifndef COUNT
-#define COUNT 300
+#define COUNT 2000
 #endif
 
 #define MAX_AN (1L << SIZE_LOG)


More information about the gmp-commit mailing list