Re: Faster table compute in mpn_sec_powm

2018-03-27 Thread Torbjörn Granlund
"Marco Bodrato" writes: I unified definitions... Correctly, I hope! LGTM, thanks! -- Torbjörn Please encrypt, key id 0xC8601622 ___ gmp-devel mailing list gmp-devel@gmplib.org https://gmplib.org/mailman/listinfo/gmp-devel

Re: Faster table compute in mpn_sec_powm

2018-03-26 Thread Marco Bodrato
Ciao, Il Lun, 26 Marzo 2018 11:21 am, Torbjörn Granlund ha scritto: > I assume SQR_BASECASE_THRESHOLD should be checked for both definitions > of mpn_local_sqr. I unified definitions... Correctly, I hope! https://gmplib.org/repo/gmp/rev/c5c1f6d537f4 Ĝis, m -- http://bodrato.it/papers/ __

Re: Faster table compute in mpn_sec_powm

2018-03-26 Thread Torbjörn Granlund
*** *** 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 {

Re: Faster table compute in mpn_sec_powm

2018-03-26 Thread Torbjörn Granlund
"Marco Bodrato" writes: May I suggest: [snip] Right. That was not introduced now, but an old inefficiency. :-( -- Torbjörn Please encrypt, key id 0xC8601622 ___ gmp-devel mailing list gmp-devel@gmplib.org https://gmplib.org/mailman/listinfo/gmp-

Re: Faster table compute in mpn_sec_powm

2018-03-25 Thread Marco Bodrato
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

Re: Faster table compute in mpn_sec_powm

2018-03-24 Thread Torbjörn Granlund
B^(2j) = (B^j)^2 (i.e., even values of i) B^(2j+1) = (B^(2j))*B (i.e., odd values of i) I pushed a set of changes implementing this: https://gmplib.org/repo/gmp/raw-rev/186ea964d61f https://gmplib.org/repo/gmp/raw-rev/a6967ea18b2f https://gmplib.org/repo/gmp/raw-rev/289ab13bc3fe htt

Re: Faster table compute in mpn_sec_powm

2018-03-20 Thread Bradley Lucier
On 03/20/2018 11:02 AM, Torbjörn Granlund wrote: francisco delgado writes: For odd values of i Instead of this B^(2j+1) = (B^(j-1))*B Shouldn't be this? B^(2j+1) = (B^j)^2*B That's at least mathmatically correct, but this is what I meant: B^(2j) = (B^j)^2 (i.e., even v

Re: Faster table compute in mpn_sec_powm

2018-03-20 Thread Torbjörn Granlund
Bradley Lucier writes: If you're filling the entire table, I don't see how this would be faster. (E.g., if B=10 and you're calculating the entries of a table from 1 to 10,000.) Squaring is much faster than general multiplication. But of one is to compute a table of powers of something sm

Re: Faster table compute in mpn_sec_powm

2018-03-20 Thread Niels Möller
t...@gmplib.org (Torbjörn Granlund) writes: > In the side-channel silent GMP mpn_sec_powm we compute a table of powers > of the base B, from B^0 to B^k-1 for some table size k. [...] > I.e., for even powers we do a squaring, while for odd numbers we do like > before. That's a nice (and likely o

Re: Faster table compute in mpn_sec_powm

2018-03-20 Thread Emmanuel Thomé
On Tue, Mar 20, 2018 at 04:13:54PM +0100, Paul Zimmermann wrote: >Torbjörn, > > > B^(2j) = (B^j)^2 (i.e., even values of i) > > B^(2j+1) = (B^(2j))*B (i.e., odd values of i) > > this is a classical trick we use at several places in MPFR, and we mention > in Modern Computer Algebr

Re: Faster table compute in mpn_sec_powm

2018-03-20 Thread Torbjörn Granlund
paul zimmermann writes: this is a classical trick we use at several places in MPFR, and we mention in Modern Computer Algebra (page 142). Does someone has an earlier reference for that trick? Only a later; I invented it today at 14:00 UTC. :-D -- Torbjörn Please encrypt, key id 0xC8601

Re: Faster table compute in mpn_sec_powm

2018-03-20 Thread paul zimmermann
Torbjörn, > B^(2j) = (B^j)^2 (i.e., even values of i) > B^(2j+1) = (B^(2j))*B (i.e., odd values of i) this is a classical trick we use at several places in MPFR, and we mention in Modern Computer Algebra (page 142). Does someone has an earlier reference for that trick? Paul

Re: Faster table compute in mpn_sec_powm

2018-03-20 Thread francisco delgado
For odd values of i Instead of this B^(2j+1) = (B^(j-1))*B Shouldn't be this? B^(2j+1) = (B^j)^2*B Fran. El mar, 20/3/18, Torbjörn Granlund escribió: Asunto: Faster table compute in mpn_sec_powm Para: gmp-devel@gmplib.org Fecha: martes,

Re: Faster table compute in mpn_sec_powm

2018-03-20 Thread Torbjörn Granlund
francisco delgado writes: For odd values of i Instead of this B^(2j+1) = (B^(j-1))*B Shouldn't be this? B^(2j+1) = (B^j)^2*B That's at least mathmatically correct, but this is what I meant: B^(2j) = (B^j)^2 (i.e., even values of i) B^(2j+1) = (B^(2j))*B (i.e., odd values o

Faster table compute in mpn_sec_powm

2018-03-20 Thread Torbjörn Granlund
In the side-channel silent GMP mpn_sec_powm we compute a table of powers of the base B, from B^0 to B^k-1 for some table size k. We do this simple by using the recusrion B^k = B^k*B. I now realised this can be sped up very easily: B^(2j) = (B^j)^2 (i.e., even values of i) B^(2j+1) = (B^(