20210308, 15:04  #1 
Mar 2021
4_{16} Posts 
Odd GMP Performance
This C++ program https://pastebin.com/y2u9AYRW takes over 7 mins (before I terminated) to run the mpz_probab_prime_p function.
This python implementation(using pypy) can do this in 20 seconds for i in tqdm(a): if all(i % j for j in range(2, ((2**i)1))): print(i) Is there something that I am missing? Also these are very large numbers ~(10^10000000) Last fiddled with by prime on 20210308 at 15:42 Reason: added info 
20210308, 16:12  #2  
Sep 2002
Database er0rr
2·3·691 Posts 
Quote:
Last fiddled with by paulunderwood on 20210308 at 16:13 

20210308, 16:25  #3 
Mar 2021
2^{2} Posts 
I have a few questions. Why does the python implementation seem to work at a reasonable(I think) speed? Also does GWNUM have the same license agreement as Prime95, where if you find a Mersenne prime you share the winnings?(this is not of much concern to me, just wondering) Also do gpus excel at these types of tasks?
Last fiddled with by prime on 20210308 at 16:35 Reason: spelling 
20210308, 16:41  #4 
Sep 2002
Database er0rr
2·3·691 Posts 
I don't know Python. I can't make heads nor tails of it. Someone else will chip in.
Yes GWNUM does have that license agreement about world record primes. If you don't want to get your hands dirty then OpenPFGW may be an option for you. It makes life easy, compared to writing your own GWNUM code GPUs running gpuOwl for Mersenne is very fast, particularly on AMD Radeon V II. For example that card takes a day to crunch a current wavefront test (107M bits long) whereas Prime95 on a fast CPU would take a week or two. Last fiddled with by paulunderwood on 20210308 at 17:04 
20210308, 17:16  #5  
"Ben"
Feb 2007
3,617 Posts 
Quote:
Last fiddled with by bsquared on 20210308 at 17:19 

20210308, 17:27  #6 
Mar 2021
2^{2} Posts 
I think you are correct about the python implementation. Sorry for the silly question

20210308, 17:40  #7 
"Ben"
Feb 2007
E21_{16} Posts 
No worries. The GMP function mpz_probab_prime_p performs the Baillie–PSW primality test followed by some MillerRabin tests. There are probably python implementations of those things around the web, if you would like to compare the speed of mpz_probab_prime_p with something equivalent in python. I would not recommend jumping to 10^10000000 right away! Start with smaller numbers and work your way up to understand how things scale.

20210308, 17:51  #8 
Sep 2002
Database er0rr
2×3×691 Posts 
For Python: https://pypi.org/project/labmath/ for example has various tests including bpsw and fermat_prp.
Once you have tried out 10k digit numbers be amazed by the speed of OpenPFGW (which like LLR and Prime95 is based in GWNUM). Last fiddled with by paulunderwood on 20210308 at 17:55 
20210308, 17:56  #9  
Mar 2021
2^{2} Posts 
Quote:
Last fiddled with by prime on 20210308 at 17:57 

20210308, 18:01  #10 
Sep 2002
Database er0rr
2·3·691 Posts 
A week or two for Mersenne. Other forms take longer because they are not so simple in form and there is a special "transform" for Mersenne numbers,

20210308, 22:13  #11  
"Viliam Furík"
Jul 2018
Martin, Slovakia
3×251 Posts 
Quote:
If you would use some similar CPU, with more cores, the time needed would obviously get even shorter. 

Thread Tools  
Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
3280 core performance  aurashift  Hardware  91  20150424 05:23 
64bit performance of v25.6  James Heinrich  PrimeNet  11  20080424 01:42 
64 bit performance?  zacariaz  Hardware  1  20070510 13:08 
LLR performance on k and n  robert44444uk  15k Search  1  20060209 01:43 
Performance  battlemaxx  Prime Sierpinski Project  4  20050629 20:32 