mersenneforum.org why is prime95 much faster than mathematica?
 Register FAQ Search Today's Posts Mark Forums Read

 2019-03-02, 00:27 #1 bbb120     Feb 2019 China 3B16 Posts why is prime95 much faster than mathematica? I test M86243=2^86243-1 with prime95 and mathematica , by using the same algorithm -lucas lehmer algorithm , but prime95 is much much much fast than mathematica 11.3! prime 95 takes no more than 2 seconds, but mathematica took 49.8735 seconds, prime 95 is 25 times faster than mathematica ! it is much much much much faster than mathematica ! so I think there should be something wrong with prime 95， my mathematica code as follow Code: LucasLehmer[n_]:=Module[{Mp,s,k},Mp=2^n-1;s=4;Do[s=Mod[s^2-2,Mp],{k,1,n-2}];If[s==0,Return[True],Return[False]]] Timing[LucasLehmer[86243]]
2019-03-02, 00:32   #2
Prime95
P90 years forever!

Aug 2002
Yeehaw, FL

22×1,873 Posts

Quote:
 Originally Posted by bbb120 it is much much much much faster than mathematica ! so I think there should be something wrong with prime 95
LOL

 2019-03-02, 00:34 #3 paulunderwood     Sep 2002 Database er0rr 1110010111012 Posts Prime95 uses George Woltman's well-crafted FFT assembly subroutines to perform multiplication, a luxury not seen in Mathematica. Last fiddled with by paulunderwood on 2019-03-02 at 00:36
2019-03-02, 01:00   #4
bbb120

Feb 2019
China

738 Posts

Quote:
 Originally Posted by paulunderwood Prime95 uses George Woltman's well-crafted FFT assembly subroutines to perform multiplication, a luxury not seen in Mathematica.
but different FFT can diff much？
the large Mp,the much faster prime95 than mathematica!

2019-03-02, 01:21   #5
Mysticial

Sep 2016

5148 Posts

Quote:
 Originally Posted by bbb120 but different FFT can diff much？ the large Mp,the much faster prime95 than mathematica!
Absolutely:
• Prime95's FFT only needs to be half the size due to FFT wrap-around.
• Mathematica uses GMP's FFT which is a general purpose and provably-correct integer algorithm. Prime95's FFT is a specialized floating-point implementation that trades away provable-correctness from round-off error for large increases in speed.

FFT differences aside, you're also using the Mod function - which is very slow. Prime95 doesn't need a mod function thanks to the aforementioned FFT wrap-around.

2019-03-02, 01:33   #6
kriesel

"TF79LL86GIMPS96gpu17"
Mar 2017
US midwest

3·5·73 Posts

Quote:
 Originally Posted by bbb120 I test M86243=2^86243-1 with prime95 and mathematica , by using the same algorithm -lucas lehmer algorithm , but prime95 is much much much fast than mathematica 11.3! prime 95 takes no more than 2 seconds, but mathematica took 49.8735 seconds, prime 95 is 25 times faster than mathematica ! it is much much much much faster than mathematica ! so I think there should be something wrong with prime 95
Run some other exponents and see how they scale.
Mathematica is a general purpose application; prime95 is not.
Prime95 was written by George Woltman for a narrow purpose (and refined with cpu-model-specific assembler tuned for performance over 23 years); Mathematica was not.
Prime95 has found the last 17 Mersenne primes; Mathematica zero total.
Prime95's accuracy has been validated by multiple other applications, including software used to make previous discoveries.
https://en.wikipedia.org/wiki/Prime95
https://en.wikipedia.org/wiki/Wolfram_Mathematica

2019-03-02, 01:38   #7
ATH
Einyen

Dec 2003
Denmark

3,137 Posts

Quote:
 Originally Posted by bbb120 but different FFT can diff much？ the large Mp,the much faster prime95 than mathematica!
This is why GIMPS is so successful running for 23 years and finding 17 huge primes, because it is literally the fastest program there is, and it is running the fastest known primality testing algorithm, so we can find primes over 24 million digits.

2019-03-02, 02:02   #8
retina
Undefined

"The unspeakable one"
Jun 2006
My evil lair

17FF16 Posts

Why is the ThrustSSC much faster than a heavy goods truck?
Quote:
 Originally Posted by bbb120 ... so I think there should be something wrong with prime 95
So I think there should be something wrong with ThrustSSC.

2019-03-02, 02:35   #9
PhilF

Feb 2005

2×3×103 Posts

Quote:
 Originally Posted by bbb120 but different FFT can diff much？ the large Mp,the much faster prime95 than mathematica!
If you had a power meter attached to your computer, you would see that Prime95 pulls a lot more power than Mathematica. Where do you think that power is going?

George's program uses every available register and every CPU extension in order to maximize throughput, in addition to making the most efficient use of the CPU's cache memory. When driven to extremes like that, not only does it use more power but it speeds things up about 25 times.

Make sense?

2019-03-02, 03:43   #10
kriesel

"TF79LL86GIMPS96gpu17"
Mar 2017
US midwest

3·5·73 Posts

Quote:
 Originally Posted by PhilF If you had a power meter attached to your computer, you would see that Prime95 pulls a lot more power than Mathematica. Where do you think that power is going? George's program uses every available register and every CPU extension in order to maximize throughput, in addition to making the most efficient use of the CPU's cache memory. When driven to extremes like that, not only does it use more power but it speeds things up about 25 times. Make sense?
George's program is well tuned to maximize throughput, for each of many cpu models for many different fft lengths, and using the superior speed of the FP features. (There's a reason it's 36MB of executable code.)

Prime95 works the cpu so hard, that on some computers, you can hear the iterations. (Variation in current draw and voltage fluctuation with the computation progress causes capacitors that are a little bit piezoelectric to act as speakers. There can also be other effects, such as circuit traces heating and induction, varying magnetic forces in coils in the power supply, etc.) It tests or exceeds the cooling design limits. The laptop I'm using now for this post requires considerable throttling of prime95 to avoid thermal shutdown with prime95. It's also well known as a stress testing program in the overclocking community, and has been employed as a test program by Intel.

Last fiddled with by kriesel on 2019-03-02 at 03:44

2019-03-02, 04:03   #11
bbb120

Feb 2019
China

59 Posts

Quote:
 Originally Posted by Mysticial Absolutely: Prime95's FFT only needs to be half the size due to FFT wrap-around. Mathematica uses GMP's FFT which is a general purpose and provably-correct integer algorithm. Prime95's FFT is a specialized floating-point implementation that trades away provable-correctness from round-off error for large increases in speed. FFT differences aside, you're also using the Mod function - which is very slow. Prime95 doesn't need a mod function thanks to the aforementioned FFT wrap-around.
Is this algorithm much better and faster than lucas-lehmer algorithm ?

Testing Mersenne Primes with Elliptic Curves

 Similar Threads Thread Thread Starter Forum Replies Last Post wakko Software 6 2021-02-09 16:52 ChemicalCat59 Information & Answers 6 2017-02-20 23:22 JuanTutors Information & Answers 7 2007-06-14 17:29 jinydu Lounge 0 2007-05-07 05:05 Zeta-Flux Math 6 2005-09-22 21:47

All times are UTC. The time now is 00:24.

Wed May 19 00:24:56 UTC 2021 up 40 days, 19:05, 0 users, load averages: 1.95, 2.18, 1.97