I have created a patch for GMP-ECM (the SVN version) that allows it to be 
built with MPIR-2.6.0 and Bill's New FFT.  

A patch giving the changes needed is attached.   If you are able to tests 
it, please report any successes and failures here.

    Brian

-- 
You received this message because you are subscribed to the Google Groups 
"mpir-devel" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/mpir-devel/-/YYS2PkS0tLAJ.
To post to this group, send email to mpir-devel@googlegroups.com.
To unsubscribe from this group, send email to 
mpir-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/mpir-devel?hl=en.

Index: ecm-gmp.h
===================================================================
--- ecm-gmp.h   (revision 2185)
+++ ecm-gmp.h   (working copy)
@@ -139,6 +139,14 @@
   void __gmpn_mullo_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);
 #endif
 
+#if defined( __MPIR_RELEASE ) && __MPIR_RELEASE >= 20600
+
+#define mpn_mulmod_Bexpp1_fft __gmpn_mulmod_Bexpp1_fft
+int __gmpn_mulmod_Bexpp1_fft(mp_ptr op, mp_size_t pl, mp_srcptr n, mp_size_t 
nl, 
+                                                        mp_srcptr m, mp_size_t 
ml);
+
+#else
+
 #define mpn_mul_fft __gmpn_mul_fft
 mp_limb_t __gmpn_mul_fft (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_srcptr, 
                           mp_size_t, int);
@@ -152,4 +160,6 @@
 #define mpn_fft_best_k __gmpn_fft_best_k
 int __gmpn_fft_best_k (mp_size_t, int);
 
+#endif
+
 #endif /* _ECM_GMP_H */
Index: ks-multiply.c
===================================================================
--- ks-multiply.c       (revision 2185)
+++ ks-multiply.c       (working copy)
@@ -517,15 +517,27 @@
   /* the product rev(a) * c has m+l+1 coefficients.
      We throw away the first m and the last l-n <= m.
      If we compute mod (m+n+1) * s limbs, we are ok */
+
+#if defined( __MPIR_RELEASE ) && __MPIR_RELEASE >= 20600
+  bn = fft_adjust_limbs((m + n + 1) * s);
+#else
   k = mpn_fft_best_k ((m + n + 1) * s, 0);
   bn = mpn_fft_next_size ((m + n + 1) * s, k);
+#endif
+
 #ifdef TEST_OLD_S
   k_old = mpn_fft_best_k ((m + n + 1) * s_old, 0);
   if (k != k_old)
     outputf (OUTPUT_ERROR, 
              "Got different FFT transform length, k = %lu, k_old : %lu\n",
              k, k_old);    
+
+#if defined( __MPIR_RELEASE ) && __MPIR_RELEASE >= 20600
+  bn = fft_adjust_limbs((m + n + 1) * s_old)
+#else
   bn_old = mpn_fft_next_size ((m + n + 1) * s_old, k_old);
+#endif
+
   if (bn != bn_old)
     outputf (OUTPUT_ERROR, "Got different FFT size, bn = %d, bn_old : %d\n",
              (int) bn, (int) bn_old);
@@ -537,7 +549,12 @@
       ret = 1;
       goto TMulKS_free_cp;
     }
+#if defined( __MPIR_RELEASE ) && __MPIR_RELEASE >= 20600
+  mpn_mulmod_Bexpp1_fft (bp, bn, ap, an, cp, cn);
+#else
   mpn_mul_fft (bp, bn, ap, an, cp, cn, k);
+#endif
+
   if (m && bp[m * s - 1] >> (GMP_NUMB_BITS - 1)) /* lo(b)-hi(b) is negative */
     mpn_add_1 (bp + m * s, bp + m * s, (n + 1) * s, (mp_limb_t) 1);
 #else
@@ -602,10 +619,22 @@
   s = t * 2 + 1;
   for (i = k - 1; i; s++, i >>= 1);
   s = 1 + (s - 1) / GMP_NUMB_BITS;
+
+#if defined( __MPIR_RELEASE ) && __MPIR_RELEASE >= 20600
+  i = fft_adjust_limbs(m0 * s);
+#else
   fft_k = mpn_fft_best_k (m0 * s, 0);
   i = mpn_fft_next_size (m0 * s, fft_k);
+#endif
+
   while (i % s)
+
+#if defined( __MPIR_RELEASE ) && __MPIR_RELEASE >= 20600
+    i = fft_adjust_limbs(i + 1);
+#else
     i = mpn_fft_next_size (i + 1, fft_k);
+#endif
+
   m = i / s;
   return m;
 }
@@ -667,12 +696,23 @@
     if (SIZ(B[i]))
       MPN_COPY (t1_ptr + i * s, PTR(B[i]), SIZ(B[i]));
 
+#if defined( __MPIR_RELEASE ) && __MPIR_RELEASE >= 20600
+  i = fft_adjust_limbs(m0 * s);
+#else
   fft_k = mpn_fft_best_k (m0 * s, 0);
   i = mpn_fft_next_size (m0 * s, fft_k);
+#endif
+
   /* the following loop ensures we don't cut in the middle of a
      coefficient */
   while (i % s)
+
+#if defined( __MPIR_RELEASE ) && __MPIR_RELEASE >= 20600
+    i = fft_adjust_limbs(i + 1);
+#else
     i = mpn_fft_next_size (i + 1, fft_k);
+#endif
+
   m = i / s;
   ASSERT(m <= 2 * m0 - 3 + list_mul_mem (m0 - 1));
 
@@ -684,8 +724,12 @@
       return 0;
     }
 
+#if defined( __MPIR_RELEASE ) && __MPIR_RELEASE >= 20600
+  mpn_mulmod_Bexpp1_fft (t2_ptr, i, t0_ptr, size_t0, t1_ptr, size_t1);
+#else
   mpn_mul_fft (t2_ptr, i, t0_ptr, size_t0, t1_ptr, size_t1, fft_k);
-  
+#endif
+
   for (i = 0, tp = t2_ptr, negative = 0; i < m; i++)
     {
       size_tmp = s;
Index: mpmod.c
===================================================================
--- mpmod.c     (revision 2185)
+++ mpmod.c     (working copy)
@@ -1452,9 +1452,13 @@
       s1s = SIZ(S1);
       s2p = PTR(S2);
       s2s = SIZ(S2);
-      
+
+#if defined( __MPIR_RELEASE ) && __MPIR_RELEASE >= 20600
+      ASSERT(fft_adjust_limbs(n) == n);
+#else
       k = mpn_fft_best_k (n, S1 == S2);
       ASSERT(mpn_fft_next_size (n, k) == n);
+#endif
 
       if (base2mod_2 (modulus->temp1, S1, n, modulus->orig_modulus))
         {
@@ -1477,8 +1481,14 @@
          in that case R is set to zero and 1 is returned as carry-out.
          In all other cases 0 is returned. Hence the complete result is 
          R + cy * B^n, where cy is the value returned by mpn_mul_fft(). */
+
+#if defined( __MPIR_RELEASE ) && __MPIR_RELEASE >= 20600
+      PTR(R)[n] = mpn_mulmod_Bexpp1_fft(PTR(R), n, s1p, ABS(s1s), s2p, 
ABS(s2s));
+#else
       PTR(R)[n] = mpn_mul_fft (PTR(R), n, s1p, ABS(s1s), s2p, ABS(s2s), k);
-      n ++;
+#endif
+
+         n ++;
       MPN_NORMALIZE(PTR(R), n);
       SIZ(R) = ((s1s ^ s2s) >= 0) ? (int) n : (int) -n;
 
@@ -1662,8 +1672,13 @@
       mp_size_t s1s = SIZ(S1), s2s = SIZ(S2);
       
       MPZ_REALLOC (R, n + 1);
+
+#if defined( __MPIR_RELEASE ) && __MPIR_RELEASE >= 20600
+      ASSERT(fft_adjust_limbs(n) == n);
+#else
       k = mpn_fft_best_k (n, S1 == S2);
       ASSERT(mpn_fft_next_size (n, k) == n);
+#endif
 
       if (base2mod_2 (modulus->temp1, S1, n, modulus->orig_modulus))
         {
@@ -1686,7 +1701,13 @@
          in that case R is set to zero and 1 is returned as carry-out.
          In all other cases 0 is returned. Hence the complete result is 
          R + cy * B^n, where cy is the value returned by mpn_mul_fft(). */
+
+#if defined( __MPIR_RELEASE ) && __MPIR_RELEASE >= 20600
+      PTR(R)[n] = mpn_mulmod_Bexpp1_fft (PTR(R), n, s1p, ABS(s1s), s2p, 
ABS(s2s));
+#else
       PTR(R)[n] = mpn_mul_fft (PTR(R), n, s1p, ABS(s1s), s2p, ABS(s2s), k);
+#endif
+
       n ++;
       MPN_NORMALIZE(PTR(R), n);
       SIZ(R) = ((s1s ^ s2s) >= 0) ? (int) n : (int) -n;
Index: schoen_strass.c
===================================================================
--- schoen_strass.c     (revision 2185)
+++ schoen_strass.c     (working copy)
@@ -175,9 +175,15 @@
       _mpz_realloc (gt, n2 + 1);
       /* in case the reallocation fails, _mpz_realloc sets the value to 0 */
       ASSERT_ALWAYS (mpz_cmp_ui (gt, 0) != 0);
+
+#if defined( __MPIR_RELEASE ) && __MPIR_RELEASE >= 20600
+      mpn_mulmod_Bexpp1_fft(PTR(gt), n2, PTR(S1), ABSIZ(S1), PTR(S2), 
ABSIZ(S2));
+#else
       k = mpn_fft_best_k (n2, S1 == S2);
       mpn_mul_fft (PTR(gt), n2, PTR(S1), ABSIZ(S1), PTR(S2), ABSIZ(S2), k);
-      MPN_NORMALIZE(PTR(gt), n2);
+#endif
+
+         MPN_NORMALIZE(PTR(gt), n2);
       SIZ(gt) = ((SIZ(S1) ^ SIZ(S2)) >= 0) ? n2 : -n2;
       F_mod_gt (R, n);
       return;

Reply via email to