Toom sqr recursion
Torbjorn Granlund
tg at gmplib.org
Sun Jan 27 22:06:13 CET 2013
Torbjorn Granlund <tg at gmplib.org> writes:
And in toom44_mul.c and toom4_sqr.c we set MAYBE_*_toom4* using
MUL_FFT_THRESHOLD when we should really consider TOOM6 or (if TOOM6 = 0)
TOOM8. This was forgotten when the 6H and 8H code was merged.
Here's is a possible patch set:
diff -Nrc2 gmp-powm-powm_ui.8ec61b8b6882/mpn/generic/toom44_mul.c gmp-powm-powm_ui/mpn/generic/toom44_mul.c
*** gmp-powm-powm_ui.8ec61b8b6882/mpn/generic/toom44_mul.c Sun Jan 27 22:05:24 2013
--- gmp-powm-powm_ui/mpn/generic/toom44_mul.c Sun Jan 27 22:05:24 2013
***************
*** 51,54 ****
--- 51,61 ----
#define MAYBE_mul_toom44 1
#else
+ #if MUL_TOOM6H_THRESHOLD != 0
+ #define MUL_NEXTALG_THRESHOLD MUL_TOOM6H_THRESHOLD
+ #elif MUL_TOOM8H_THRESHOLD != 0
+ #define MUL_NEXTALG_THRESHOLD MUL_TOOM8H_THRESHOLD
+ #else
+ #define MUL_NEXTALG_THRESHOLD MUL_FFT_THRESHOLD
+ #endif
#define MAYBE_mul_basecase \
(MUL_TOOM44_THRESHOLD < 4 * MUL_TOOM22_THRESHOLD)
***************
*** 56,60 ****
(MUL_TOOM44_THRESHOLD < 4 * MUL_TOOM33_THRESHOLD)
#define MAYBE_mul_toom44 \
! (MUL_FFT_THRESHOLD >= 4 * MUL_TOOM44_THRESHOLD)
#endif
--- 63,67 ----
(MUL_TOOM44_THRESHOLD < 4 * MUL_TOOM33_THRESHOLD)
#define MAYBE_mul_toom44 \
! (MUL_NEXTALG_THRESHOLD >= 4 * MUL_TOOM44_THRESHOLD)
#endif
diff -Nrc2 gmp-powm-powm_ui.8ec61b8b6882/mpn/generic/toom4_sqr.c gmp-powm-powm_ui/mpn/generic/toom4_sqr.c
*** gmp-powm-powm_ui.8ec61b8b6882/mpn/generic/toom4_sqr.c Sun Jan 27 22:05:24 2013
--- gmp-powm-powm_ui/mpn/generic/toom4_sqr.c Sun Jan 27 22:05:24 2013
***************
*** 48,51 ****
--- 48,58 ----
#define MAYBE_sqr_toom4 1
#else
+ #if SQR_TOOM6H_THRESHOLD != 0
+ #define SQR_NEXTALG_THRESHOLD SQR_TOOM6H_THRESHOLD
+ #elif SQR_TOOM8H_THRESHOLD != 0
+ #define SQR_NEXTALG_THRESHOLD SQR_TOOM8H_THRESHOLD
+ #else
+ #define SQR_NEXTALG_THRESHOLD SQR_FFT_THRESHOLD
+ #endif
#define MAYBE_sqr_basecase \
(SQR_TOOM4_THRESHOLD < 4 * SQR_TOOM2_THRESHOLD)
***************
*** 53,57 ****
(SQR_TOOM4_THRESHOLD < 4 * SQR_TOOM3_THRESHOLD)
#define MAYBE_sqr_toom4 \
! (SQR_FFT_THRESHOLD >= 4 * SQR_TOOM4_THRESHOLD)
#endif
--- 60,64 ----
(SQR_TOOM4_THRESHOLD < 4 * SQR_TOOM3_THRESHOLD)
#define MAYBE_sqr_toom4 \
! (SQR_NEXTALG_THRESHOLD >= 4 * SQR_TOOM4_THRESHOLD)
#endif
--
Torbjörn
More information about the gmp-devel
mailing list