[Ecm-commits] r2691 - trunk

cvs commits ecm-commits at lists.gforge.inria.fr
Tue Apr 28 12:12:07 CEST 2015


Author: zimmerma
Date: 2015-04-28 12:12:07 +0200 (Tue, 28 Apr 2015)
New Revision: 2691

Modified:
   trunk/cudawrapper.c
Log:
fixed Segmentation fault in case of GPU error


Modified: trunk/cudawrapper.c
===================================================================
--- trunk/cudawrapper.c	2015-04-25 06:09:51 UTC (rev 2690)
+++ trunk/cudawrapper.c	2015-04-28 10:12:07 UTC (rev 2691)
@@ -343,14 +343,12 @@
   mpres_init (P.A, modulus);
   mpz_init (tmp_A);
 
-
   youpi = set_stage_2_params (B2, B2_parm, B2min, B2min_parm, &root_params,
                               B1, &k, S, use_ntt, &po2, &dF,
                               TreeFilename, maxmem, Fermat, modulus);
   if (youpi == ECM_ERROR)
       goto end_gpu_ecm;
   
-  
 
   /* Initialiaze the GPU if necessary */
   if (!*device_init)
@@ -364,7 +362,7 @@
       if (youpi != 0)
         {
           youpi = ECM_ERROR;
-          goto end_gpu_ecm;
+          goto end_gpu_ecm2;
         }
 
       outputf (OUTPUT_VERBOSE, "GPU: Selection and initialization of the device "
@@ -594,14 +592,9 @@
   }
 
 end_gpu_ecm:
-  mpres_clear (P.A, modulus);
-  mpres_clear (P.y, modulus);
-  mpres_clear (P.x, modulus);
-  mpmod_clear (modulus);
   mpz_clear (root_params.i0);
   mpz_clear (B2);
   mpz_clear (B2min);
-  mpz_clear (tmp_A);
 
   for (i = 0; i < *nb_curves; i++)
       mpz_clear (factors[i]);
@@ -609,6 +602,13 @@
   free (array_stage_found);
   free (factors);
 
+end_gpu_ecm2:
+  mpz_clear (tmp_A);
+  mpres_clear (P.A, modulus);
+  mpres_clear (P.y, modulus);
+  mpres_clear (P.x, modulus);
+  mpmod_clear (modulus);
+
   return youpi;
 }
 #endif



More information about the Ecm-commits mailing list