[Gmp-commit] /var/hg/gmp: mpn/generic/mul_fft.c: Use _bknp1, but not when tun...

mercurial at gmplib.org mercurial at gmplib.org
Tue Mar 15 22:45:33 CET 2022


details:   /var/hg/gmp/rev/f9cbcda05f7e
changeset: 18327:f9cbcda05f7e
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Tue Mar 15 22:45:03 2022 +0100
description:
mpn/generic/mul_fft.c: Use _bknp1, but not when tuning, to avoid "random" results

diffstat:

 mpn/generic/mul_fft.c |  28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

diffs (45 lines):

diff -r a44f487c8d20 -r f9cbcda05f7e mpn/generic/mul_fft.c
--- a/mpn/generic/mul_fft.c	Fri Mar 11 21:13:20 2022 +0100
+++ b/mpn/generic/mul_fft.c	Tue Mar 15 22:45:03 2022 +0100
@@ -474,6 +474,7 @@
 mpn_fft_mul_modF_K (mp_ptr *ap, mp_ptr *bp, mp_size_t n, mp_size_t K)
 {
   int i;
+  unsigned k;
   int sqr = (ap == bp);
   TMP_DECL;
 
@@ -547,6 +548,33 @@
 	  (*ap)[n] = cy;
 	}
     }
+#if ! TUNE_PROGRAM_BUILD
+  else if (MPN_MULMOD_BKNP1_USABLE (n, k, MUL_FFT_MODF_THRESHOLD))
+    {
+      mp_ptr a;
+      mp_size_t n_k = n / k;
+
+      if (sqr)
+       {
+	 mp_ptr tp = TMP_SALLOC_LIMBS (mpn_sqrmod_bknp1_itch (n));
+         for (i = 0; i < K; i++)
+           {
+             a = *ap++;
+             mpn_sqrmod_bknp1 (a, a, n_k, k, tp);
+           }
+       }
+      else
+       {
+	 mp_ptr b, tp = TMP_SALLOC_LIMBS (mpn_mulmod_bknp1_itch (n));
+         for (i = 0; i < K; i++)
+           {
+             a = *ap++;
+             b = *bp++;
+             mpn_mulmod_bknp1 (a, a, b, n_k, k, tp);
+           }
+       }
+    }
+#endif
   else
     {
       mp_ptr a, b, tp, tpn;


More information about the gmp-commit mailing list