[Ecm-commits] r2592 - trunk

cvs commits ecm-commits at lists.gforge.inria.fr
Mon Feb 9 10:34:37 CET 2015


Author: zimmerma
Date: 2015-02-09 10:34:37 +0100 (Mon, 09 Feb 2015)
New Revision: 2592

Modified:
   trunk/cudawrapper.c
   trunk/factor.c
   trunk/rho.c
   trunk/test.pm1
   trunk/test.pp1
Log:
improve coverage


Modified: trunk/cudawrapper.c
===================================================================
--- trunk/cudawrapper.c	2015-02-08 20:40:26 UTC (rev 2591)
+++ trunk/cudawrapper.c	2015-02-09 09:34:37 UTC (rev 2592)
@@ -235,19 +235,8 @@
 
   mpz_clear(tmp);
 }
-#endif
 
-#ifndef WITH_GPU
 int
-gpu_ecm () 
-{
-  fprintf(stderr, "This version of libecm does not contain the GPU code.\n"
-                  "You should recompile it with ./configure --enable-gpu or\n"
-                  "link a version of libecm which contain the GPU code.\n");
-  return ECM_ERROR;
-}
-#else
-int
 gpu_ecm (mpz_t f, mpz_t x, int *param, mpz_t firstsigma, mpz_t n, mpz_t go, 
          double *B1done, double B1, mpz_t B2min_parm, mpz_t B2_parm, 
          unsigned long k, const int S, int verbose, int repr,

Modified: trunk/factor.c
===================================================================
--- trunk/factor.c	2015-02-08 20:40:26 UTC (rev 2591)
+++ trunk/factor.c	2015-02-09 09:34:37 UTC (rev 2592)
@@ -129,6 +129,9 @@
 
   if (p->method == ECM_ECM)
     {
+#ifndef WITH_GPU
+      ASSERT_ALWAYS(p->gpu == 0);
+#endif
       if (p->gpu == 0)
         {
             res = ecm (f, p->x, p->y, &(p->param), p->sigma, n, p->go,
@@ -143,18 +146,14 @@
         }
       else
         {
-#ifdef WITH_GPU
-            res = gpu_ecm (f, p->x, &(p->param), p->sigma, n, p->go, 
-                           &(p->B1done), B1, p->B2min, p->B2, p->k,
-                           p->S, p->verbose, p->repr, p->nobase2step2, 
-                           p->use_ntt, p->sigma_is_A, p->os, p->es,
-                           p->chkfilename, p->TreeFilename, p->maxmem,
-                           p->stop_asap, p->batch_s, &(p->batch_last_B1_used),
-                           p->gpu_device, &(p->gpu_device_init),
-                           &(p->gpu_number_of_curves));
-#else
-            res = gpu_ecm ();
-#endif
+          res = gpu_ecm (f, p->x, &(p->param), p->sigma, n, p->go, 
+                         &(p->B1done), B1, p->B2min, p->B2, p->k,
+                         p->S, p->verbose, p->repr, p->nobase2step2, 
+                         p->use_ntt, p->sigma_is_A, p->os, p->es,
+                         p->chkfilename, p->TreeFilename, p->maxmem,
+                         p->stop_asap, p->batch_s, &(p->batch_last_B1_used),
+                         p->gpu_device, &(p->gpu_device_init),
+                         &(p->gpu_number_of_curves));
         }
     }
   else if (p->method == ECM_PM1)

Modified: trunk/rho.c
===================================================================
--- trunk/rho.c	2015-02-08 20:40:26 UTC (rev 2591)
+++ trunk/rho.c	2015-02-09 09:34:37 UTC (rev 2592)
@@ -307,14 +307,12 @@
   ASSERT(x <= 3.);
   if (x <= 0.)
     return 0.;
-  if (x <= 1.)
+  else if (x <= 1.)
     return 1.;
-  if (x <= 2.)
+  else if (x <= 2.)
     return 1. - log (x);
-  if (x <= 3.) /* 2 < x <= 3 thus -2 <= 1-x < -1 */
+  else /* 2 < x <= 3 thus -2 <= 1-x < -1 */
     return 1. - log (x) * (1. - log (x - 1.)) + dilog (1. - x) + 0.5 * M_PI_SQR_6;
-  
-  return 0.; /* x > 3. and asserting not enabled: bail out with 0. */
 }
 
 
@@ -372,11 +370,7 @@
   tablemax = parm_tablemax;
   
   rhotable = (double *) malloc (parm_invh * parm_tablemax * sizeof (double));
-  if (rhotable == NULL)
-    {
-      fprintf (stderr, "Cannot allocate memory in rhoinit\n");
-      exit (1);
-    }
+  ASSERT_ALWAYS(rhotable != NULL);
   
   for (i = 0; i < (3 < parm_tablemax ? 3 : parm_tablemax) * invh; i++)
     rhotable[i] = rhoexact (i * h);
@@ -405,20 +399,20 @@
     }
 }
 
+/* assumes alpha < tablemax */
 static double
 dickmanrho (double alpha)
 {
+  ASSERT(alpha < tablemax);
+
   if (alpha <= 3.)
      return rhoexact (alpha);
-  if (alpha < tablemax)
-    {
-      int a = floor (alpha * invh);
-      double rho1 = rhotable[a];
-      double rho2 = (a + 1) < tablemax * invh ? rhotable[a + 1] : 0;
-      return rho1 + (rho2 - rho1) * (alpha * invh - (double)a);
-    }
-  
-  return 0.;
+  {
+    int a = floor (alpha * invh);
+    double rho1 = rhotable[a];
+    double rho2 = (a + 1) < tablemax * invh ? rhotable[a + 1] : 0;
+    return rho1 + (rho2 - rho1) * (alpha * invh - (double) a);
+  }
 }
 
 #if 0
@@ -452,10 +446,8 @@
 static double
 dickmanlocal (double alpha, double x)
 {
-  if (alpha <= 0.)
-    return 0.;
   if (alpha <= 1.)
-    return 1.;
+    return rhoexact (alpha);
   if (alpha < tablemax)
     return dickmanrho (alpha) - M_EULER * dickmanrho (alpha - 1.) / log (x);
   return 0.;

Modified: trunk/test.pm1
===================================================================
--- trunk/test.pm1	2015-02-08 20:40:26 UTC (rev 2591)
+++ trunk/test.pm1	2015-02-09 09:34:37 UTC (rev 2592)
@@ -120,6 +120,8 @@
 echo "2^(2^12)+1" | $PM1 -go "N-1" 1e6; checkcode $? 2
 
 # check -v option
+echo 33852066257429811148979390609187539760850944806763555795340084882048986912482949506591909041130651770779842162499482875755533111808276172876211496409325473343590723224081353129229935527059488811457730702694849036693756201766866018562295004353153066430367 | $PM1 -v 19999; checkcode $? 0
+
 echo 33852066257429811148979390609187539760850944806763555795340084882048986912482949506591909041130651770779842162499482875755533111808276172876211496409325473343590723224081353129229935527059488811457730702694849036693756201766866018562295004353153066430367 | $PM1 -v 1e5; checkcode $? 0
 
 # check -v -v option
@@ -131,4 +133,7 @@
 # check -v -v -v option with -no-ntt
 echo 33852066257429811148979390609187539760850944806763555795340084882048986912482949506591909041130651770779842162499482875755533111808276172876211496409325473343590723224081353129229935527059488811457730702694849036693756201766866018562295004353153066430367 | $PM1 -no-ntt -v -v -v 1e5; checkcode $? 0
 
+# check -v -v -v -v option
+echo 33852066257429811148979390609187539760850944806763555795340084882048986912482949506591909041130651770779842162499482875755533111808276172876211496409325473343590723224081353129229935527059488811457730702694849036693756201766866018562295004353153066430367 | $PM1 -v -v -v -v 1e5 > /dev/null
+
 echo "All P-1 tests are ok."

Modified: trunk/test.pp1
===================================================================
--- trunk/test.pp1	2015-02-08 20:40:26 UTC (rev 2591)
+++ trunk/test.pp1	2015-02-09 09:34:37 UTC (rev 2592)
@@ -123,4 +123,16 @@
 
 echo 18446744073709551337 | $PP1 -pp1 -x0 2 70823 714487; checkcode $? 8
 
+# check -v option
+echo 33852066257429811148979390609187539760850944806763555795340084882048986912482949506591909041130651770779842162499482875755533111808276172876211496409325473343590723224081353129229935527059488811457730702694849036693756201766866018562295004353153066430367 | $PP1 -v 1e5; checkcode $? 0
+
+# check -v -v option
+echo 33852066257429811148979390609187539760850944806763555795340084882048986912482949506591909041130651770779842162499482875755533111808276172876211496409325473343590723224081353129229935527059488811457730702694849036693756201766866018562295004353153066430367 | $PP1 -v -v 1e5; checkcode $? 0
+
+# check -v -v -v option
+echo 33852066257429811148979390609187539760850944806763555795340084882048986912482949506591909041130651770779842162499482875755533111808276172876211496409325473343590723224081353129229935527059488811457730702694849036693756201766866018562295004353153066430367 | $PP1 -v -v -v 1e5; checkcode $? 0
+
+# check -v -v -v -v option
+echo 33852066257429811148979390609187539760850944806763555795340084882048986912482949506591909041130651770779842162499482875755533111808276172876211496409325473343590723224081353129229935527059488811457730702694849036693756201766866018562295004353153066430367 | $PP1 -v -v -v -v 1e5 > /dev/null
+
 echo "All P+1 tests are ok."



More information about the Ecm-commits mailing list