Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c++
Subject: Re: OT: Re: Sieve of Erastosthenes optimized to the max
Date: Mon, 26 Aug 2024 12:08:11 -0700
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <86v7zn3xwk.fsf@linuxsc.com>
References: <86o78mpnlf.fsf@linuxsc.com> <86ttibod7n.fsf@linuxsc.com> <86h6eaoi2r.fsf@linuxsc.com> <867celixcw.fsf@linuxsc.com> <86zfr0b9hw.fsf@linuxsc.com> <861q3o5do1.fsf@linuxsc.com> <868qx45v5g.fsf@linuxsc.com> <86r0aojx1m.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Mon, 26 Aug 2024 21:08:13 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="d6baed66fa18aad174400126e3461865"; logging-data="2720457"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Icjjs1PEloei9m27ZcFzDkXdq0vG2jdw="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:Dn+yt2zGrsnoX4bF3A0byesO8EU= sha1:dmjCujwbAam03UexAIDsTtUL47o=
Xref: csiph.com comp.lang.c++:119915
Vir Campestris writes:
> On 20/08/2024 16:24, Bonita Montero wrote:
>
>> Am 20.08.2024 um 17:21 schrieb Bonita Montero:
>>
>>> Am 19.08.2024 um 22:23 schrieb Vir Campestris:
>>>
>>>> On 16/08/2024 18:35, Bonita Montero wrote:
>>>>
>>>>
>>>>> But basically I don't think it is a good idea to skip numbers
>>>>> exept multiples of two. [...] I think this extra computation
>>>>> is higher than the time for the saved memory loads.
[...]
> I'm leaning towards thinking you may have a point on the mod30
> code. There are more operations on the innermost loop with mod30,
> although the loop goes around fewer times. It also means that the
> store is forced to be byte wide - I find that my original odd-only
> code is significantly faster - about 30% - when the store is 64
> bit wide rather than byte. [...]
One motivation for choosing a mod30 representation is being able to
compute more primes -- almost twice as many. Any machine with 64GB
of memory should be able to compute primes up to 1.5 trillion.
Even if an odds-only representation runs faster for more limited
sizes (and I'm not yet convinced that it does), it doesn't matter
if it's faster, because it doesn't do the job. I was computing all
32-bit primes 20 years ago, back when 32-bit machines were a thing.
The challenge for today's world is correspondingly higher.