mersenneforum.org GAPS BETWEEN PRIME PAIRS (Twin Primes)
 Register FAQ Search Today's Posts Mark Forums Read

 2019-05-21, 00:26 #78 firejuggler     Apr 2010 Over the rainbow 1001001111012 Posts ok, here are my numbers bat/perl with 2 core Code: Start Time: 2:20:59,69 Finish Time: 2:22:46,67 almost 2 min The new script (which doesn't write a file yet) on a single core Code: elapsed time = 01:02:17.972027 So it seems thatthe new perl script is about 4 time quicker.
2019-05-21, 14:33   #79
Thomas11

Feb 2003

190510 Posts

Quote:
 Originally Posted by Thomas11 I did the same test (for only one iteration) on the same machine under Windows 10 and there it is much slower: 2 minutes (Win) vs. 3 secs (Linux)!
I investigated this a little bit further and found the source of this discrepancy:
There are actually two different functions with the same name "sieve_prime_cluster". One is defined in Math::Prime::Utils, and another (slower) one is defined in Math::Prime::Utils::GMP.

While on Linux it correctly uses the faster one from Math::Prime::Utils, on Windows it seems to fall back to the slower one from Math::Prime::Utils::GMP, even if this package isn't explicitly used by the script.

You can test this on your machine(s) by changing the line
Code:
use Math::Prime::Util qw/:all/;
into
Code:
use Math::Prime::Util::GMP qw/:all/;
If you get (roughly) identical timings, your environment is always using the slower one from Math::Prime::Util::GMP.

On Linux I get 3 secs vs. 65 secs, while on Windows I'm getting 65 secs in both cases. (All for just one 2e8 iteration.)

2019-05-21, 17:43   #80
firejuggler

Apr 2010
Over the rainbow

5×11×43 Posts

ok, so apparently I have the slow verion on windows. any way to specify the faster module?
Attached Files
 report-classic.txt (11.7 KB, 20 views) report-gmp.txt (2.6 KB, 19 views)

 2019-05-22, 08:58 #81 Thomas11     Feb 2003 3×5×127 Posts Here are some further timings for the two versions of sieve_prime_cluster, all for one iteration (interval = 2e8): Code: $from "GMP" "non-GMP" ---------------------------- 0 112.4 sec 3.3 sec 3.7e6 109.8 sec 3.1 sec 3.7e10 36.8 sec 2.2 sec 3.7e14 12.4 sec 2.5 sec 3.7e15 10.5 sec 3.0 sec Quite interesting, how the slow one significantly gains speed with increasing numbers. 2019-05-23, 13:26 #82 Thomas11 Feb 2003 35618 Posts Meanwhile I finished the interval [8.5e14;9.0e14]. Code: 3016 860568785161207 3104 850373961384458 3111 854246643055437 ... 3940 874799018995998 3968 889713596180965 4065 862629306774760 The attached file contains the full list of gaps (182 in total) which are not yet in Fischer's list. Please let me know from where I should continue (9.5e14 or 1e15)...? Attached Files  gaplist_850-900e12.txt (3.9 KB, 18 views) 2019-05-23, 14:58 #83 robert44444uk Jun 2003 Oxford, UK 111010100112 Posts Quote:  Originally Posted by Thomas11 Meanwhile I finished the interval [8.5e14;9.0e14]. Code: 3016 860568785161207 3104 850373961384458 3111 854246643055437 ... 3940 874799018995998 3968 889713596180965 4065 862629306774760 The attached file contains the full list of gaps (182 in total) which are not yet in Fischer's list. Please let me know from where I should continue (9.5e14 or 1e15)...? I'd go for 9.5e14. Out of interest one of the two perl suites has a twin_prime function that may be quicker. Has anyone tried? 2019-05-23, 17:43 #84 firejuggler Apr 2010 Over the rainbow 5·11·43 Posts Meanwhile, I have done about 25% of my workload, from 9e15 to 9.01e15 I'm sure many gap I found are the same as Thomas one. His are better than mine, probably. Found 325 gap Code: 3016 9000070942331767 3104 9001387635261233 3111 9001088083731142 ... 4226 9002250610190467 4443 9009758172001925 4905 9000382149988845 Attached Files  gaplist 9e15-9.01e15 .txt (7.4 KB, 17 views) Last fiddled with by firejuggler on 2019-05-23 at 17:46 2019-05-24, 09:06 #85 Thomas11 Feb 2003 3×5×127 Posts Quote:  Originally Posted by robert44444uk I'd go for 9.5e14. Out of interest one of the two perl suites has a twin_prime function that may be quicker. Has anyone tried? Okay, I'm running the interval [9.5e14;1e15] now, still with the newpgen/perl combo. I also started another range starting from 1e15 using the perl approach (see below). Your suggestion of using the "twin_primes" function was a really a good idea, Robert! I already tested it before, and found a similar performance to the use of "sieve_prime_cluster". That was on my Linux system... Now, I've tested it again on Windows and getting the same speed as on Linux (about 10 secs per 1e9 interval). So, the performance drop is gone! I modified Robert's perl script as follows: It uses a subinterval of 1e9 now, which seems to be optimal. And I eliminated the need for the overlap between subintervals by keeping the last twin of each interval. The "overlap" is still used once in order to obtain the last twin preceding the search interval. BTW: Robert, note the use of "use integer" which solves your earlier printing problem with numbers greater than 1e15. Code: #!/usr/bin/env perl use warnings; use strict; use Math::Prime::Util qw/:all/; use v5.10; use Time::HiRes qw(gettimeofday time tv_interval);$|=1;

