Re: OT: Re: Sieve of Erastosthenes optimized to the max

Liste des GroupesRevenir à cl c++ 
Sujet : Re: OT: Re: Sieve of Erastosthenes optimized to the max
De : tr.17687 (at) *nospam* z991.linuxsc.com (Tim Rentsch)
Groupes : comp.lang.c++
Date : 07. Oct 2024, 16:41:21
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <86msjfzzry.fsf@linuxsc.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
User-Agent : Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Vir Campestris <vir.campestris@invalid.invalid> writes:

On 28/09/2024 21:49, Keith Thompson wrote:
>
Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>
Vir Campestris <vir.campestris@invalid.invalid> writes:
>
[...]
>
I tried to post a short followup, but I must have done something
wrong because nothing went out.  Long story short, I've been
pulled away from looking at this further due to other tasks
demanding my attention, and also because the Sieve of Aiken
looks more promising (having been reminded recently of
primegen by Daniel Bernstein).
>
Typo:  Sieve of Atkin.
>
https://en.wikipedia.org/wiki/Sieve_of_Atkin
>
In any case, thank you for the back and forth, it's been fun.
>
[...]
>
I now have a working version storing all primes as (prime/30
mask(prime%30) and tuned up.
>
The disappointing thing is that it's not until you get to seriously
big numbers - something in the 1e9 range - that this is faster than
the code I posted before.  And even then it's not _much_ faster.  About
20% at 1e11.

This reaction, more broadly, has been rather surprising.  The whole
point of using a sieve is that it is asymptotically faster.  Who
cares about how fast primes under a billion, or ten billion, or
fifty billion, can be computed?  It's much more interesting to ask
how high a limit can be searched in a day or a week of computing.
(I don't mean just your comment, but comments from other folks
bragging about how fast they can find all 32-bit primes.)  I ran
my earlier programs up to limits of 3 trillion or so.

Over in comp.lang.c this came up too, and there's a link there to the
Sieve of Atkin
>
<https://en.wikipedia.org/wiki/Sieve_of_Atkin>
>
and to a program
>
<http://cr.yp.to/primegen.html>
>
which implements it.

I saw this link but didn't play around with the program.

I'm pleased to be able to report that that program, written for a 1998
CPU, is slower than mine on my modern CPU.

What has been interesting is that these days prime-finding programs
really need to be tailored to the hardware they will be run on.
Somehow that seems like a step backwards.  Fifty years ago programmers
always thought about low-level hardware characteristics when writing
programs.  Over time the fraction of time spent worrying about such
things has gotten smaller and smaller, to the point now where it is
almost never important.  But wanting to write a fast prime-finding
program has taken us back to the glory days of yesteryear. ;)

Incidentally, I found a program primesieve that's available under
Ubuntu Linux.  On a whim I had it find primes less than 2**49,
which took slightly more than 12 hours elapsed time (running on 12
cores).  If computing primes up to N, a nice ratio to compute is

    (number of primes less than N) * log N / N

which converges to 1, but very slowly.  For primes less than 2**49
I got 1.03135087927594382.

