[Ecm-commits] r2636 - trunk

cvs commits ecm-commits at lists.gforge.inria.fr
Wed Feb 25 15:52:05 CET 2015


Author: zimmerma
Date: 2015-02-25 15:52:05 +0100 (Wed, 25 Feb 2015)
New Revision: 2636

Modified:
   trunk/Makefile.am
   trunk/auxlib.c
   trunk/ecm-impl.h
   trunk/main.c
   trunk/pm1.c
   trunk/pp1.c
   trunk/test.pm1
   trunk/test.pp1
Log:
repaired the -chkpnt option which was broken for P-1/P+1
improved coverage of auxlib.c
removed listz_handle.[ch] from Makefile.am, since unused currently


Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am	2015-02-24 17:39:09 UTC (rev 2635)
+++ trunk/Makefile.am	2015-02-25 14:52:05 UTC (rev 2636)
@@ -37,8 +37,7 @@
 		   random.c factor.c sp.c spv.c spm.c mpzspm.c mpzspv.c \
 		   ntt_gfp.c ecm_ntt.c pm1fs2.c sets_long.c \
 		   auxarith.c batch.c parametrizations.c cudawrapper.c \
-		   listz_handle.c addlaws.c torsions.c \
-		   aprtcle/mpz_aprcl.c
+		   addlaws.c torsions.c aprtcle/mpz_aprcl.c
 # Link the asm redc code (if we use it) into libecm.la
 libecm_la_CPPFLAGS = $(MULREDCINCPATH)
 libecm_la_CFLAGS = $(OPENMP_CFLAGS) -g
@@ -102,8 +101,7 @@
 include_HEADERS = ecm.h
 noinst_HEADERS = basicdefs.h ecm-impl.h ecm-gmp.h ecm-ecm.h sp.h longlong.h \
 	         ecm-params.h mpmod.h ecm-gpu.h cudakernel.h addlaws.h \
-                 listz_handle.h torsions.h aprtcle/mpz_aprcl.h \
-                 aprtcle/jacobi_sum.h
+                 torsions.h aprtcle/mpz_aprcl.h aprtcle/jacobi_sum.h
 
 EXTRA_DIST = test.pm1 test.pp1 test.ecm README.lib INSTALL-ecm ecm.xml  \
              pentium4/params.h x86_64/core2/params.h x86_64/k8/params.h \

Modified: trunk/auxlib.c
===================================================================
--- trunk/auxlib.c	2015-02-24 17:39:09 UTC (rev 2635)
+++ trunk/auxlib.c	2015-02-25 14:52:05 UTC (rev 2636)
@@ -90,20 +90,15 @@
     RS->_mp_size -= mpz_sgn (RS);
 }
 
-/* Convert a double d to a size_t. If d < 0., returns 0. If d > MAX_SIZE, 
-   returns MAX_SIZE. */
-
+/* Convert a double d to a size_t.
+   Assumes d >= 0. If d > SIZE_MAX, returns SIZE_MAX. */
 size_t
 double_to_size (double d)
 {
-  if (d < 0.)
-    return (size_t) 0;
-  if (d > (double) SIZE_MAX)
-    return SIZE_MAX;
-  return (size_t) d;
+  ASSERT(d >= 0.0);
+  return (d > (double) SIZE_MAX) ? SIZE_MAX : (size_t) d;
 }
 
-
 /* cputime () gives the elapsed time in milliseconds */
 
 #if defined (_WIN32)
@@ -168,17 +163,7 @@
 long
 elltime (long st0, long st1)
 {
-  if (st1 >= st0)
-    return st1 - st0;
-  else
-    {
-      /* A wrap around can only really happen on a system where long int is 
-         32 bit and where we use clock(). So we assume that there was exactly 
-         one wrap-around which "swallowed" 
-         LONG_MAX * (1000. / (double) CLOCKS_PER_SEC) milliseconds. */
-      
-      return st1 - st0 + (long)(LONG_MAX * (1000. / (double) CLOCKS_PER_SEC));
-    }
+  return st1 - st0; /* assumes no wrap around */
 }
 
 /* Get real (wall-clock) time in milliseconds */
@@ -187,8 +172,8 @@
 {
 #ifdef HAVE_GETTIMEOFDAY
   struct timeval tv;
-  if (gettimeofday(&tv, NULL) != 0)
-    return 0L;
+  int ret = gettimeofday (&tv, NULL);
+  ASSERT_ALWAYS(ret == 0); /* if HAVE_GETTIMEOFDAY, it should be functional */
   return (long) tv.tv_sec * 1000L + (long) tv.tv_usec / 1000L;
 #else
   return 0L;
@@ -230,6 +215,7 @@
   return n;
 }
 
+/* for P-1 and P+1 we have A = y = z = NULL */
 void
 writechkfile (char *chkfilename, int method, double p, mpmod_t modulus, 
               mpres_t A, mpres_t x, mpres_t y, mpres_t z)
@@ -238,7 +224,7 @@
   char *methodname;
   mpz_t t;
 
-  outputf (OUTPUT_DEVVERBOSE, "Writing checkpoint to %s at p = %.0f\n",
+  outputf (OUTPUT_VERBOSE, "Writing checkpoint to %s at p = %.0f\n",
            chkfilename, p);
 
   switch (method)
@@ -252,12 +238,7 @@
     }
 
   chkfile = fopen (chkfilename, "w");
-  if (chkfile == NULL)
-    {
-      outputf (OUTPUT_ERROR, "Error opening checkpoint file %s\n", 
-	       chkfilename);
-      return;
-    }
+  ASSERT_ALWAYS(chkfile != NULL);
 
   mpz_init (t);
 
@@ -288,6 +269,7 @@
   fclose (chkfile);
 }
 
