mersenneforum.org  

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

Reply
 
Thread Tools
Old 2018-08-05, 17:55   #45
ktpn2011
 
Aug 2018
GEORGIA Republic

2810 Posts
Default

1. about your code: I just put main LL algo, instead of some 'modpow optimization'
2. back to sqrt. I looked in debugger, and Perl's BigInt
library is a GMP. And code executing was some written in MMX registers, possible name 'basecase_sqr', but from one glance, nothing like simple loops of MUL. need more info on that code.
ktpn2011 is offline   Reply With Quote
Old 2018-08-07, 11:12   #46
ktpn2011
 
Aug 2018
GEORGIA Republic

1C16 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
... PARIdroid

Hi! I become interested and downloaded it, but some strange happens, 10^390625 is same, as (10^390625)^2 ; does [+++] means "more digits there"?

this just overflows 10^390625^2.

Last fiddled with by ktpn2011 on 2018-08-07 at 11:14
ktpn2011 is offline   Reply With Quote
Old 2018-08-07, 11:15   #47
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

Quote:
Originally Posted by ktpn2011 View Post
Hi! I become interested and downloaded it, but some strange happens, 10^390625 is same, as (10^390625)^2 ; this just overflows 10^390625^2.
allocatemem is you're friend that and parisizemax
science_man_88 is offline   Reply With Quote
Old 2018-08-07, 11:28   #48
ktpn2011
 
Aug 2018
GEORGIA Republic

22·7 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
allocatemem is you're friend that and parisizemax
i edited my question.. +++ means there are more number.

Now I just want to get 100m digit number in binary file. (not 100.. text)
Can I do it?
ktpn2011 is offline   Reply With Quote
Old 2018-08-07, 12:25   #49
ktpn2011
 
Aug 2018
GEORGIA Republic

348 Posts
Default

got near
x=10^(390625*16); writebin ("outfile", x)

but not only number is inside, some other info

Last fiddled with by ktpn2011 on 2018-08-07 at 12:26
ktpn2011 is offline   Reply With Quote
Old 2018-08-07, 12:52   #50
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

Quote:
Originally Posted by ktpn2011 View Post
Now I just want to get 100m digit number in binary file. (not 100.. text)
Can I do it?
I mean, sure, but I wouldn't really recommend gp for this sort of thing.

Most directly you could do
Code:
binary(greatBigNumber)
and have it as a 332-million element vector. If that's too big you could do a bit more work to get it as a Vecsmall or peel off the digits one by one and write them to a file.
CRGreathouse is offline   Reply With Quote
Old 2018-08-07, 20:57   #51
ktpn2011
 
Aug 2018
GEORGIA Republic

22·7 Posts
Default

Quote:
Originally Posted by paulunderwood View Post
If FFT is a bit daunting for you, you could easily implement Karatsuba.
today implemented Karatuba basic step..huh overcoming extra-bit problem
ktpn2011 is offline   Reply With Quote
Old 2018-08-07, 23:38   #52
danaj
 
"Dana Jacobsen"
Feb 2011
Bangkok, TH

22·227 Posts
Default

Regarding the Perl,

There are lots of little things one could do outside the powmod to be either cleaner or faster, but it is really irrelevent for this purpose.

Perl has multiple bigint backends, from the gawdawful-slow-but-super-portable pure Perl, old Pari, or GMP. Kriesel's script asks specifically for GMP though doesn't it will just whine and keep running if it isn't available.

Using the Math::BigInt front end has a lot of overhead for each operation. Math::GMPz is less portable (in that you *have* to have GMP) and more brittle for coding (get a type wrong and it barfs nastily), but has almost no overhead. Much more similar timings to using C+GMP.

Even so, for 86243 it is only about 15% slower than C+GMP using the same method (three step mul/pow, sub, mod). But it is about 5x slower than when we use the efficient mod for 2^p-1. E.g.

Code:
time perl -E 'use ntheory; say Math::Prime::Util::GMP::is_mersenne_prime(86243)'
1
user	0m11.391s
which uses code basically identical to what is shown at RosettaCode (since that was copied from the Perl module).
danaj is offline   Reply With Quote
Old 2018-08-08, 19:25   #53
kriesel
 
kriesel's Avatar
 
"TF79LL86GIMPS96gpu17"
Mar 2017
US midwest

541810 Posts
Default

Quote:
Originally Posted by danaj View Post
Regarding the Perl,

There are lots of little things one could do outside the powmod to be either cleaner or faster, but it is really irrelevent for this purpose.
...

Even so, for 86243 it is only about 15% slower than C+GMP using the same method (three step mul/pow, sub, mod). But it is about 5x slower than when we use the efficient mod for 2^p-1. E.g.

Code:
time perl -E 'use ntheory; say Math::Prime::Util::GMP::is_mersenne_prime(86243)'
1
user    0m11.391s
which uses code basically identical to what is shown at RosettaCode (since that was copied from the Perl module).
Very useful input.