Date Sujet#  Auteur
30 Jun 24 * Re: Sieve of Erastosthenes optimized to the max54Vir Campestris
2 Jul 24 `* Re: Sieve of Erastosthenes optimized to the max53Tim Rentsch
2 Jul 24  +- Re: Sieve of Erastosthenes optimized to the max1Vir Campestris
3 Jul 24  `* Re: Sieve of Erastosthenes optimized to the max51Vir Campestris
15 Jul 24   +- Re: Sieve of Erastosthenes optimized to the max1Tim Rentsch
20 Jul 24   +* Re: Sieve of Erastosthenes optimized to the max48Tim Rentsch
25 Jul 24   i`* OT: Re: Sieve of Erastosthenes optimized to the max47Vir Campestris
10 Aug 24   i +* Re: OT: Re: Sieve of Erastosthenes optimized to the max44Tim Rentsch
12 Aug 24   i i+* Re: OT: Re: Sieve of Erastosthenes optimized to the max2Vir Campestris
16 Aug 24   i ii`- Re: OT: Re: Sieve of Erastosthenes optimized to the max1Tim Rentsch
15 Aug 24   i i`* Re: OT: Re: Sieve of Erastosthenes optimized to the max41Vir Campestris
16 Aug 24   i i `* Re: OT: Re: Sieve of Erastosthenes optimized to the max40Tim Rentsch
16 Aug 24   i i  +* Re: OT: Re: Sieve of Erastosthenes optimized to the max38Bonita Montero
16 Aug 24   i i  i+- Re: OT: Re: Sieve of Erastosthenes optimized to the max1Bonita Montero
19 Aug 24   i i  i+* Re: OT: Re: Sieve of Erastosthenes optimized to the max19Vir Campestris
20 Aug 24   i i  ii`* Re: OT: Re: Sieve of Erastosthenes optimized to the max18Bonita Montero
20 Aug 24   i i  ii `* Re: OT: Re: Sieve of Erastosthenes optimized to the max17Bonita Montero
20 Aug 24   i i  ii  +- Re: OT: Re: Sieve of Erastosthenes optimized to the max1Bonita Montero
20 Aug 24   i i  ii  `* Re: OT: Re: Sieve of Erastosthenes optimized to the max15Vir Campestris
20 Aug 24   i i  ii   +- Re: OT: Re: Sieve of Erastosthenes optimized to the max1Bonita Montero
26 Aug 24   i i  ii   `* Re: OT: Re: Sieve of Erastosthenes optimized to the max13Tim Rentsch
27 Aug 24   i i  ii    `* Re: OT: Re: Sieve of Erastosthenes optimized to the max12Bonita Montero
1 Sep 24   i i  ii     `* Re: OT: Re: Sieve of Erastosthenes optimized to the max11Vir Campestris
2 Sep 24   i i  ii      `* Re: OT: Re: Sieve of Erastosthenes optimized to the max10Tim Rentsch
2 Sep 24   i i  ii       +- Re: OT: Re: Sieve of Erastosthenes optimized to the max1Bonita Montero
3 Sep 24   i i  ii       `* Re: OT: Re: Sieve of Erastosthenes optimized to the max8Vir Campestris
28 Sep 24   i i  ii        `* Re: OT: Re: Sieve of Erastosthenes optimized to the max7Tim Rentsch
28 Sep 24   i i  ii         `* Re: OT: Re: Sieve of Erastosthenes optimized to the max6Keith Thompson
2 Oct 24   i i  ii          `* Re: OT: Re: Sieve of Erastosthenes optimized to the max5Vir Campestris
2 Oct 24   i i  ii           +- Re: OT: Re: Sieve of Erastosthenes optimized to the max1Bonita Montero
7 Oct 24   i i  ii           `* Re: OT: Re: Sieve of Erastosthenes optimized to the max3Tim Rentsch
20 Oct 24   i i  ii            `* Re: OT: Re: Sieve of Erastosthenes optimized to the max2Vir Campestris
4 Nov 24   i i  ii             `- Re: OT: Re: Sieve of Erastosthenes optimized to the max1Tim Rentsch
19 Aug 24   i i  i+* Re: OT: Re: Sieve of Erastosthenes optimized to the max12Vir Campestris
20 Aug 24   i i  ii+* Re: OT: Re: Sieve of Erastosthenes optimized to the max4red floyd
20 Aug 24   i i  iii+* Re: OT: Re: Sieve of Erastosthenes optimized to the max2Vir Campestris
26 Aug 24   i i  iiii`- Re: OT: Re: Sieve of Erastosthenes optimized to the max1Tim Rentsch
26 Aug 24   i i  iii`- Re: OT: Re: Sieve of Erastosthenes optimized to the max1Tim Rentsch
20 Aug 24   i i  ii+* Re: OT: Re: Sieve of Erastosthenes optimized to the max3Bonita Montero
20 Aug 24   i i  iii+- Re: OT: Re: Sieve of Erastosthenes optimized to the max1Bonita Montero
20 Aug 24   i i  iii`- Re: OT: Re: Sieve of Erastosthenes optimized to the max1Bonita Montero
20 Aug 24   i i  ii`* Re: OT: Re: Sieve of Erastosthenes optimized to the max4Bonita Montero
22 Aug 24   i i  ii `* Re: OT: Re: Sieve of Erastosthenes optimized to the max3Vir Campestris
22 Aug 24   i i  ii  `* Re: OT: Re: Sieve of Erastosthenes optimized to the max2Bonita Montero
22 Aug 24   i i  ii   `- Re: OT: Re: Sieve of Erastosthenes optimized to the max1Vir Campestris
22 Aug 24   i i  i`* Re: OT: Re: Sieve of Erastosthenes optimized to the max5Vir Campestris
23 Aug 24   i i  i +* Re: OT: Re: Sieve of Erastosthenes optimized to the max3red floyd
26 Aug 24   i i  i i+- Re: OT: Re: Sieve of Erastosthenes optimized to the max1Tim Rentsch
28 Sep 24   i i  i i`- Re: OT: Re: Sieve of Erastosthenes optimized to the max1Andrey Tarasevich
26 Aug 24   i i  i `- Re: OT: Re: Sieve of Erastosthenes optimized to the max1Tim Rentsch
19 Aug 24   i i  `- Re: OT: Re: Sieve of Erastosthenes optimized to the max1Tim Rentsch
11 Aug 24   i +- Re: OT: Re: Sieve of Erastosthenes optimized to the max1Tim Rentsch
11 Aug 24   i `- Re: OT: Re: Sieve of Erastosthenes optimized to the max1Tim Rentsch
23 Jul 24   `- Re: Sieve of Erastosthenes optimized to the max1Tim Rentsch

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal