Faster table compute in mpn_sec_powm
Marco Bodrato
bodrato at mail.dm.unipi.it
Mon Mar 26 01:33:24 UTC 2018
Ciao,
Il Sab, 24 Marzo 2018 3:37 pm, Torbjörn Granlund ha scritto:
> B^(2j) = (B^j)^2 (i.e., even values of i)
> B^(2j+1) = (B^(2j))*B (i.e., odd values of i)
> I haven't benchmarked this change, but it is clearly never a slowdown.
maybe a slowdown on the few systems with a non-zero SQR_BASECASE_THRESHOLD?
May I suggest:
**
/tmp/extdiff.03cT8S/gmp-repo.2a3b146aee90/mpn/generic/sec_powm.c 2018-03-25
00:47:27.000000000 +0100
--- /home/bodrato/gmp-repo/mpn/generic/sec_powm.c 2018-03-26
03:21:22.401588338 +0200
***************
*** 116,128 ****
size. */
#define mpn_local_sqr(rp,up,n,tp) mpn_sqr_basecase(rp,up,n)
#else
/* Else use mpn_sqr_basecase for its allowed sizes, else
mpn_mul_basecase. */
#define mpn_local_sqr(rp,up,n,tp) \
do { \
! if (BELOW_THRESHOLD (n, SQR_BASECASE_LIM)) \
mpn_sqr_basecase (rp, up, n); \
else \
mpn_mul_basecase(rp, up, n, up, n); \
} while (0)
#endif
--- 116,129 ----
size. */
#define mpn_local_sqr(rp,up,n,tp) mpn_sqr_basecase(rp,up,n)
#else
/* Else use mpn_sqr_basecase for its allowed sizes, else
mpn_mul_basecase. */
#define mpn_local_sqr(rp,up,n,tp) \
do { \
! if (ABOVE_THRESHOLD (n, SQR_BASECASE_THRESHOLD) && \
! BELOW_THRESHOLD (n, SQR_BASECASE_LIM)) \
mpn_sqr_basecase (rp, up, n); \
else \
mpn_mul_basecase(rp, up, n, up, n); \
} while (0)
#endif
... but this threshold might be used also for the other definition of
_local_sqr ... moreover, both definitions discard the parameter tp, can we
get rid of it?
Ĝis,
m
--
http://bodrato.it/
More information about the gmp-devel
mailing list