That form of time is linux-specific; https://www.lifewire.com/command-ret...ommand-4054237
The following errors on windows 7;
perl -E 'use ntheory; say Math::Prime::Util::GMP::is_mersenne_prime(86243);'
Code:
Can't find string terminator "'" anywhere before EOF at -e line 1.
A Windows compatible rough equivalent but limited to one second resolution is pmp.pl
Code:
$t1=time();
use ntheory;
$p=86243;
$bool=Math::Prime::Util::GMP::is_mersenne_prime($p);
$dt=time()-$t1;
print "exponent $p yields $bool in $dt seconds\n";
# $bool 0 composite, 1 prime
On Windows, one could use cmd line time /T before and after but its resolution is only a minute then. One could use cmd line time with a <(file containing a carriage return) for a bit more time resolution, ~1/64 second.
Code:
time <cr.txt
time <cr.txt
perl pmp.pl
 time <cr.txt
On my i3-M370, one core, 86243 ntheory took ~149. seconds. I ran the ntheory version for several exponents and compensated the timings for the time required to get time at the cmd line (~.01 sec) It extrapolates to 4-8 times faster than the 3-step perl code, and 3 to 3200. times faster than the ASM code. All are orders of magnitude too slow for exponents at or beyond the GIMPS wavefront, hence irrelevant for GIMPS progress.

Interestingly, https://metacpan.org/pod/Math::Prime...mersenne_prime says it uses a list or table for various known Mersenne primes up to 37,156,667. The timings seem too long for that to be the case.
Attached Files
File Type: pdf perl vs asm n2.pdf (23.7 KB, 125 views)
kriesel is online now   Reply With Quote
Old 2018-08-08, 20:31   #54
danaj
 
"Dana Jacobsen"
Feb 2011
Bangkok, TH

90810 Posts
Default

Quote:
Originally Posted by kriesel View Post
The following errors on windows 7;
perl -E 'use ntheory; say Math::Prime::Util::GMP::is_mersenne_prime(86243);'
The DOS shell is crippled in many ways. In this case it doesn't understand single quotes, so you need to use double quotes.

As for timing, I don't do a lot with it on Windows. It looks like you have to do some work yourself, maybe with Time::HiRes.

Quote:
It extrapolates to 4-8 times faster than the 3-step perl code, and 3 to 3200. times faster than the ASM code. All are orders of magnitude too slow for exponents at or beyond the GIMPS wavefront, hence irrelevant for GIMPS progress.
This seems pretty close to what I see. It is using standard GMP calls so won't be remotely competitive with gwnum (used by prime95 / GIMPS) for large values. That is mentioned in the documentation.

Quote:
Interestingly, https://metacpan.org/pod/Math::Prime...mersenne_prime says it uses a list or table for various known Mersenne primes up to 37,156,667. The timings seem too long for that to be the case.
Yes, the one-liner above is calling the GMP back-end directly, which bypasses those checks. If you took out the '::GMP' part you would get the standard C code (or Perl if you disable the C code) which has a list and checks it. It takes under a tenth of a second on my Macbook and would be much less for repeated calls.
danaj is offline   Reply With Quote
Old 2018-08-09, 02:39   #55
kriesel
 
kriesel's Avatar
 
"TF79LL86GIMPS96gpu17"
Mar 2017
US midwest

10101001010102 Posts
Default

Quote:
Originally Posted by danaj View Post
The DOS shell is crippled in many ways. In this case it doesn't understand single quotes, so you need to use double quotes.

As for timing, I don't do a lot with it on Windows. It looks like you have to do some work yourself, maybe with Time::HiRes.
Yes. Or Powershell Measure Command. https://stackoverflow.com/questions/...-in-powershell

In http://perldoc.perl.org/Time/HiRes.html They're not kidding when stating "Some calls simply aren't available, real or emulated, on every platform."

Code:
use Time::HiRes qw( usleep ualarm gettimeofday tv_interval nanosleep          clock_gettime clock_getres clock_nanosleep clock stat lstat utime);
after a succession of messages similar to
Code:
Time::HiRes::ualarm(): unimplemented in this platform at hrt2.pl line 1.
BEGIN failed--compilation aborted at hrt2.pl line 3
. reduced to
Code:
use Time::HiRes qw( usleep gettimeofday tv_interval stat lstat );

Last fiddled with by kriesel on 2018-08-09 at 02:39
kriesel is online now   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Primality test based on factorization of n^2+n+1 carpetpool Miscellaneous Math 5 2018-02-05 05:20
Composites that pass Mathematica's pseudoprime test grandpascorpion Math 15 2012-03-23 02:52
Prime numbers Grid, to test an odd integer on 44 Zarck Math 5 2012-03-06 14:43
Faster Lucas-Lehmer test using integer arithmetic? __HRB__ Software 188 2010-08-09 11:13
please help me pass the test. caliman Hardware 2 2007-11-08 06:12

All times are UTC. The time now is 18:12.


Sun Aug 1 18:12:19 UTC 2021 up 9 days, 12:41, 0 users, load averages: 3.63, 3.18, 2.67

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.