+#if 0 /* currently unused (only used in listz_handle.c, currently inactive) */
 int 
 aux_fseek64(FILE *f, const int64_t offset, const int whence)
 {
@@ -300,12 +282,4 @@
   ASSERT_ALWAYS (offset <= LONG_MAX);
   return fseek (f, (long) offset, whence);
 }
-
-int64_t 
-aux_ftell64(FILE *f)
-{
-#ifdef HAVE__FSEEKI64
-  return _ftelli64(f);
 #endif
-  return (int64_t) ftell (f);
-}

Modified: trunk/ecm-impl.h
===================================================================
--- trunk/ecm-impl.h	2015-02-24 17:39:09 UTC (rev 2635)
+++ trunk/ecm-impl.h	2015-02-25 14:52:05 UTC (rev 2636)
@@ -649,8 +649,6 @@
 void writechkfile (char *, int, double, mpmod_t, mpres_t, mpres_t, mpres_t, mpres_t);
 #define aux_fseek64 __ECM(aux_fseek64)
 int aux_fseek64(FILE *, const int64_t, const int);
-#define aux_ftell64 __ECM(aux_ftell64)
-int64_t aux_ftell64(FILE *);
 
 /* auxarith.c */
 #define gcd __ECM(gcd)

Modified: trunk/main.c
===================================================================
--- trunk/main.c	2015-02-24 17:39:09 UTC (rev 2635)
+++ trunk/main.c	2015-02-25 14:52:05 UTC (rev 2636)
@@ -736,6 +736,7 @@
       else if ((argc > 2) && (strcmp (argv[1], "-maxmem") == 0))
 	{
 	  maxmem = atof (argv[2]) * 1048576.;
+          ASSERT_ALWAYS(maxmem >= 0.0);
 	  argv += 2;
 	  argc -= 2;
 	}

Modified: trunk/pm1.c
===================================================================
--- trunk/pm1.c	2015-02-24 17:39:09 UTC (rev 2635)
+++ trunk/pm1.c	2015-02-25 14:52:05 UTC (rev 2636)
@@ -306,7 +306,7 @@
         if (chkfilename != NULL && p > last_chkpnt_p + 10000. &&
             elltime (last_chkpnt_time, cputime ()) > CHKPNT_PERIOD)
           {
-	    writechkfile (chkfilename, ECM_PM1, p, n, NULL, NULL, a, NULL);
+	    writechkfile (chkfilename, ECM_PM1, p, n, NULL, a, NULL, NULL);
             last_chkpnt_p = p;
             last_chkpnt_time = cputime ();
           }
@@ -331,7 +331,7 @@
 
  clear_pm1_stage1:
   if (chkfilename != NULL)
-    writechkfile (chkfilename, ECM_PM1, *B1done, n, NULL, NULL, a, NULL);
+    writechkfile (chkfilename, ECM_PM1, *B1done, n, NULL, a, NULL, NULL);
   getprime_clear (); /* free the prime tables, and reinitialize */
   mpz_clear (d);
   mpz_clear (g);

Modified: trunk/pp1.c
===================================================================
--- trunk/pp1.c	2015-02-24 17:39:09 UTC (rev 2635)
+++ trunk/pp1.c	2015-02-25 14:52:05 UTC (rev 2636)
@@ -226,7 +226,7 @@
       if (chkfilename != NULL && p > last_chkpnt_p + 10000. &&
           elltime (last_chkpnt_time, cputime ()) > CHKPNT_PERIOD)
         {
-	  writechkfile (chkfilename, ECM_PP1, p, n, NULL, NULL, P0, NULL);
+	  writechkfile (chkfilename, ECM_PP1, p, n, NULL, P0, NULL, NULL);
           last_chkpnt_p = p;
           last_chkpnt_time = cputime ();
         }
@@ -246,7 +246,7 @@
 
 clear_and_exit:
   if (chkfilename != NULL)
-    writechkfile (chkfilename, ECM_PP1, p, n, NULL, NULL, P0, NULL);
+    writechkfile (chkfilename, ECM_PP1, p, n, NULL, P0, NULL, NULL);
   getprime_clear (); /* free the prime tables, and reinitialize */
   mpres_clear (Q, n);
   mpres_clear (R, n);

Modified: trunk/test.pm1
===================================================================
--- trunk/test.pm1	2015-02-24 17:39:09 UTC (rev 2635)
+++ trunk/test.pm1	2015-02-25 14:52:05 UTC (rev 2636)
@@ -90,6 +90,12 @@
 /bin/rm -f test.pm1.save
 checkcode $C 8
 
+# check the -chkpnt option
+echo 25591172394760497166702530699464321 | $PM1 -chkpnt test.pm1.chk 100000
+C=$?
+/bin/rm -f test.pm1.chk
+checkcode $C 14
+
 ### same with -savea
 echo 25591172394760497166702530699464321 | $PM1 -savea test.pm1.save 100000
 checkcode $? 0

Modified: trunk/test.pp1
===================================================================
--- trunk/test.pp1	2015-02-24 17:39:09 UTC (rev 2635)
+++ trunk/test.pp1	2015-02-25 14:52:05 UTC (rev 2636)
@@ -107,6 +107,12 @@
 /bin/rm -f test.pp1.save
 checkcode $C 14
 
+# test -chkpnt
+echo 2277189375098448170118558775447117254551111605543304035536750762506158547102293199086726265869065639109 | $PP1 -x0 3 -save test.pp1.chk 2337233 0
+C=$?
+/bin/rm -f test.pp1.chk
+checkcode $C 14
+
 # bug in ecm-5.0 (overflow in fin_diff_coeff)
 echo 630503947831861669 | $PP1 -x0 5 7 9007199254740000-9007199254741000; checkcode $? 8
 



More information about the Ecm-commits mailing list