mersenneforum.org  

Go Back   mersenneforum.org > Great Internet Mersenne Prime Search > Software

Reply
 
Thread Tools
Old 2019-03-02, 00:27   #1
bbb120
 
bbb120's Avatar
 
Feb 2019
China

3B16 Posts
Default 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]]
bbb120 is offline   Reply With Quote
Old 2019-03-02, 00:32   #2
Prime95
P90 years forever!
 
Prime95's Avatar
 
Aug 2002
Yeehaw, FL

22×1,873 Posts
Default

Quote:
Originally Posted by bbb120 View Post
it is much much much much faster than mathematica !
so I think there should be something wrong with prime 95
LOL
Prime95 is offline   Reply With Quote
Old 2019-03-02, 00:34   #3
paulunderwood
 
paulunderwood's Avatar
 
Sep 2002
Database er0rr

1110010111012 Posts
Default

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
paulunderwood is offline   Reply With Quote
Old 2019-03-02, 01:00   #4
bbb120
 
bbb120's Avatar
 
Feb 2019
China

738 Posts
Default

Quote:
Originally Posted by paulunderwood View Post
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!
bbb120 is offline   Reply With Quote
Old 2019-03-02, 01:21   #5
Mysticial
 
Mysticial's Avatar
 
Sep 2016

5148 Posts
Default

Quote:
Originally Posted by bbb120 View Post
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.
Mysticial is offline   Reply With Quote
Old 2019-03-02, 01:33   #6
kriesel
 
kriesel's Avatar
 
"TF79LL86GIMPS96gpu17"
Mar 2017
US midwest

3·5·73 Posts
Default

Quote:
Originally Posted by bbb120 View Post
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
kriesel is offline   Reply With Quote
Old 2019-03-02, 01:38   #7
ATH
Einyen
 
ATH's Avatar
 
Dec 2003
Denmark

3,137 Posts
Default

Quote:
Originally Posted by bbb120 View Post
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.
ATH is offline   Reply With Quote
Old 2019-03-02, 02:02   #8
retina
Undefined
 
retina's Avatar
 
"The unspeakable one"
Jun 2006
My evil lair

17FF16 Posts
Default

Why is the ThrustSSC much faster than a heavy goods truck?
Quote:
Originally Posted by bbb120 View Post
... so I think there should be something wrong with prime 95
So I think there should be something wrong with ThrustSSC.
retina is offline   Reply With Quote
Old 2019-03-02, 02:35   #9
PhilF
 
PhilF's Avatar
 
Feb 2005
Colorado

2×3×103 Posts
Default

Quote:
Originally Posted by bbb120 View Post
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?
PhilF is offline   Reply With Quote
Old 2019-03-02, 03:43   #10
kriesel
 
kriesel's Avatar
 
"TF79LL86GIMPS96gpu17"
Mar 2017
US midwest

3·5·73 Posts
Default

Quote:
Originally Posted by PhilF View Post
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
kriesel is offline   Reply With Quote
Old 2019-03-02, 04:03   #11
bbb120
 
bbb120's Avatar
 
Feb 2019
China

59 Posts
Default

Quote:
Originally Posted by Mysticial View Post
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
https://link.springer.com/chapter/10.1007/11870814_27
bbb120 is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is Mathematica really slow? wakko Software 6 2021-02-09 16:52
How to make Prime95 run faster without charger? ChemicalCat59 Information & Answers 6 2017-02-20 23:22
Long Division in Mathematica JuanTutors Information & Answers 7 2007-06-14 17:29
Mathematica 6 Released jinydu Lounge 0 2007-05-07 05:05
Mathematica question-solving systems 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

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.