my $interval = 1_000_000_000; my$overlap = 100_000;

my $from = shift || 1_000_000_000_000_000; my$numberofiterations = shift || 1;
my $reportsmallgapmult = shift || 2000; my$t0 = [gettimeofday];

# find the largest twin prime below search interval
my @twins = @{twin_primes(6*$from-6*$overlap, 6*$from)}; my$lasttwin = $twins[$#twins];

for (my $k=0;$k < $numberofiterations;$k++)
{
my $start = 6*($from+$k*$interval);
my $end =$start+$interval*6; my @twins = @{twin_primes($start, $end)}; my$gap = ($twins[0]-$lasttwin);
if ($gap>=$reportsmallgapmult*6)
{
use integer;
say $gap/6, " ", ($lasttwin+1)/6;
}

for (my $l=1;$l < scalar @twins; $l++) { my$gap = ($twins[$l]-$twins[$l-1]);
if ($gap>=$reportsmallgapmult*6)
{
use integer;
my $firsttwin = ($twins[$l-1]+1)/6; say$gap/6, " ", $firsttwin; } }$lasttwin = $twins[$#twins];
}

my $duration = tv_interval($t0);
printf ("\nExecution time: %.2fs\n", \$duration);

 2019-05-24, 14:51 #86 robert44444uk     Jun 2003 Oxford, UK 3×54 Posts I can't wait to use the new program when I get back next week. Any chance someone can make this multithread?
2019-05-24, 19:14   #87
Thomas11

Feb 2003

3·5·127 Posts

Quote:
 Originally Posted by robert44444uk Any chance someone can make this multithread?
Well, speaking for myself, I just run several instances of it, each in it's own directory.

2019-05-25, 06:51   #88
robert44444uk

Jun 2003
Oxford, UK

3×54 Posts

Quote:
 Originally Posted by Thomas11 Well, speaking for myself, I just run several instances of it, each in it's own directory.
That's what I normally do as well 😀

I'm not confident to program perl with threads. It would make our searching more efficient though

 Similar Threads Thread Thread Starter Forum Replies Last Post Bobby Jacobs Prime Gap Searches 51 2020-07-09 07:49 Pietro Maiorana Twin Prime Search 8 2019-09-26 23:07 hal1se Miscellaneous Math 13 2018-11-05 16:34 carpetpool Miscellaneous Math 3 2017-08-10 13:47 PawnProver44 Miscellaneous Math 10 2016-04-10 19:32

All times are UTC. The time now is 05:33.

Wed Aug 5 05:33:13 UTC 2020 up 19 days, 1:19, 1 user, load averages: 1.75, 1.50, 1.35