Bill Allombert on Sat, 15 Jul 2023 00:24:38 +0200
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Why is "lift(Mod(qnr, n)^(n\4))" 16% slower than C libgmp "powm(r, qnr, n/4, n)" ?
|
- To: hermann@stamm-wilbrandt.de
- Subject: Re: Why is "lift(Mod(qnr, n)^(n\4))" 16% slower than C libgmp "powm(r, qnr, n/4, n)" ?
- From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
- Date: Sat, 15 Jul 2023 00:19:53 +0200
- Arc-authentication-results: i=1; smail; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1689373186; c=relaxed/relaxed; bh=/Ogl/eP0jSAUpMcoROgnLD16hncykDzNJ8sFHW7RTc4=; h=DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: Mail-Followup-To:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=IkekP6IofQdj2xiaNXJ4nJn7kd83BtNOTCeXSD0+8/AebXaOR61ZOtxX3kk4JRlKlLHH7/8xTBKTz9gTULMRkoxjWvGJGk+Bn2epEGIY1Wx8NczMwu4KTiv3qtm2Qho1Yb+hSMhDHk2Is9SPWa7wu9WaU8GjXQvOg3ItuUFmW+/kfc5xm3Ndd97MAuHhLioD34tb33PnyZ6No8kXHxu91ijHEhwt8g0IO0T1ZqEJoYlZ8Mz0zhtGn5GEYBca7cEwc+V1Mn0ifjrcAWZ+nJW1jY6TCL6tWhwVhTNe5M3OZrpsHHpHHEuEX4x8Alpzf5joZ3rAqqKs/nxxIVO686WvKLe6vuobdJ/YLVUFkfKGQ8AJDtJRnQ4tfiVkehDFH8vIJFKLFSgpdgJfdt0T+tdiFxlsGwybvYIIW9pHP9PjqV8CNPG6ejDQQuxbV/+XBfF1MCJqb2i5sxRQ2iE8t362lZUTc0GRk7zpdTKzBJdj65UWcZP2U3mXsjfX2YXeHCok8E37T2I5kL8K877uAjSTe+0SBN3ebJo32n6Lm5U6pUbASJSKjA6Oov85XKLEr2n3ZMKaNKk3Tom6Cp4IL+fNb5Ii/VgpIa4mtoZhkBTUns8VenNQgi61SPE3cejb7ePtyy/vlWJ2QmPLr83od5YB49dMqxIcOaOmC5zCE21vBSI=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1689373186; cv=none; b=DZSpUT/6jDeeyBWaaWUQZnEuQyLk7KFIEIJlD3DFFH44Tczhcvb7Gi6BTE4kf1jt4llQ5xRe4iHLzgvv43D1XrX2OxVEfhBhIRTZewpiH+5VJN/ci/t1SAazvntVjeST2vH9Sy5za9KnpsENo3u6zM3e6JXvYwWTJvycftnvu+wqoe/B6RyEWlM1wWIjvEoWGAZrgg1g9gMCwwleg69zjYCm4/jQSXfhkiDLF6seeW5UncMsVnA6Gbkjnr4rAUG3yeF111CFsL6Z2iNiy2G57U+JNsKjOlmre5JUmxfN5R//CtYVrgcS5FhJHHM4AE8jjnh3udcu+GBVc1YlxAGI8AkbolDZPNLK2rrNE8JYkkTSu5iLbCsAkCqCG5WPM8nYVXoc1KBo5a2H8P7iqXd5Tw4OjfeoIwkYzo4w3NdDG7T8MLZec+etko0SeGrpU5esy//EUlpOIae3ClgGF0rTP1NEzL+VArYw4YLCQ2aJ2xUBERlId7CDqSPmMpuqamyCUiwKR3Vt8uTbSebPfvNSIQAwSwUrFlre9g2aYMjyWEob2DdISegV2ozIIJdQIJF8nS/Bibd21D79wLbGzUkChYThaMQZEVEZmYWN9MolhWtOhj9ME4Ks2TZDRe4ICrJxKUSZYkY6xxlKvOL4vXPh2MrOJSb5ffkc3WfFuyftgKY=
- Authentication-results: smail; arc=none
- Cc: pari-users@pari.math.u-bordeaux.fr
- Delivery-date: Sat, 15 Jul 2023 00:24:38 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1689373186; bh=/Ogl/eP0jSAUpMcoROgnLD16hncykDzNJ8sFHW7RTc4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DUHRWWs7Dc00QOI5Teb+EAxEj65w1xBkBVZpOV34ScBS8zYDcJ3+Hd7vLogDR50Vo 2iVuTpvVlJGHs47RKB2/cmcIY9gji6sQFCeV3B8BVj5BjiWni7VRM203aUBsMIhtj5 VPISr/n8ZCESYYayz7Udjr6jTO++CwkSSk1BkY4SiMVmqJfmicV8+bfJpfOB2iuwXa cb6HCSyAXl1LZH4vJ0Krps3a67jXt1cj6/151NG5bbxDc9xbwZeloUeXK8CAyQRPCD kxSOlT0B+PgrSlAq10WEIg12zmsNKgB7j+8iNYzvueA7QwaEHIbvBQwvCsnP+ILfWp FXPOc96Sn8hnLvTXaYruBVQb6ZfuhRSEE5QAdbiYJwELVieTZL4kCHJ5Ew4PPl0jH3 8WoZ7hKbLQMscwKczO+DESyHTYuk+Lw86IBZsq8RzAwesvJcoQP1hqTFeSpsI0JkVb WMc8jGCIzWY4oN5yNJqS5pxGhdyrbuJ6SkVRAGJD+n76JMzG1OmNh2zt+dMuanh8+5 UJKehWS7xMSUZP+J8HVc6h9uz2UinRj7bTB8GqhifiSRecIPG2gPf+ZyjnYbwMh3Gb vmXSyjGf0Cq5hjdxgEM8xjaF4px4nrxbBp0OiA3x6SMbwDJa6wS/OrqGG/FbpLxayQ RqdBzCSwvsE52h6kWzJMh0QA=
- In-reply-to: <6fa2e06c0ed114049cd6a46a43d7de34@stamm-wilbrandt.de>
- Mail-followup-to: hermann@stamm-wilbrandt.de, pari-users@pari.math.u-bordeaux.fr
- References: <43475cd077e10ac2cebf5d8fb59c9118@stamm-wilbrandt.de> <ZJV+RwzesyTLJTDj@seventeen> <ZLGCSwm4nqalbZOe@seventeen> <6fa2e06c0ed114049cd6a46a43d7de34@stamm-wilbrandt.de>
On Fri, Jul 14, 2023 at 11:58:22PM +0200, hermann@stamm-wilbrandt.de wrote:
> On 2023-07-14 19:13, Bill Allombert wrote:
> > > The short answer is that the GNU MP library does not provide a
> > > function mpn_powm
> > > that PARI could use. mpz_powm use a lot of internal mpn functions
> > > for fast modular
> > > reduction which are very efficient but not public.
> > >
> > > Now, I could add a wrapper for mpz_powm for large entries but 16%
> > > slower is not
> > > that bad and we need fast modular reduction in more general setting.
> >
> > Could you compare
> >
> > p=(2^95369 + 1)/3; Mod(2,p)^((p-1)/5)
> > with mpz_powm and PARI ?
> >
> Sure.
>
> Performance problem was related to the base, exponent and modulus I used.
> For your base, exponent and modulus gp outperforms C++ with mpz_powm() by
> 27% !
> That is very good to know.
> OS is Ubuntu 22.04 Desktop.
>
> gp: 19.6s (5.440 GHz)
> g++: 26.9s (5.320 GHz)
Yes, I got the same result... but in fact, this is rather annoying!
If I change PARI to use mpz_powm then I will slowdown this case.
There are two factors that can effect this:
1) the base 2 is handled specially by PARI
2) the bit pattern of the exponent, in particular the number of 1s.
If you could find in which case PARI is faster then GMP, this would be helpful.
(you do not need to try very large numbers, 10000bit should be sufficient.)
Cheers,
Bill.
- Prev by Date:
Re: Why is "lift(Mod(qnr, n)^(n\4))" 16% slower than C libgmp "powm(r, qnr, n/4, n)" ?
- Next by Date:
Re: Why is "lift(Mod(qnr, n)^(n\4))" 16% slower than C libgmp "powm(r, qnr, n/4, n)" ?
- Previous by thread:
Re: Why is "lift(Mod(qnr, n)^(n\4))" 16% slower than C libgmp "powm(r, qnr, n/4, n)" ?
- Next by thread:
Re: Why is "lift(Mod(qnr, n)^(n\4))" 16% slower than C libgmp "powm(r, qnr, n/4, n)" ?
- Index(es):