Two 10-lines functions

bodrato at mail.dm.unipi.it bodrato at mail.dm.unipi.it
Wed Feb 3 16:27:50 CET 2010


Sorry,

> I tested the very simple patch below. Results are a very little bit

I forgot the patch... a very simple-minded one, just for testing...
I repeat, not the right direction.

diff -r 5c7b3ee5d37e mpn/generic/mul_fft.c
--- a/mpn/generic/mul_fft.c	Wed Feb 03 08:05:13 2010 +0100
+++ b/mpn/generic/mul_fft.c	Wed Feb 03 15:40:03 2010 +0100
@@ -104,21 +104,22 @@
 int
 mpn_fft_best_k (mp_size_t n, int sqr)
 {
-  FFT_TABLE_ATTRS struct fft_table_nk *fft_tab, *tab;
+  FFT_TABLE_ATTRS struct fft_table_nk *tab;
   mp_size_t tab_n, thres;
-  int last_k;
+  int last_k, max_k;

-  fft_tab = mpn_fft_table3[sqr];
-  last_k = fft_tab->k;
-  for (tab = fft_tab + 1; ; tab++)
+  tab = mpn_fft_table3[sqr&1];
+  max_k = last_k = tab->k;
+  for (tab = tab + 1; ; tab++)
     {
       tab_n = tab->n;
       thres = tab_n << last_k;
       if (n <= thres)
 	break;
       last_k = tab->k;
+      max_k = MAX(max_k, last_k);
     }
-  return last_k;
+  return (sqr&2)?max_k:last_k;
 }

 #define MPN_FFT_BEST_READY 1
diff -r 5c7b3ee5d37e mpn/generic/mulmod_bnm1.c
--- a/mpn/generic/mulmod_bnm1.c	Wed Feb 03 08:05:13 2010 +0100
+++ b/mpn/generic/mulmod_bnm1.c	Wed Feb 03 15:40:03 2010 +0100
@@ -347,5 +347,5 @@
   if (BELOW_THRESHOLD (nh, MUL_FFT_MODF_THRESHOLD))
     return (n + (8-1)) & (-8);

-  return 2 * mpn_fft_next_size (nh, mpn_fft_best_k (nh, 0));
+  return 2 * mpn_fft_next_size (nh, mpn_fft_best_k (nh, 0+2));
 }
diff -r 5c7b3ee5d37e mpn/generic/sqrmod_bnm1.c
--- a/mpn/generic/sqrmod_bnm1.c	Wed Feb 03 08:05:13 2010 +0100
+++ b/mpn/generic/sqrmod_bnm1.c	Wed Feb 03 15:40:03 2010 +0100
@@ -298,5 +298,5 @@
   if (BELOW_THRESHOLD (nh, SQR_FFT_MODF_THRESHOLD))
     return (n + (8-1)) & (-8);

-  return 2 * mpn_fft_next_size (nh, mpn_fft_best_k (nh, 1));
+  return 2 * mpn_fft_next_size (nh, mpn_fft_best_k (nh, 1+2));
 }


-- 
http://bodrato.it/



More information about the gmp-devel mailing list