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

mercurial at gmplib.org mercurial at gmplib.org
Sun Jan 20 15:58:33 CET 2013


details:   /var/hg/gmp/rev/4bdf9f64c0a1
changeset: 15334:4bdf9f64c0a1
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sun Jan 20 15:58:05 2013 +0100
description:
(main): Put random junk at qp[] instead of zeroing.

details:   /var/hg/gmp/rev/c8538b70fce6
changeset: 15335:c8538b70fce6
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sun Jan 20 15:58:27 2013 +0100
description:
ChangeLog

diffstat:

 ChangeLog         |   4 ++++
 tests/mpn/t-div.c |  38 +++++++++++++++++++++-----------------
 2 files changed, 25 insertions(+), 17 deletions(-)

diffs (176 lines):

diff -r a3f46985b1e4 -r c8538b70fce6 ChangeLog
--- a/ChangeLog	Sun Jan 20 14:33:39 2013 +0100
+++ b/ChangeLog	Sun Jan 20 15:58:27 2013 +0100
@@ -1,10 +1,14 @@
 2013-01-20  Torbjorn Granlund  <tege at gmplib.org>
 
+	* Makefile.am (check-mini-gmp): Set also DYLD_LIBRARY_PATH for the
+	benefit of Darwin.
+
 	* tests/mpn/t-div.c: Test mpn_sb_div_qr_sec and mpn_sb_div_r_sec.
 	(main): Separate divisor into normalised (dnp) and unnormalised (dup),
 	pass appropriate variant to each function.
 	(main): Make negative `test' index value mean divisor bits, for better
 	small operands coverage.
+	(main): Put random junk at qp[] instead of zeroing.
 
 	* tests/mpz/t-remove.c: Back out last change which left `divisor_size'
 	uninitialised; achieve change's aim with a parameter tweak.
diff -r a3f46985b1e4 -r c8538b70fce6 tests/mpn/t-div.c
--- a/tests/mpn/t-div.c	Sun Jan 20 14:33:39 2013 +0100
+++ b/tests/mpn/t-div.c	Sun Jan 20 15:58:27 2013 +0100
@@ -142,9 +142,9 @@
 {
   gmp_randstate_ptr rands;
   unsigned long maxnbits, maxdbits, nbits, dbits;
-  mpz_t n, d, q, r, tz;
+  mpz_t n, d, q, r, tz, junk;
   mp_size_t maxnn, maxdn, nn, dn, clearn, i;
-  mp_ptr np, dup, dnp, qp, rp;
+  mp_ptr np, dup, dnp, qp, rp, junkp;
   mp_limb_t t;
   gmp_pi1_t dinv;
   long count = COUNT;
@@ -176,6 +176,7 @@
   mpz_init (q);
   mpz_init (r);
   mpz_init (tz);
+  mpz_init (junk);
 
   maxnn = maxnbits / GMP_NUMB_BITS + 1;
   maxdn = maxdbits / GMP_NUMB_BITS + 1;
@@ -184,12 +185,12 @@
 
   qp = TMP_ALLOC_LIMBS (maxnn + 2) + 1;
   rp = TMP_ALLOC_LIMBS (maxnn + 2) + 1;
-  dnp = TMP_ALLOC_LIMBS (maxdn + 2) + 1;
+  dnp = TMP_ALLOC_LIMBS (maxdn);
 
   alloc = 1;
   scratch = __GMP_ALLOCATE_FUNC_LIMBS (alloc);
 
-  for (test = -300; test < count;)
+  for (test = -300; test < count; test++)
     {
       nbits = random_word (rands) % (maxnbits - GMP_NUMB_BITS) + 2 * GMP_NUMB_BITS;
 
@@ -234,6 +235,9 @@
       ASSERT_ALWAYS (nn <= maxnn);
       ASSERT_ALWAYS (dn <= maxdn);
 
+      mpz_urandomb (junk, rands, nbits);
+      junkp = PTR (junk);
+
       np = PTR (n);
 
       mpz_urandomb (tz, rands, 32);
@@ -260,9 +264,8 @@
 	  break;
 	}
 
-      test++;
-
-      invert_pi1 (dinv, dnp[dn - 1], dnp[dn - 2]);
+      if (dn >= 2)
+	invert_pi1 (dinv, dnp[dn - 1], dnp[dn - 2]);
 
       rran0 = random_word (rands);
       rran1 = random_word (rands);
@@ -282,7 +285,7 @@
 	    {
 	      MPN_COPY (rp, np, nn);
 	      if (nn > dn)
-		MPN_ZERO (qp, nn - dn);
+		MPN_COPY (qp, junkp, nn - dn);
 	      qp[nn - dn] = mpn_sbpi1_div_qr (qp, rp, nn, dnp, dn, dinv.inv32);
 	      check_one (qp, rp, np, nn, dnp, dn, "mpn_sbpi1_div_qr", 0);
 	    }
@@ -292,7 +295,7 @@
 	    {
 	      MPN_COPY (rp, np, nn);
 	      if (nn > dn)
-		MPN_ZERO (qp, nn - dn);
+		MPN_COPY (qp, junkp, nn - dn);
 	      qp[nn - dn] = mpn_sbpi1_divappr_q (qp, rp, nn, dnp, dn, dinv.inv32);
 	      check_one (qp, NULL, np, nn, dnp, dn, "mpn_sbpi1_divappr_q", 1);
 	    }
@@ -302,7 +305,7 @@
 	    {
 	      MPN_COPY (rp, np, nn);
 	      if (nn > dn)
-		MPN_ZERO (qp, nn - dn);
+		MPN_COPY (qp, junkp, nn - dn);
 	      qp[nn - dn] = mpn_sbpi1_div_q (qp, rp, nn, dnp, dn, dinv.inv32);
 	      check_one (qp, NULL, np, nn, dnp, dn, "mpn_sbpi1_div_q", 0);
 	    }
@@ -317,7 +320,7 @@
 	  scratch[itch] = ran;
 	  MPN_COPY (rp, np, nn);
 	  if (nn >= dn)
-	    MPN_ZERO (qp, nn - dn + 1);
+	    MPN_COPY (qp, junkp, nn - dn + 1);
 	  mpn_sb_div_qr_sec (qp, rp, nn, dup, dn, scratch);
 	  ASSERT_ALWAYS (ran == scratch[itch]);
 	  check_one (qp, rp, np, nn, dup, dn, "mpn_sb_div_qr_sec", 0);
@@ -343,7 +346,7 @@
 	{
 	  MPN_COPY (rp, np, nn);
 	  if (nn > dn)
-	    MPN_ZERO (qp, nn - dn);
+	    MPN_COPY (qp, junkp, nn - dn);
 	  qp[nn - dn] = mpn_dcpi1_div_qr (qp, rp, nn, dnp, dn, &dinv);
 	  ASSERT_ALWAYS (qp[-1] == qran0);  ASSERT_ALWAYS (qp[nn - dn + 1] == qran1);
 	  ASSERT_ALWAYS (rp[-1] == rran0);
@@ -355,7 +358,7 @@
 	{
 	  MPN_COPY (rp, np, nn);
 	  if (nn > dn)
-	    MPN_ZERO (qp, nn - dn);
+	    MPN_COPY (qp, junkp, nn - dn);
 	  qp[nn - dn] = mpn_dcpi1_divappr_q (qp, rp, nn, dnp, dn, &dinv);
 	  ASSERT_ALWAYS (qp[-1] == qran0);  ASSERT_ALWAYS (qp[nn - dn + 1] == qran1);
 	  ASSERT_ALWAYS (rp[-1] == rran0);
@@ -367,7 +370,7 @@
 	{
 	  MPN_COPY (rp, np, nn);
 	  if (nn > dn)
-	    MPN_ZERO (qp, nn - dn);
+	    MPN_COPY (qp, junkp, nn - dn);
 	  qp[nn - dn] = mpn_dcpi1_div_q (qp, rp, nn, dnp, dn, &dinv);
 	  ASSERT_ALWAYS (qp[-1] == qran0);  ASSERT_ALWAYS (qp[nn - dn + 1] == qran1);
 	  ASSERT_ALWAYS (rp[-1] == rran0);
@@ -384,7 +387,7 @@
 	      alloc = itch + 1;
 	    }
 	  scratch[itch] = ran;
-	  MPN_ZERO (qp, nn - dn);
+	  MPN_COPY (qp, junkp, nn - dn);
 	  MPN_ZERO (rp, dn);
 	  rp[dn] = rran1;
 	  qp[nn - dn] = mpn_mu_div_qr (qp, rp, np, nn, dnp, dn, scratch);
@@ -404,7 +407,7 @@
 	      alloc = itch + 1;
 	    }
 	  scratch[itch] = ran;
-	  MPN_ZERO (qp, nn - dn);
+	  MPN_COPY (qp, junkp, nn - dn);
 	  qp[nn - dn] = mpn_mu_divappr_q (qp, np, nn, dnp, dn, scratch);
 	  ASSERT_ALWAYS (ran == scratch[itch]);
 	  ASSERT_ALWAYS (qp[-1] == qran0);  ASSERT_ALWAYS (qp[nn - dn + 1] == qran1);
@@ -421,7 +424,7 @@
 	      alloc = itch + 1;
 	    }
 	  scratch[itch] = ran;
-	  MPN_ZERO (qp, nn - dn);
+	  MPN_COPY (qp, junkp, nn - dn);
 	  qp[nn - dn] = mpn_mu_div_q (qp, np, nn, dnp, dn, scratch);
 	  ASSERT_ALWAYS (ran == scratch[itch]);
 	  ASSERT_ALWAYS (qp[-1] == qran0);  ASSERT_ALWAYS (qp[nn - dn + 1] == qran1);
@@ -479,6 +482,7 @@
   mpz_clear (q);
   mpz_clear (r);
   mpz_clear (tz);
+  mpz_clear (junk);
 
   tests_end ();
   return 0;


More information about the gmp-commit mailing list