Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"We don't have to protect the environment -- the Second Coming is at hand." -- James Watt


devel / comp.lang.c++ / Re: Sieve of Eratosthenes

SubjectAuthor
* Sieve of EratosthenesBonita Montero
+* Re: Sieve of Eratostheneswij
|+* Re: Sieve of EratosthenesBonita Montero
||`- Re: Sieve of Eratostheneswij
|`* Re: Sieve of EratosthenesPaavo Helde
| `- Re: Sieve of Eratostheneswij
+* Re: Sieve of EratosthenesAlf P. Steinbach
|+- Re: Sieve of EratosthenesAlf P. Steinbach
|+* Re: Sieve of EratosthenesAlf P. Steinbach
||`* Re: Sieve of EratosthenesAlf P. Steinbach
|| `- Re: Sieve of EratosthenesChris M. Thomasson
|+* Re: Sieve of Eratosthenesred floyd
||+* Re: Sieve of EratosthenesTim Rentsch
|||`* Re: Sieve of EratosthenesÖö Tiib
||| +* Re: Sieve of EratosthenesBen Bacarisse
||| |+* Re: Sieve of EratosthenesÖö Tiib
||| ||`* Re: Sieve of EratosthenesAlf P. Steinbach
||| || +* Re: Sieve of EratosthenesÖö Tiib
||| || |`* Re: Sieve of EratosthenesBonita Montero
||| || | `* Re: Sieve of EratosthenesBonita Montero
||| || |  `* Re: Sieve of EratosthenesMuttley
||| || |   `* Re: Sieve of EratosthenesBonita Montero
||| || |    `* Re: Sieve of EratosthenesMuttley
||| || |     +* Re: Sieve of EratosthenesBonita Montero
||| || |     |`* Re: Sieve of EratosthenesMuttley
||| || |     | `- Re: Sieve of EratosthenesBonita Montero
||| || |     +* Re: Sieve of EratosthenesBonita Montero
||| || |     |+* Re: Sieve of EratosthenesMuttley
||| || |     ||`* Re: Sieve of EratosthenesBonita Montero
||| || |     || `* Re: Sieve of EratosthenesMuttley
||| || |     ||  `* Re: Sieve of EratosthenesBonita Montero
||| || |     ||   `* Re: Sieve of EratosthenesMuttley
||| || |     ||    `* Re: Sieve of EratosthenesBonita Montero
||| || |     ||     `* Re: Sieve of EratosthenesMuttley
||| || |     ||      `* Re: Sieve of EratosthenesBonita Montero
||| || |     ||       `* Re: Sieve of EratosthenesMuttley
||| || |     ||        `* Re: Sieve of EratosthenesBonita Montero
||| || |     ||         `* Re: Sieve of EratosthenesMuttley
||| || |     ||          `* Re: Sieve of EratosthenesBonita Montero
||| || |     ||           `* Re: Sieve of EratosthenesMuttley
||| || |     ||            `* Re: Sieve of EratosthenesBonita Montero
||| || |     ||             `* Re: Sieve of EratosthenesMuttley
||| || |     ||              `* Re: Sieve of EratosthenesBonita Montero
||| || |     ||               `* Re: Sieve of EratosthenesMuttley
||| || |     ||                `- Re: Sieve of EratosthenesBonita Montero
||| || |     |`* Re: Sieve of EratosthenesBen Bacarisse
||| || |     | `- Re: Sieve of EratosthenesBonita Montero
||| || |     `* Re: Sieve of EratosthenesScott Lurndal
||| || |      +* Re: Sieve of EratosthenesBonita Montero
||| || |      |`- Re: Sieve of EratosthenesScott Lurndal
||| || |      `* Re: Sieve of EratosthenesMuttley
||| || |       `* Re: Sieve of EratosthenesBonita Montero
||| || |        `- Re: Sieve of EratosthenesScott Lurndal
||| || `- Re: Sieve of EratosthenesBen Bacarisse
||| |`* Re: Sieve of EratosthenesTim Rentsch
||| | `* Re: Sieve of EratosthenesBen Bacarisse
||| |  `* Re: Sieve of EratosthenesTim Rentsch
||| |   `- Re: Sieve of EratosthenesBen Bacarisse
||| `- Re: Sieve of EratosthenesTim Rentsch
||`* Re: Sieve of EratosthenesBonita Montero
|| `* Re: Sieve of EratosthenesBonita Montero
||  `* Re: Sieve of EratosthenesAlf P. Steinbach
||   +- Re: Sieve of EratosthenesBonita Montero
||   +- Re: Sieve of EratosthenesBonita Montero
||   `* Re: Sieve of EratosthenesBonita Montero
||    `* Re: Sieve of EratosthenesMuttley
||     `* Re: Sieve of EratosthenesBonita Montero
||      `* Re: Sieve of EratosthenesMuttley
||       `* Re: Sieve of EratosthenesBonita Montero
||        `* Re: Sieve of EratosthenesMuttley
||         `* Re: Sieve of EratosthenesBonita Montero
||          +* Re: Sieve of EratosthenesÖö Tiib
||          |`* Re: Sieve of EratosthenesBonita Montero
||          | +- Re: Sieve of EratosthenesBonita Montero
||          | `* Re: Sieve of EratosthenesÖö Tiib
||          |  `- Re: Sieve of EratosthenesBonita Montero
||          `* Re: Sieve of EratosthenesMuttley
||           `* Re: Sieve of EratosthenesBonita Montero
||            +- Re: Sieve of EratosthenesBonita Montero
||            `* Re: Sieve of EratosthenesMuttley
||             `* Re: Sieve of EratosthenesBonita Montero
||              `* Re: Sieve of EratosthenesMuttley
||               `* Re: Sieve of EratosthenesBonita Montero
||                `* Re: Sieve of EratosthenesMuttley
||                 +* Re: Sieve of EratosthenesBonita Montero
||                 |`* Re: Sieve of EratosthenesMuttley
||                 | `* Re: Sieve of EratosthenesBonita Montero
||                 |  `* Re: Sieve of EratosthenesMuttley
||                 |   `* Re: Sieve of EratosthenesBonita Montero
||                 |    `* Re: Sieve of EratosthenesMuttley
||                 |     `* Re: Sieve of EratosthenesBonita Montero
||                 |      +* Re: Sieve of EratosthenesRichard Damon
||                 |      |`* Re: Sieve of EratosthenesBonita Montero
||                 |      | `* Re: Sieve of EratosthenesMuttley
||                 |      |  `* Re: Sieve of EratosthenesBonita Montero
||                 |      |   `* Re: Sieve of EratosthenesMuttley
||                 |      |    `* Re: Sieve of EratosthenesBonita Montero
||                 |      |     `* Re: Sieve of EratosthenesMuttley
||                 |      |      `* Re: Sieve of EratosthenesBonita Montero
||                 |      |       `* Re: Sieve of EratosthenesMuttley
||                 |      |        +* Re: Sieve of EratosthenesBonita Montero
||                 |      |        `* Re: Sieve of EratosthenesDaniel
||                 |      `* Re: Sieve of EratosthenesMuttley
||                 `* Re: Sieve of EratosthenesScott Lurndal
|`* Re: Sieve of Eratostheneswij
+- Re: Sieve of EratosthenesBonita Montero
+- Re: Sieve of EratosthenesBonita Montero
`* Re: Sieve of EratosthenesBonita Montero

Pages:123456
Re: Sieve of Eratosthenes

<uchj7h$1jshg$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1215&group=comp.lang.c%2B%2B#1215

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Mon, 28 Aug 2023 09:43:45 +0200
Organization: A noiseless patient Spider
Lines: 100
Message-ID: <uchj7h$1jshg$1@dont-email.me>
References: <ubijff$3ahf3$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 28 Aug 2023 07:43:45 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="023d964efe2e78efd860082b5387a0d7";
logging-data="1700400"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18bzlaDcS6X6SYvuC5jncOHJwSR/JDa/Cg="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:6/9NXBdsbAihJ90wEVfjSFBto8s=
Content-Language: de-DE
In-Reply-To: <ubijff$3ahf3$1@dont-email.me>
 by: Bonita Montero - Mon, 28 Aug 2023 07:43 UTC

I further improved my code. Now scanning for the next prime is
signifiantly more efficient because I use a rotating bit mask.

#include <iostream>
#include <vector>
#include <charconv>
#include <string_view>
#include <algorithm>
#include <fstream>
#include <cctype>
#include <cstring>
#include <bit>

#if defined(_MSC_VER)
#pragma warning(disable: 26495) // uninitialized member
#endif

using namespace std;

int main( int argc, char **argv )
{ constexpr size_t BUF_SIZE = 0x100000;
try
{
size_t end;
if( argc < 2 )
return EXIT_FAILURE;
char const *sizeStr = argv[1];
bool hex = sizeStr[0] == '0' && (sizeStr[1] == 'x' || sizeStr[1] == 'X');
sizeStr += 2 * hex;
if( from_chars_result fcr = from_chars( sizeStr, sizeStr + strlen(
sizeStr ), end, !hex ? 10 : 16 ); (bool)fcr.ec || *fcr.ptr )
return EXIT_FAILURE;
if( size_t e = end; ++end + 7 < e )
throw bad_alloc();
using bit_vec = vector<uint8_t>;
using bit_it = bit_vec::iterator;
bit_vec sieve( (end + 7) / 8, -1 );
ofstream ofs;
union ndi_t { char c; ndi_t() {} };
using ndi_vec = vector<ndi_t>;
using ndi_vec_it = ndi_vec::iterator;
constexpr size_t AHEAD = 32;
ndi_vec printBuf;
ndi_vec_it bufBegin, bufEnd, bufFlush;
if( argc < 3 || *argv[2] )
{
ofs.exceptions( ofstream::failbit | ofstream::badbit );
ofs.open( argc >= 3 ? argv[2] : "primes.txt", ofstream::trunc );
printBuf.resize( BUF_SIZE + AHEAD - 1 );
bufBegin = printBuf.begin();
bufEnd = bufBegin;
bufFlush = bufBegin + BUF_SIZE;
}
auto print = [&]() { ofs << string_view( &to_address( bufBegin )->c,
&to_address( bufEnd )->c ); };
for( size_t p = 2; p != end; )
{
bit_it pSieve = sieve.begin();
for( size_t m = p; (m += p) < end; )
pSieve[m / 8] &= ~(1u << m % 8);
pSieve += ++p / 8;
for( uint8_t m = 1u << p % 8, mNew; ; ++p )
if( p == end ) [[unlikely]]
goto brk;
else if( *pSieve & m ) [[unlikely]]
break;
else
mNew = rotl( m, 1 ),
pSieve += mNew < m,
m = mNew;
if( !ofs.is_open() )
continue;
auto [ptr, ec] = to_chars( &bufEnd->c, &to_address( bufEnd + (AHEAD -
1) )->c, p );
if( (bool)ec ) [[unlikely]]
throw system_error( (int)ec, generic_category(), "converson failed" );
bufEnd = ptr - &bufBegin->c + bufBegin; // NOP
bufEnd++->c = '\n';
if( bufEnd >= bufFlush )
print(),
bufEnd = bufBegin;
}
brk:
print();
return EXIT_SUCCESS;
}
catch( bad_alloc const & )
{
cout << "out of memory" << endl;
}
catch( ios_base::failure const & )
{
cout << "I/O error" << endl;
}
catch( system_error const &se )
{
cout << se.what() << endl;
}
}

Re: Sieve of Eratosthenes

<uci8ta$1nj3p$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1216&group=comp.lang.c%2B%2B#1216

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: alf.p.st...@gmail.com (Alf P. Steinbach)
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Mon, 28 Aug 2023 15:53:44 +0200
Organization: A noiseless patient Spider
Lines: 99
Message-ID: <uci8ta$1nj3p$1@dont-email.me>
References: <ubijff$3ahf3$1@dont-email.me> <ubjedg$3emtj$1@dont-email.me>
<ubjrqh$3g7ve$1@redfloyd.dont-email.me> <86msyq5rqu.fsf@linuxsc.com>
<56146f63-17d7-40cc-8c42-4f29c922a8c4n@googlegroups.com>
<874jkknizq.fsf@bsb.me.uk>
<4f7eeaa9-47d5-4782-864b-476746654325n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 28 Aug 2023 13:53:46 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fa31b606d70f4d5b6f85b70f169db9b8";
logging-data="1821817"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19jbFCc9HFS+Eq0Mb1t8YnN"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:bHeO9LZmoH2ehoEl9E2g7sQEPWM=
In-Reply-To: <4f7eeaa9-47d5-4782-864b-476746654325n@googlegroups.com>
Content-Language: en-US
 by: Alf P. Steinbach - Mon, 28 Aug 2023 13:53 UTC

On 2023-08-28 8:23 AM, Öö Tiib wrote:
> On Monday, 28 August 2023 at 02:50:05 UTC+3, Ben Bacarisse wrote:
>> Öö Tiib <oot...@hot.ee> writes:
>>
>>> On Thursday, 17 August 2023 at 05:26:37 UTC+3, Tim Rentsch wrote:
>>>>
>>>> I suggest computing all 32 bit primes for the benchmark
>>>> tests. Shouldn't take too long.
>>>>
>>> Took 14 minutes to find those 203280221 primes single threaded
>>> on i7-8550U.
>> What do you mean by find? Do you include printing them out because that
>> will depend rather more on the OS.
>>
> I did try to invent a sieve algorithm this weekend, it worked, but bit
> sluggish, so I posted it.
> I did not measure printing or storing to file, only sieving and counting
> (to test that there are 203280221).
>
>> I wanted to try a newer algorithm, so I coded up a rather naive version
>> of Atkin & Bernstein's sieve in C. It needs some tidying and I imagine
>> a bit can be shaved off the time.
>>
>> It can generate a bitmap of the 203280221 primes and then count them in
>> about 40 seconds on an i5-8265U CPU @ 1.60GHz (single threaded). It
>> takes about 55 seconds to write them (in decimal) to a file. The result
>> is over 2GB:
>>
>> $ wc primes
>> 203280221 203280221 2178719347 primes
>>
> Thanks, so I apparently need to optimize my algorithm at least 30 times
> faster for it to be worth anything. Maybe next weekend.

The code I posted earlier, with limits changed to compute primes up to
32^2 - 1 and with `int` changed to `int64_t`, reports

28.9473339 seconds.
203280221 primes.

msinfo32 says "Processor Intel(R) Core(TM) i7-8700T CPU @ 2.40GHz, 2400
Mhz, 6 Core(s), 12 Logical Processor(s)"

so accounting for clock rate it seems a little bit slower than Ben's.

- Alf

#include <fmt/core.h>
#include "cppm-Timer.hpp"

#include <vector>
using std::vector;

#include <stdint.h> // int64_t
#include <stdlib.h> // EXIT_FAILURE
#include <stdio.h> // fopen, fclose

using Int64 = int64_t;

auto main() -> int
{ constexpr Int64 n = 4'294'967'295; // 2^32 - 1
constexpr Int64 sqrt_n = 65'535;

cppm::Timer timer;
auto is_composite = vector<bool>( n + 1 );
for( Int64 i = 4; i < n; i += 2 ) { is_composite[i] = true; }
for( Int64 i = 3; i < n; ) {
while( is_composite[i] ) { ++i; }
const Int64 prime = i;
if( prime <= sqrt_n ) {
for( Int64 j = prime*prime; j < n; j += 2*prime ) {
is_composite[j] = true;
}
}
++i;
}
timer.stop();
fmt::print( "{} seconds.\n", timer.seconds() );

Int64 count = 0;
for( Int64 i = 2; i < n; ++i ) {
if( not is_composite[i] ) {
++count;
}
}
fmt::print( "{} primes.\n", count );

auto f = fopen( "primes.alf.txt", "w" );
if( not f ) { return EXIT_FAILURE; }
for( Int64 i = 2; i < n; ++i ) {
if( not is_composite[i] ) {
fmt::print( f, "{:d}\n", i );
}
}
fclose( f );
}

Re: Sieve of Eratosthenes

<1872f8f6-4f5a-4059-b717-b40e8b9c5f3cn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1217&group=comp.lang.c%2B%2B#1217

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:620a:2619:b0:76f:109e:e244 with SMTP id z25-20020a05620a261900b0076f109ee244mr169060qko.5.1693238641024;
Mon, 28 Aug 2023 09:04:01 -0700 (PDT)
X-Received: by 2002:a05:6a00:cc6:b0:68b:dbbc:dd00 with SMTP id
b6-20020a056a000cc600b0068bdbbcdd00mr4723580pfv.0.1693238640524; Mon, 28 Aug
2023 09:04:00 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c++
Date: Mon, 28 Aug 2023 09:03:59 -0700 (PDT)
In-Reply-To: <uci8ta$1nj3p$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=84.50.190.130; posting-account=pysjKgkAAACLegAdYDFznkqjgx_7vlUK
NNTP-Posting-Host: 84.50.190.130
References: <ubijff$3ahf3$1@dont-email.me> <ubjedg$3emtj$1@dont-email.me>
<ubjrqh$3g7ve$1@redfloyd.dont-email.me> <86msyq5rqu.fsf@linuxsc.com>
<56146f63-17d7-40cc-8c42-4f29c922a8c4n@googlegroups.com> <874jkknizq.fsf@bsb.me.uk>
<4f7eeaa9-47d5-4782-864b-476746654325n@googlegroups.com> <uci8ta$1nj3p$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1872f8f6-4f5a-4059-b717-b40e8b9c5f3cn@googlegroups.com>
Subject: Re: Sieve of Eratosthenes
From: oot...@hot.ee (Öö Tiib)
Injection-Date: Mon, 28 Aug 2023 16:04:01 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3673
 by: Öö Tiib - Mon, 28 Aug 2023 16:03 UTC

On Monday, 28 August 2023 at 16:54:04 UTC+3, Alf P. Steinbach wrote:
> On 2023-08-28 8:23 AM, Öö Tiib wrote:
> > On Monday, 28 August 2023 at 02:50:05 UTC+3, Ben Bacarisse wrote:
> >> Öö Tiib <oot...@hot.ee> writes:
> >>
> >>> On Thursday, 17 August 2023 at 05:26:37 UTC+3, Tim Rentsch wrote:
> >>>>
> >>>> I suggest computing all 32 bit primes for the benchmark
> >>>> tests. Shouldn't take too long.
> >>>>
> >>> Took 14 minutes to find those 203280221 primes single threaded
> >>> on i7-8550U.
> >> What do you mean by find? Do you include printing them out because that
> >> will depend rather more on the OS.
> >>
> > I did try to invent a sieve algorithm this weekend, it worked, but bit
> > sluggish, so I posted it.
> > I did not measure printing or storing to file, only sieving and counting
> > (to test that there are 203280221).
> >
> >> I wanted to try a newer algorithm, so I coded up a rather naive version
> >> of Atkin & Bernstein's sieve in C. It needs some tidying and I imagine
> >> a bit can be shaved off the time.
> >>
> >> It can generate a bitmap of the 203280221 primes and then count them in
> >> about 40 seconds on an i5-8265U CPU @ 1.60GHz (single threaded). It
> >> takes about 55 seconds to write them (in decimal) to a file. The result
> >> is over 2GB:
> >>
> >> $ wc primes
> >> 203280221 203280221 2178719347 primes
> >>
> > Thanks, so I apparently need to optimize my algorithm at least 30 times
> > faster for it to be worth anything. Maybe next weekend.
>
> The code I posted earlier, with limits changed to compute primes up to
> 32^2 - 1 and with `int` changed to `int64_t`, reports
>
> 28.9473339 seconds.
> 203280221 primes.
>
> msinfo32 says "Processor Intel(R) Core(TM) i7-8700T CPU @ 2.40GHz, 2400
> Mhz, 6 Core(s), 12 Logical Processor(s)"
>
> so accounting for clock rate it seems a little bit slower than Ben's.
>
Quite likely Ben's "naive" is better algorithm. Pasted your algorithm to
Apple M1 Max (that is 3.2 GHz):

sieving 18.1471 seconds.
counting 1.8121 seconds.
203280221 primes.

Re: Sieve of Eratosthenes

<ucij2p$1pe53$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1218&group=comp.lang.c%2B%2B#1218

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!rocksolid2!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Mon, 28 Aug 2023 18:47:22 +0200
Organization: A noiseless patient Spider
Lines: 148
Message-ID: <ucij2p$1pe53$1@dont-email.me>
References: <ubijff$3ahf3$1@dont-email.me> <ubjedg$3emtj$1@dont-email.me>
<ubjrqh$3g7ve$1@redfloyd.dont-email.me> <86msyq5rqu.fsf@linuxsc.com>
<56146f63-17d7-40cc-8c42-4f29c922a8c4n@googlegroups.com>
<874jkknizq.fsf@bsb.me.uk>
<4f7eeaa9-47d5-4782-864b-476746654325n@googlegroups.com>
<uci8ta$1nj3p$1@dont-email.me>
<1872f8f6-4f5a-4059-b717-b40e8b9c5f3cn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 28 Aug 2023 16:47:21 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="023d964efe2e78efd860082b5387a0d7";
logging-data="1882275"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/oBmC2BwlWq5b4lkRNhjjmqlxL2BCP4gE="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:BACz0/CZr22HFDGNuRFOxZihAO4=
In-Reply-To: <1872f8f6-4f5a-4059-b717-b40e8b9c5f3cn@googlegroups.com>
Content-Language: de-DE
 by: Bonita Montero - Mon, 28 Aug 2023 16:47 UTC

Am 28.08.2023 um 18:03 schrieb Öö Tiib:

> Quite likely Ben's "naive" is better algorithm. Pasted your algorithm to
> Apple M1 Max (that is 3.2 GHz):
>
> sieving 18.1471 seconds.
> counting 1.8121 seconds.
> 203280221 primes.

I'd like to know how this code performs on a Apple
silicon Mac. That's while the M1 Max has a memory
bandwidh slightly below 300GB/s.

#include <iostream>
#include <vector>
#include <charconv>
#include <string_view>
#include <algorithm>
#include <fstream>
#include <cctype>
#include <cstring>
#include <bit>

#if defined(_MSC_VER)
#pragma warning(disable: 26495) // uninitialized member
#endif

using namespace std;

int main( int argc, char **argv )
{ constexpr size_t BUF_SIZE = 0x100000;
try
{
size_t end;
if( argc < 2 )
return EXIT_FAILURE;
char const *sizeStr = argv[1];
bool hex = sizeStr[0] == '0' && (sizeStr[1] == 'x' || sizeStr[1] == 'X');
sizeStr += 2 * hex;
if( from_chars_result fcr = from_chars( sizeStr, sizeStr + strlen(
sizeStr ), end, !hex ? 10 : 16 ); (bool)fcr.ec || *fcr.ptr )
return EXIT_FAILURE;
if( !++end )
throw bad_alloc();
using word_t = uint64_t;
constexpr size_t BITS = sizeof(word_t) * 8;
size_t bEnd = (end + BITS - 1) & -(ptrdiff_t)BITS;
if( bEnd < end )
throw bad_alloc();
using bit_vec = vector<word_t>;
using bit_it = bit_vec::iterator;
bit_vec sieve( (end + BITS - 1) / BITS, -1 );
ofstream ofs;
union ndi_t { char c; ndi_t() {} };
using ndi_vec = vector<ndi_t>;
using ndi_vec_it = ndi_vec::iterator;
constexpr size_t AHEAD = 32;
ndi_vec printBuf;
ndi_vec_it bufBegin, bufEnd, bufFlush;
if( argc < 3 || *argv[2] )
{
ofs.exceptions( ofstream::failbit | ofstream::badbit );
ofs.open( argc >= 3 ? argv[2] : "primes.txt", ofstream::trunc );
printBuf.resize( BUF_SIZE + AHEAD - 1 );
bufBegin = printBuf.begin();
bufEnd = bufBegin;
bufFlush = bufBegin + BUF_SIZE;
}
auto print = [&]() { ofs << string_view( &to_address( bufBegin )->c,
&to_address( bufEnd )->c ); };
for( size_t p = 2; p < end; )
{
bit_it
pSieve = sieve.begin(),
pSieveEnd = sieve.end();
if( size_t m = 2 * p; m < end )
if( p >= BITS )
{
word_t mask = ~((word_t)1 << m % BITS);
do
pSieve[m / BITS] &= mask,
mask = rotl( mask, (int)p % BITS ),
m += p;
while( m < end );
}
else
{
pSieve += m / BITS;
word_t newMask = ~((word_t)1 << m % BITS);
do
{
word_t word = *pSieve, mask;
do
mask = newMask,
word &= mask,
newMask = rotl( mask, (int)p );
while( newMask < mask );
*pSieve = word;
} while( ++pSieve != pSieveEnd );
}
if( ++p == end ) [[unlikely]]
break;
word_t mask = (word_t)1 << p % BITS;
pSieve = sieve.begin() + p / BITS;
do
{
word_t word = *pSieve;
do
if( word & mask ) [[unlikely]]
goto foundNext;
else
++p,
mask = rotl( mask, 1 );
while( mask != 1 );
} while( ++pSieve != pSieveEnd );
foundNext:
if( p >= end ) [[unlikely]]
break;
if( !ofs.is_open() )
continue;
auto [ptr, ec] = to_chars( &bufEnd->c, &to_address( bufEnd + (AHEAD -
1) )->c, p );
if( (bool)ec ) [[unlikely]]
throw system_error( (int)ec, generic_category(), "converson failed" );
bufEnd = ptr - &bufBegin->c + bufBegin; // NOP
bufEnd++->c = '\n';
if( bufEnd >= bufFlush )
print(),
bufEnd = bufBegin;
}
print();
return EXIT_SUCCESS;
}
catch( bad_alloc const & )
{
cout << "out of memory" << endl;
}
catch( ios_base::failure const & )
{
cout << "I/O error" << endl;
}
catch( system_error const &se )
{
cout << se.what() << endl;
}
}

Re: Sieve of Eratosthenes

<87cyz6n7kj.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1220&group=comp.lang.c%2B%2B#1220

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Mon, 28 Aug 2023 23:08:44 +0100
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <87cyz6n7kj.fsf@bsb.me.uk>
References: <ubijff$3ahf3$1@dont-email.me> <ubjedg$3emtj$1@dont-email.me>
<ubjrqh$3g7ve$1@redfloyd.dont-email.me> <86msyq5rqu.fsf@linuxsc.com>
<56146f63-17d7-40cc-8c42-4f29c922a8c4n@googlegroups.com>
<874jkknizq.fsf@bsb.me.uk>
<4f7eeaa9-47d5-4782-864b-476746654325n@googlegroups.com>
<uci8ta$1nj3p$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="977a4d1e6a2a373854ca610ae118af7d";
logging-data="1980276"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+dIt9hmxm3Qh2wV83KiEh5fndg6iKkZMI="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:geQPq70tjcd/tSIGbJg7Az+FiUI=
sha1:oHY+7VMC/jTIW7Zs/RHNvAMyp+c=
X-BSB-Auth: 1.7cddfce7e4654286dd0c.20230828230844BST.87cyz6n7kj.fsf@bsb.me.uk
 by: Ben Bacarisse - Mon, 28 Aug 2023 22:08 UTC

"Alf P. Steinbach" <alf.p.steinbach@gmail.com> writes:

> On 2023-08-28 8:23 AM, Öö Tiib wrote:
>> On Monday, 28 August 2023 at 02:50:05 UTC+3, Ben Bacarisse wrote:
>>> Öö Tiib <oot...@hot.ee> writes:
>>>
>>>> On Thursday, 17 August 2023 at 05:26:37 UTC+3, Tim Rentsch wrote:
>>>>>
>>>>> I suggest computing all 32 bit primes for the benchmark
>>>>> tests. Shouldn't take too long.
>>>>>
>>>> Took 14 minutes to find those 203280221 primes single threaded
>>>> on i7-8550U.
>>> What do you mean by find? Do you include printing them out because that
>>> will depend rather more on the OS.
>>>
>> I did try to invent a sieve algorithm this weekend, it worked, but bit
>> sluggish, so I posted it.
>> I did not measure printing or storing to file, only sieving and counting
>> (to test that there are 203280221).
>>
>>> I wanted to try a newer algorithm, so I coded up a rather naive version
>>> of Atkin & Bernstein's sieve in C. It needs some tidying and I imagine
>>> a bit can be shaved off the time.
>>>
>>> It can generate a bitmap of the 203280221 primes and then count them in
>>> about 40 seconds on an i5-8265U CPU @ 1.60GHz (single threaded). It
>>> takes about 55 seconds to write them (in decimal) to a file. The result
>>> is over 2GB:
>>>
>>> $ wc primes
>>> 203280221 203280221 2178719347 primes
>>>
>> Thanks, so I apparently need to optimize my algorithm at least 30 times
>> faster for it to be worth anything. Maybe next weekend.
>
> The code I posted earlier, with limits changed to compute primes up to 32^2
> - 1 and with `int` changed to `int64_t`, reports
>
> 28.9473339 seconds.
> 203280221 primes.
>
> msinfo32 says "Processor Intel(R) Core(TM) i7-8700T CPU @ 2.40GHz, 2400
> Mhz, 6 Core(s), 12 Logical Processor(s)"
>
> so accounting for clock rate it seems a little bit slower than Ben's.

On my machine, compiled with -O3, it takes just over 2 minutes. (I had
to remove the timing code and replace the fmt/core.h use with a call to
printf.)

It's not easy to compare i7 and i5 speeds from the clock rate alone.

--
Ben.

Re: Sieve of Eratosthenes

<865y4yyg3p.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1221&group=comp.lang.c%2B%2B#1221

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Mon, 28 Aug 2023 15:08:58 -0700
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <865y4yyg3p.fsf@linuxsc.com>
References: <ubijff$3ahf3$1@dont-email.me> <ubjedg$3emtj$1@dont-email.me> <ubjrqh$3g7ve$1@redfloyd.dont-email.me> <86msyq5rqu.fsf@linuxsc.com> <56146f63-17d7-40cc-8c42-4f29c922a8c4n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="1084eb5dd0b1a11121af7ba127734067";
logging-data="1985633"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19VtZCWYUEE82S3kGLre/QP+b98vdZtPrE="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:3dTPsJZKtssQ7nqS0j5HUclc/kE=
sha1:NL6gOAW1tiNYVOX4WOuF65FN1Ew=
 by: Tim Rentsch - Mon, 28 Aug 2023 22:08 UTC

Tiib <ootiib@hot.ee> writes:

> On Thursday, 17 August 2023 at 05:26:37 UTC+3, Tim Rentsch wrote:
>
>> I suggest computing all 32 bit primes for the benchmark
>> tests. Shouldn't take too long.
>
> Took 14 minutes to find those 203280221 primes single threaded
> on i7-8550U.

I'm pleased to see that my suggestions sparked some interest.

Re: Sieve of Eratosthenes

<861qfmyft6.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1222&group=comp.lang.c%2B%2B#1222

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Mon, 28 Aug 2023 15:15:17 -0700
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <861qfmyft6.fsf@linuxsc.com>
References: <ubijff$3ahf3$1@dont-email.me> <ubjedg$3emtj$1@dont-email.me> <ubjrqh$3g7ve$1@redfloyd.dont-email.me> <86msyq5rqu.fsf@linuxsc.com> <56146f63-17d7-40cc-8c42-4f29c922a8c4n@googlegroups.com> <874jkknizq.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="1084eb5dd0b1a11121af7ba127734067";
logging-data="1985633"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18EEu6l5UExzu4UTbzKBzTi4mK67yTzheI="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:3+jCKJDKLJv6IJTF9NqIJyERArs=
sha1:DNhGI6uyLklZCj3EIIfqfI7KAWs=
 by: Tim Rentsch - Mon, 28 Aug 2023 22:15 UTC

Ben Bacarisse <ben.usenet@bsb.me.uk> writes:

> I wanted to try a newer algorithm, so I coded up a rather naive
> version of Atkin & Bernstein's sieve in C. It needs some tidying
> and I imagine a bit can be shaved off the time.

Thank you for this. Would you mind posting your code? Also do
you have a reference for the Atkin/Bernstein algorithm (or even
better, code?)?

Re: Sieve of Eratosthenes

<873502n61v.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1223&group=comp.lang.c%2B%2B#1223

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Mon, 28 Aug 2023 23:41:32 +0100
Organization: A noiseless patient Spider
Lines: 135
Message-ID: <873502n61v.fsf@bsb.me.uk>
References: <ubijff$3ahf3$1@dont-email.me> <ubjedg$3emtj$1@dont-email.me>
<ubjrqh$3g7ve$1@redfloyd.dont-email.me> <86msyq5rqu.fsf@linuxsc.com>
<56146f63-17d7-40cc-8c42-4f29c922a8c4n@googlegroups.com>
<874jkknizq.fsf@bsb.me.uk> <861qfmyft6.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="977a4d1e6a2a373854ca610ae118af7d";
logging-data="1999270"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+kqgrirQ2htALGA7TcrN8Ps0Tv8leA0ZA="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:6wkIX53SI942ejTqSky1+f4UZOQ=
sha1:pItpOP+3/G7ESWhIxVRVbBU6yRs=
X-BSB-Auth: 1.2f5d63bf117c7da964c4.20230828234132BST.873502n61v.fsf@bsb.me.uk
 by: Ben Bacarisse - Mon, 28 Aug 2023 22:41 UTC

Tim Rentsch <tr.17687@z991.linuxsc.com> writes:

> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>
>> I wanted to try a newer algorithm, so I coded up a rather naive
>> version of Atkin & Bernstein's sieve in C. It needs some tidying
>> and I imagine a bit can be shaved off the time.
>
> Thank you for this. Would you mind posting your code?

Hmm... It's a bit of a mess... but sure.

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

typedef unsigned int nat;
typedef unsigned long long int big_nat;

nat isqrt(nat n)
{ if (n < 2)
return n;
nat s = (isqrt(n >> 2) << 1) + 1;
return s - (s*s > n);
}

static inline void *bitset(nat n)
{ return calloc(1, n/8 + 1);
}

static inline void bitset_clear(void *set, nat n)
{ ((unsigned char *)set)[n/8] &= ~(1 << n%8);
}

static inline void bitset_flip(void *set, nat n)
{ ((unsigned char *)set)[n/8] ^= 1 << n%8;
}

static inline bool bitset_test(const void *set, nat n)
{ return ((const unsigned char *)set)[n/8] & (1 << n%8);
}

void *primes_up_to(nat n)
{ #define B(n) (1ull << (n))
typedef big_nat small_set;

nat sqrt_n = isqrt(n);
void *pset = bitset(n);

static small_set s1 =
B(1) | B(13) | B(17) | B(29) | B(37) | B(41) | B(49) | B(53);
for (big_nat x = 1; x <= sqrt_n; x++) {
for (nat y = 1; y <= sqrt_n; y += 2) {
big_nat m = 4*x*x + y*y;
if ((B(m % 60) & s1) && m <= n)
bitset_flip(pset, m);
}
}

static small_set s2 = B(7) | B(19) | B(31) | B(43);
for (big_nat x = 1; x <= sqrt_n; x += 2) {
for (nat y = 2; y <= sqrt_n; y += 2) {
big_nat m = 3*x*x + y*y;
if ((B(m % 60) & s2) && m <= n)
bitset_flip(pset, m);
}
}

static small_set s3 = B(11) | B(23) | B(47) | B(59);
for (big_nat x = 2; x <= sqrt_n; x++) {
for (int y = x - 1; y >= 1; y -= 2) {
big_nat m = 3*x*x - y*y;
if ((B(m % 60) & s3) && m <= n)
bitset_flip(pset, m);
}
}

static small_set s =
B(1) | B(7) | B(11) | B(13) | B(17) | B(19) | B(23) | B(29) |
B(31) | B(37) | B(41) | B(43) | B(47) | B(49) | B(53) | B(59);
for (big_nat m = 2; m <= n; m++) {
if (!(B(m % 60) & s))
continue;
big_nat mm = m*m;
if (mm > n)
break;
if (bitset_test(pset, m)) {
for (big_nat m2 = 1; m2 <= n; m2++) {
if (!(B(m2 % 60) & s))
continue;
big_nat c = mm * m2;
if (c > n)
break;
bitset_clear(pset, c);
}
}
}
bitset_flip(pset, 2);
bitset_flip(pset, 3);
bitset_flip(pset, 5);
return pset;
}

int main(int argc, char **argv)
{ int p = argc > 1 ? atoi(argv[1]) : 32;
nat n = (nat)-1 >> 32 - p;
fprintf(stderr, "p=%d, n=%u\n", p, n);

void *pset = primes_up_to(n);
nat count = 0;
while (n > 0)
if (bitset_test(pset, n--))
count += 1;
printf("%u\n", count);
free(pset);
}

I wanted to get rid of the big_nat type. I's sure it can be written
using only 32-bit types.

> Also do
> you have a reference for the Atkin/Bernstein algorithm (or even
> better, code?)?

Well, there's this: https://en.wikipedia.org/wiki/Sieve_of_Atkin

--
Ben.

Re: Sieve of Eratosthenes

<ucldoh$2c6qt$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1226&group=comp.lang.c%2B%2B#1226

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Tue, 29 Aug 2023 20:34:57 +0200
Organization: A noiseless patient Spider
Lines: 149
Message-ID: <ucldoh$2c6qt$1@dont-email.me>
References: <ubijff$3ahf3$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 29 Aug 2023 18:34:57 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="29af086456143f20ae59fea3d0f6f1b5";
logging-data="2497373"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+DB4blSyOgU9hOTbhp+HSXnLwjA1d4NG0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:pU4uX7YpIoCaYTVyuWhWMN+yhec=
Content-Language: de-DE
In-Reply-To: <ubijff$3ahf3$1@dont-email.me>
 by: Bonita Montero - Tue, 29 Aug 2023 18:34 UTC

I think that's my final solution. Currently I store the bits in
size_ts and I look up the next set bit with countr_zero which maps
to TZCNT on x64 and according to some small code on godbolt ARM
also has a proper instruction for that.
Resettig the bits for the composites is done by a rotating bit-mask.
If the prime is less than size_t * 8 there's a special case optimi-
zation.

#include <iostream>
#include <vector>
#include <charconv>
#include <string_view>
#include <algorithm>
#include <fstream>
#include <cctype>
#include <cstring>
#include <bit>

#if defined(_MSC_VER)
#pragma warning(disable: 26495) // uninitialized member
#endif
#if defined(__llvm__)
#pragma clang diagnostic ignored "-Wdangling-else"
#endif

using namespace std;

int main( int argc, char **argv )
{ constexpr size_t BUF_SIZE = 0x100000;
try
{
size_t end;
if( argc < 2 )
return EXIT_FAILURE;
char const *sizeStr = argv[1];
bool hex = sizeStr[0] == '0' && (sizeStr[1] == 'x' ||
sizeStr[1] == 'X');
sizeStr += 2 * hex;
if( from_chars_result fcr = from_chars( sizeStr, sizeStr +
strlen( sizeStr ), end, !hex ? 10 : 16 ); (bool)fcr.ec || *fcr.ptr )
return EXIT_FAILURE;
if( !++end )
throw bad_alloc();
using word_t = size_t;
constexpr size_t BITS = sizeof(word_t) * 8;
size_t bEnd = (end + BITS - 1) & -(ptrdiff_t)BITS;
if( bEnd < end )
throw bad_alloc();
union ndi_word_t { word_t w; ndi_word_t( word_t w ) : w( w ) {}
};
using bit_vec = vector<ndi_word_t>;
using bit_it = bit_vec::iterator;
bit_vec sieve( (end + BITS - 1) / BITS,
(word_t)0xAAAAAAAAAAAAAAAAu );
ofstream ofs;
union ndi_t { char c; ndi_t() {} };
using ndi_vec = vector<ndi_t>;
constexpr size_t AHEAD = 32;
ndi_vec printBuf;
ndi_vec::iterator bufBegin, bufEnd, bufFlush;
if( argc < 3 || *argv[2] )
{
ofs.exceptions( ofstream::failbit | ofstream::badbit );
ofs.open( argc >= 3 ? argv[2] : "primes.txt",
ofstream::trunc );
printBuf.resize( BUF_SIZE + AHEAD - 1 );
bufBegin = printBuf.begin();
bufEnd = bufBegin;
bufFlush = bufBegin + BUF_SIZE;
}
auto print = [&]() { ofs << string_view( &to_address( bufBegin
)->c, &to_address( bufEnd )->c ); };
bit_it const pSieveEnd = sieve.end();
size_t sqr = (ptrdiff_t)ceil( sqrt( (ptrdiff_t)end ) );
for( size_t p = 2; p < end; )
{
if( ofs.is_open() )
{
auto [ptr, ec] = to_chars( &bufEnd->c, &to_address(
bufEnd + (AHEAD - 1) )->c, p );
if( (bool)ec ) [[unlikely]]
throw system_error( (int)ec, generic_category(),
"converson failed" );
bufEnd = ptr - &bufBegin->c + bufBegin; // NOP
bufEnd++->c = '\n';
if( bufEnd >= bufFlush )
ofs << string_view( &to_address( bufBegin )->c,
&to_address( bufEnd )->c ),
bufEnd = bufBegin;
}
if( ++p == end ) [[unlikely]]
break;
for( bit_it pSieve = sieve.begin() + p / BITS; ; )
{
size_t g = countr_zero( pSieve->w & (word_t)-1 << p %
BITS );
p = (p & -(ptrdiff_t)BITS) + g;
if( g != BITS )
break;
if( ++pSieve == pSieveEnd )
goto end;
}
bit_it pSieve = sieve.begin();
if( size_t m = p * p; p < sqr )
if( p >= BITS ) [[likely]]
{
word_t mask = rotl( (word_t)-2, m % BITS );
do
pSieve[m / BITS].w &= mask,
mask = rotl( mask, (int)p % BITS ),
m += p;
while( m < end );
}
else
{
pSieve += m / BITS;
word_t mask = rotl( (word_t)-2, m % BITS );
do
{
word_t punch = -1, oldMask;
do
punch &= mask,
oldMask = mask,
mask = rotl( mask, (int)p );
while( mask < oldMask );
pSieve->w &= punch;
} while( ++pSieve != pSieveEnd );
}
}
end:
if( ofs.is_open() )
print();
return EXIT_SUCCESS;
}
catch( bad_alloc const & )
{
cout << "out of memory" << endl;
}
catch( ios_base::failure const & )
{
cout << "I/O error" << endl;
}
catch( system_error const &se )
{
cout << se.what() << endl;
}
}

Re: Sieve of Eratosthenes

<ucn7hr$2n64m$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1230&group=comp.lang.c%2B%2B#1230

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Wed, 30 Aug 2023 13:01:16 +0200
Organization: A noiseless patient Spider
Lines: 63
Message-ID: <ucn7hr$2n64m$1@dont-email.me>
References: <ubijff$3ahf3$1@dont-email.me> <ubjedg$3emtj$1@dont-email.me>
<ubjrqh$3g7ve$1@redfloyd.dont-email.me> <86msyq5rqu.fsf@linuxsc.com>
<56146f63-17d7-40cc-8c42-4f29c922a8c4n@googlegroups.com>
<874jkknizq.fsf@bsb.me.uk>
<4f7eeaa9-47d5-4782-864b-476746654325n@googlegroups.com>
<uci8ta$1nj3p$1@dont-email.me>
<1872f8f6-4f5a-4059-b717-b40e8b9c5f3cn@googlegroups.com>
<ucij2p$1pe53$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 30 Aug 2023 11:01:15 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1516dabee8f133ed8fc4a778f5a0be1a";
logging-data="2857110"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19zNsugjK455Z0ZkmqBdCY+5FLMlgviTuc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:qlHbNWC2tfDlXj/lXwDORPLcrFk=
Content-Language: de-DE
In-Reply-To: <ucij2p$1pe53$1@dont-email.me>
 by: Bonita Montero - Wed, 30 Aug 2023 11:01 UTC

I implemented Alf's code according to my taste. The code has
about 40% the performance of my code if I don't output a file
with the numbers on Sklyake CPU with g++ 12 and -march=native.

#include <iostream>
#include <vector>
#include <charconv>
#include <fstream>
#include <cmath>
#include <cstring>

using namespace std;

int main( int argc, char **argv )
{ constexpr size_t BUF_SIZE = 0x100000;
size_t end;
if( argc < 2 )
return EXIT_FAILURE;
char const *sizeStr = argv[1];
bool hex = sizeStr[0] == '0' && (sizeStr[1] == 'x' || sizeStr[1] == 'X');
sizeStr += 2 * hex;
if( from_chars_result fcr = from_chars( sizeStr, sizeStr + strlen(
sizeStr ), end, !hex ? 10 : 16 ); (bool)fcr.ec || *fcr.ptr )
return EXIT_FAILURE;
if( !++end )
throw bad_alloc();
vector<bool> primes( end, true );
ofstream ofs;
string printBuf;
if( argc < 3 || *argv[2] )
ofs.exceptions( ofstream::failbit | ofstream::badbit ),
ofs.open( argc >= 3 ? argv[2] : "primes.txt", ofstream::trunc ),
printBuf.reserve( BUF_SIZE + 31 );
size_t sqr = (ptrdiff_t)ceil( sqrt( (ptrdiff_t)end ) );
for( size_t p = 2; p < end; ++p )
{
while( !primes[p] )
if( ++p == end )
goto end;
if( p < sqr )
{
size_t m = p * p;
do
primes[m] = false;
while( (m += p) < end );
}
if( !ofs.is_open() )
continue;
char strPrime[32];
auto [ptr, ec] = to_chars( strPrime, std::end( strPrime ), p );
if( (bool)ec ) [[unlikely]]
throw system_error( (int)ec, generic_category(), "converson failed" );
*ptr++ = '\n';
printBuf += string_view( strPrime, ptr );
if( printBuf.size() >= BUF_SIZE )
ofs << printBuf,
printBuf.resize( 0 );
}
end:
if( ofs.is_open() )
ofs << printBuf;
}

Re: Sieve of Eratosthenes

<ucnnop$2plof$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1231&group=comp.lang.c%2B%2B#1231

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Mutt...@dastardlyhq.com
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Wed, 30 Aug 2023 15:38:01 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <ucnnop$2plof$1@dont-email.me>
References: <ubijff$3ahf3$1@dont-email.me> <ubjedg$3emtj$1@dont-email.me>
<ubjrqh$3g7ve$1@redfloyd.dont-email.me> <86msyq5rqu.fsf@linuxsc.com>
<56146f63-17d7-40cc-8c42-4f29c922a8c4n@googlegroups.com>
<874jkknizq.fsf@bsb.me.uk>
<4f7eeaa9-47d5-4782-864b-476746654325n@googlegroups.com>
<uci8ta$1nj3p$1@dont-email.me>
<1872f8f6-4f5a-4059-b717-b40e8b9c5f3cn@googlegroups.com>
<ucij2p$1pe53$1@dont-email.me>
<ucn7hr$2n64m$1@dont-email.me>
Injection-Date: Wed, 30 Aug 2023 15:38:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1394d7f309bd261de156a64c995fae36";
logging-data="2938639"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+px2g5ER9F00dJ/vXnhme4"
Cancel-Lock: sha1:76GuGqtnxqNxGLyoaMvmCsfAPDM=
 by: Mutt...@dastardlyhq.com - Wed, 30 Aug 2023 15:38 UTC

On Wed, 30 Aug 2023 13:01:16 +0200
Bonita Montero <Bonita.Montero@gmail.com> wrote:
> if( argc < 3 || *argv[2] )
> ofs.exceptions( ofstream::failbit | ofstream::badbit ),
> ofs.open( argc >= 3 ? argv[2] : "primes.txt", ofstream::trunc ),
> printBuf.reserve( BUF_SIZE + 31 );

Commas as statement seperators instead of using a bracketed block? Are you
posting this code for lols?

Re: Sieve of Eratosthenes

<ucnqt4$2q4ic$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1232&group=comp.lang.c%2B%2B#1232

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Wed, 30 Aug 2023 18:31:32 +0200
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <ucnqt4$2q4ic$1@dont-email.me>
References: <ubijff$3ahf3$1@dont-email.me> <ubjedg$3emtj$1@dont-email.me>
<ubjrqh$3g7ve$1@redfloyd.dont-email.me> <86msyq5rqu.fsf@linuxsc.com>
<56146f63-17d7-40cc-8c42-4f29c922a8c4n@googlegroups.com>
<874jkknizq.fsf@bsb.me.uk>
<4f7eeaa9-47d5-4782-864b-476746654325n@googlegroups.com>
<uci8ta$1nj3p$1@dont-email.me>
<1872f8f6-4f5a-4059-b717-b40e8b9c5f3cn@googlegroups.com>
<ucij2p$1pe53$1@dont-email.me> <ucn7hr$2n64m$1@dont-email.me>
<ucnnop$2plof$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 30 Aug 2023 16:31:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1516dabee8f133ed8fc4a778f5a0be1a";
logging-data="2953804"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/mPPjg12hXe5BAqgPK0ej58lH7RQ/aE4g="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:dLfHiQN0eo4J6XHn5cBxJhojneo=
Content-Language: de-DE
In-Reply-To: <ucnnop$2plof$1@dont-email.me>
 by: Bonita Montero - Wed, 30 Aug 2023 16:31 UTC

Am 30.08.2023 um 17:38 schrieb Muttley@dastardlyhq.com:
> On Wed, 30 Aug 2023 13:01:16 +0200
> Bonita Montero <Bonita.Montero@gmail.com> wrote:
>> if( argc < 3 || *argv[2] )
>> ofs.exceptions( ofstream::failbit | ofstream::badbit ),
>> ofs.open( argc >= 3 ? argv[2] : "primes.txt", ofstream::trunc ),
>> printBuf.reserve( BUF_SIZE + 31 );

> Commas as statement seperators instead of using a bracketed block?
> Are you posting this code for lols?

I often concatenate a small number of statements with the comma-operator
to save screen space. I never had any issues with that. That's just a
matter of personal taste. If you're noticing this until now, I'm going
to assume that you haven't really looked at the previous code.
But that's just the syntax issue. My code is also superior in terms of
safety (iterator debuggin) and performance (+2/3 more performance with
g++ 12 and a Sklake-CPU).

Re: Sieve of Eratosthenes

<ucnsmq$2qeb0$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1233&group=comp.lang.c%2B%2B#1233

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Wed, 30 Aug 2023 19:02:19 +0200
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <ucnsmq$2qeb0$1@dont-email.me>
References: <ubijff$3ahf3$1@dont-email.me> <ucldoh$2c6qt$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 30 Aug 2023 17:02:18 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1516dabee8f133ed8fc4a778f5a0be1a";
logging-data="2963808"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18d8kuMXLliFRzNnUxm57e1AKzAS6eTdE8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:+ZANi0TnGaGoZBDzQ8QRSuFzD/U=
In-Reply-To: <ucldoh$2c6qt$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Wed, 30 Aug 2023 17:02 UTC

Am 29.08.2023 um 20:34 schrieb Bonita Montero:

> size_t g = countr_zero( pSieve->w & (word_t)-1 << p % BITS );

size_t g = countr_zero( (word_t)(pSieve->w & (word_t)-1 << p % BITS) );

OMG, an integral promotion error.
If word_t is defined < unsigned the results are wrong.

Re: Sieve of Eratosthenes

<86v8cwt4yd.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1234&group=comp.lang.c%2B%2B#1234

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Wed, 30 Aug 2023 17:45:30 -0700
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <86v8cwt4yd.fsf@linuxsc.com>
References: <ubijff$3ahf3$1@dont-email.me> <ubjedg$3emtj$1@dont-email.me> <ubjrqh$3g7ve$1@redfloyd.dont-email.me> <86msyq5rqu.fsf@linuxsc.com> <56146f63-17d7-40cc-8c42-4f29c922a8c4n@googlegroups.com> <874jkknizq.fsf@bsb.me.uk> <861qfmyft6.fsf@linuxsc.com> <873502n61v.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="49a0c7fba7d7c0f06cea865d80b29294";
logging-data="3098900"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18jUnLvIY39Y9efVy5r3tnWtOKBvSRX/Yk="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:3T3XusInddhwmJKS7M27LjwUu/0=
sha1:ZpFyUzfoR4RQbVffxxQiotqZV2Y=
 by: Tim Rentsch - Thu, 31 Aug 2023 00:45 UTC

Ben Bacarisse <ben.usenet@bsb.me.uk> writes:

> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>
>> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>>
>>> I wanted to try a newer algorithm, so I coded up a rather naive
>>> version of Atkin & Bernstein's sieve in C. It needs some tidying
>>> and I imagine a bit can be shaved off the time.
>>
>> Thank you for this. Would you mind posting your code?
>
> Hmm... It's a bit of a mess... but sure. [...]

It looks quite okay. I haven't yet had time to look at it
closely but I look forward to doing so.

>> Also do
>> you have a reference for the Atkin/Bernstein algorithm (or even
>> better, code?)?
>
> Well, there's this: https://en.wikipedia.org/wiki/Sieve_of_Atkin

Excellent! And this page has a link to DJ Bernstein's fast
primes code, which is stunningly swift.

Thank you for both.

Re: Sieve of Eratosthenes

<87wmxckl8x.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1235&group=comp.lang.c%2B%2B#1235

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Thu, 31 Aug 2023 03:18:22 +0100
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <87wmxckl8x.fsf@bsb.me.uk>
References: <ubijff$3ahf3$1@dont-email.me> <ubjedg$3emtj$1@dont-email.me>
<ubjrqh$3g7ve$1@redfloyd.dont-email.me> <86msyq5rqu.fsf@linuxsc.com>
<56146f63-17d7-40cc-8c42-4f29c922a8c4n@googlegroups.com>
<874jkknizq.fsf@bsb.me.uk> <861qfmyft6.fsf@linuxsc.com>
<873502n61v.fsf@bsb.me.uk> <86v8cwt4yd.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="b4e95399c10c70c93d0dbe52083af2de";
logging-data="3249113"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/4giosVymsa6y69qjyScBQj7LIl7p9C6A="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:LnVhlXjM9Jl03wPyIx36tnLGCII=
sha1:v9+MkNUX2ly+Y47N3ZWC/YsUoRs=
X-BSB-Auth: 1.a41446fd8e3783ae27c3.20230831031822BST.87wmxckl8x.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 31 Aug 2023 02:18 UTC

Tim Rentsch <tr.17687@z991.linuxsc.com> writes:

> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>
>> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>>
>>> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>>>
>>>> I wanted to try a newer algorithm, so I coded up a rather naive
>>>> version of Atkin & Bernstein's sieve in C. It needs some tidying
>>>> and I imagine a bit can be shaved off the time.
>>>
>>> Thank you for this. Would you mind posting your code?
>>
>> Hmm... It's a bit of a mess... but sure. [...]
>
> It looks quite okay. I haven't yet had time to look at it
> closely but I look forward to doing so.

About 20% of the time was spent counting the primes, so I added a
population count function to the bitset operations. And there's an
obvious halving one can do on the upper bound of the first loop. That
brought the time down to about 28 seconds.

>>> Also do
>>> you have a reference for the Atkin/Bernstein algorithm (or even
>>> better, code?)?
>>
>> Well, there's this: https://en.wikipedia.org/wiki/Sieve_of_Atkin
>
> Excellent! And this page has a link to DJ Bernstein's fast
> primes code, which is stunningly swift.

I haven't looked at it yet. It would probably have put me off!

> Thank you for both.

You're welcome.

--
Ben.

Re: Sieve of Eratosthenes

<ucpikj$35rda$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1238&group=comp.lang.c%2B%2B#1238

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Mutt...@dastardlyhq.com
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Thu, 31 Aug 2023 08:22:43 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <ucpikj$35rda$1@dont-email.me>
References: <ubijff$3ahf3$1@dont-email.me> <ubjedg$3emtj$1@dont-email.me>
<ubjrqh$3g7ve$1@redfloyd.dont-email.me> <86msyq5rqu.fsf@linuxsc.com>
<56146f63-17d7-40cc-8c42-4f29c922a8c4n@googlegroups.com>
<874jkknizq.fsf@bsb.me.uk>
<4f7eeaa9-47d5-4782-864b-476746654325n@googlegroups.com>
<uci8ta$1nj3p$1@dont-email.me>
<1872f8f6-4f5a-4059-b717-b40e8b9c5f3cn@googlegroups.com>
<ucij2p$1pe53$1@dont-email.me> <ucn7hr$2n64m$1@dont-email.me>
<ucnnop$2plof$1@dont-email.me>
<ucnqt4$2q4ic$1@dont-email.me>
Injection-Date: Thu, 31 Aug 2023 08:22:43 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d86a6a0bd34e9d7e70ab89a57df72b62";
logging-data="3337642"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19SSKssAXKRo0K2v9EEqswR"
Cancel-Lock: sha1:LexSeFXP+bm1foss1JXIBL4dYdo=
 by: Mutt...@dastardlyhq.com - Thu, 31 Aug 2023 08:22 UTC

On Wed, 30 Aug 2023 18:31:32 +0200
Bonita Montero <Bonita.Montero@gmail.com> wrote:
>Am 30.08.2023 um 17:38 schrieb Muttley@dastardlyhq.com:
>> On Wed, 30 Aug 2023 13:01:16 +0200
>> Bonita Montero <Bonita.Montero@gmail.com> wrote:
>>> if( argc < 3 || *argv[2] )
>>> ofs.exceptions( ofstream::failbit | ofstream::badbit ),
>>> ofs.open( argc >= 3 ? argv[2] : "primes.txt", ofstream::trunc ),
>>> printBuf.reserve( BUF_SIZE + 31 );
>
>> Commas as statement seperators instead of using a bracketed block?
>> Are you posting this code for lols?
>
>I often concatenate a small number of statements with the comma-operator
>to save screen space. I never had any issues with that. That's just a

To save space? Seriously??

>matter of personal taste. If you're noticing this until now, I'm going

Its not just personal taste, it makes the code harder to parse for anyone
who has to maintain it and could easily lead to logical errors if someone
modifies it and forgets to replace the ; with a , at the end.

>to assume that you haven't really looked at the previous code.
>But that's just the syntax issue. My code is also superior in terms of
>safety (iterator debuggin) and performance (+2/3 more performance with
>g++ 12 and a Sklake-CPU).

Yes, we know how wonderful your code is after you seem to spend multiple days
on some trivial task. Obviously no one else could ever manage what you did,
you're a coding god.

Re: Sieve of Eratosthenes

<ucpkqm$364pb$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1239&group=comp.lang.c%2B%2B#1239

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Thu, 31 Aug 2023 11:00:06 +0200
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <ucpkqm$364pb$1@dont-email.me>
References: <ubijff$3ahf3$1@dont-email.me> <ubjedg$3emtj$1@dont-email.me>
<ubjrqh$3g7ve$1@redfloyd.dont-email.me> <86msyq5rqu.fsf@linuxsc.com>
<56146f63-17d7-40cc-8c42-4f29c922a8c4n@googlegroups.com>
<874jkknizq.fsf@bsb.me.uk>
<4f7eeaa9-47d5-4782-864b-476746654325n@googlegroups.com>
<uci8ta$1nj3p$1@dont-email.me>
<1872f8f6-4f5a-4059-b717-b40e8b9c5f3cn@googlegroups.com>
<ucij2p$1pe53$1@dont-email.me> <ucn7hr$2n64m$1@dont-email.me>
<ucnnop$2plof$1@dont-email.me> <ucnqt4$2q4ic$1@dont-email.me>
<ucpikj$35rda$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 31 Aug 2023 09:00:06 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ff70a7335e595a5f320387c3a69d8d92";
logging-data="3347243"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18i66vHzDBb1HZElmSkKOvnMmv/EZCSw18="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:b9ywm5/ehIK9N2D9zZ2ssgbBnmY=
Content-Language: de-DE
In-Reply-To: <ucpikj$35rda$1@dont-email.me>
 by: Bonita Montero - Thu, 31 Aug 2023 09:00 UTC

Am 31.08.2023 um 10:22 schrieb Muttley@dastardlyhq.com:

> To save space? Seriously??

It's my taste.

> Its not just personal taste, it makes the code harder to parse for anyone
> who has to maintain ...

Not true, you just feel unsecure with that for whaterver reason.

> Yes, we know how wonderful your code is after you seem to spend multiple days
> on some trivial task. ...

The task is not trivial if you consider my solution.
You won't manage to have it that fast.

Re: Sieve of Eratosthenes

<ucpns9$36iap$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1241&group=comp.lang.c%2B%2B#1241

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Thu, 31 Aug 2023 11:52:09 +0200
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <ucpns9$36iap$1@dont-email.me>
References: <ubijff$3ahf3$1@dont-email.me> <ubjedg$3emtj$1@dont-email.me>
<ubjrqh$3g7ve$1@redfloyd.dont-email.me> <86msyq5rqu.fsf@linuxsc.com>
<56146f63-17d7-40cc-8c42-4f29c922a8c4n@googlegroups.com>
<874jkknizq.fsf@bsb.me.uk>
<4f7eeaa9-47d5-4782-864b-476746654325n@googlegroups.com>
<uci8ta$1nj3p$1@dont-email.me>
<1872f8f6-4f5a-4059-b717-b40e8b9c5f3cn@googlegroups.com>
<ucij2p$1pe53$1@dont-email.me> <ucn7hr$2n64m$1@dont-email.me>
<ucnnop$2plof$1@dont-email.me> <ucnqt4$2q4ic$1@dont-email.me>
<ucpikj$35rda$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 31 Aug 2023 09:52:09 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ff70a7335e595a5f320387c3a69d8d92";
logging-data="3361113"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19P9Evz9YGoks1HkKLqZQRW4rvCm4w1zr0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Zcl1KvigDu8fc9YhBG/ZN8cSJnY=
In-Reply-To: <ucpikj$35rda$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Thu, 31 Aug 2023 09:52 UTC

Am 31.08.2023 um 10:22 schrieb Muttley@dastardlyhq.com:

> Yes, we know how wonderful your code is after you seem to spend multiple days
> on some trivial task. Obviously no one else could ever manage what you did,
> you're a coding god.

I just benchmarked my code with an upper bound of 1E3 against your code
on a Skylake CPU with g++ 12 and -march=native. My code runs about 0.9s,
your code takes 5.26s. Any questions ?

Re: Sieve of Eratosthenes

<qG1IM.472123$xMqa.47393@fx12.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1242&group=comp.lang.c%2B%2B#1242

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx12.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Sieve of Eratosthenes
Newsgroups: comp.lang.c++
References: <ubijff$3ahf3$1@dont-email.me> <ubjrqh$3g7ve$1@redfloyd.dont-email.me> <86msyq5rqu.fsf@linuxsc.com> <56146f63-17d7-40cc-8c42-4f29c922a8c4n@googlegroups.com> <874jkknizq.fsf@bsb.me.uk> <4f7eeaa9-47d5-4782-864b-476746654325n@googlegroups.com> <uci8ta$1nj3p$1@dont-email.me> <1872f8f6-4f5a-4059-b717-b40e8b9c5f3cn@googlegroups.com> <ucij2p$1pe53$1@dont-email.me> <ucn7hr$2n64m$1@dont-email.me> <ucnnop$2plof$1@dont-email.me> <ucnqt4$2q4ic$1@dont-email.me> <ucpikj$35rda$1@dont-email.me>
Lines: 23
Message-ID: <qG1IM.472123$xMqa.47393@fx12.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 31 Aug 2023 14:43:34 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 31 Aug 2023 14:43:34 GMT
X-Received-Bytes: 1976
 by: Scott Lurndal - Thu, 31 Aug 2023 14:43 UTC

Muttley@dastardlyhq.com writes:
>On Wed, 30 Aug 2023 18:31:32 +0200
>Bonita Montero <Bonita.Montero@gmail.com> wrote:
>>Am 30.08.2023 um 17:38 schrieb Muttley@dastardlyhq.com:
>>> On Wed, 30 Aug 2023 13:01:16 +0200
>>> Bonita Montero <Bonita.Montero@gmail.com> wrote:
>>>> if( argc < 3 || *argv[2] )
>>>> ofs.exceptions( ofstream::failbit | ofstream::badbit ),
>>>> ofs.open( argc >= 3 ? argv[2] : "primes.txt", ofstream::trunc ),
>>>> printBuf.reserve( BUF_SIZE + 31 );
>>
>>> Commas as statement seperators instead of using a bracketed block?
>>> Are you posting this code for lols?
>>
>>I often concatenate a small number of statements with the comma-operator
>>to save screen space. I never had any issues with that. That's just a
>
>To save space? Seriously??

cfront used to generate extensive comma laden expressions. It did
cause problems with PCC's temporary register allocation algorithms
that I had to fix back around 1989.

Re: Sieve of Eratosthenes

<ucq9pc$3b661$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1243&group=comp.lang.c%2B%2B#1243

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Thu, 31 Aug 2023 16:57:49 +0200
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <ucq9pc$3b661$1@dont-email.me>
References: <ubijff$3ahf3$1@dont-email.me>
<ubjrqh$3g7ve$1@redfloyd.dont-email.me> <86msyq5rqu.fsf@linuxsc.com>
<56146f63-17d7-40cc-8c42-4f29c922a8c4n@googlegroups.com>
<874jkknizq.fsf@bsb.me.uk>
<4f7eeaa9-47d5-4782-864b-476746654325n@googlegroups.com>
<uci8ta$1nj3p$1@dont-email.me>
<1872f8f6-4f5a-4059-b717-b40e8b9c5f3cn@googlegroups.com>
<ucij2p$1pe53$1@dont-email.me> <ucn7hr$2n64m$1@dont-email.me>
<ucnnop$2plof$1@dont-email.me> <ucnqt4$2q4ic$1@dont-email.me>
<ucpikj$35rda$1@dont-email.me> <qG1IM.472123$xMqa.47393@fx12.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 31 Aug 2023 14:57:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ff70a7335e595a5f320387c3a69d8d92";
logging-data="3512513"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX194JcK46LiQA3Zj1m3nhD8cNpRD5ic8f0M="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:x32oWROAOc5bBMvzjga2sT7cevQ=
In-Reply-To: <qG1IM.472123$xMqa.47393@fx12.iad>
Content-Language: de-DE
 by: Bonita Montero - Thu, 31 Aug 2023 14:57 UTC

Am 31.08.2023 um 16:43 schrieb Scott Lurndal:

> cfront used to generate extensive comma laden expressions. It did
> cause problems with PCC's temporary register allocation algorithms
> that I had to fix back around 1989.

There's for sure no compiler that generates different code whether
you youse individual ;-separated statements or one comma-separated
statement as both are sequence points.

Re: Sieve of Eratosthenes

<ucqb70$3beeo$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1244&group=comp.lang.c%2B%2B#1244

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Mutt...@dastardlyhq.com
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Thu, 31 Aug 2023 15:22:08 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <ucqb70$3beeo$1@dont-email.me>
References: <ubijff$3ahf3$1@dont-email.me> <ubjedg$3emtj$1@dont-email.me>
<ubjrqh$3g7ve$1@redfloyd.dont-email.me> <86msyq5rqu.fsf@linuxsc.com>
<56146f63-17d7-40cc-8c42-4f29c922a8c4n@googlegroups.com>
<874jkknizq.fsf@bsb.me.uk>
<4f7eeaa9-47d5-4782-864b-476746654325n@googlegroups.com>
<uci8ta$1nj3p$1@dont-email.me>
<1872f8f6-4f5a-4059-b717-b40e8b9c5f3cn@googlegroups.com>
<ucij2p$1pe53$1@dont-email.me> <ucn7hr$2n64m$1@dont-email.me>
<ucnnop$2plof$1@dont-email.me> <ucnqt4$2q4ic$1@dont-email.me>
<ucpikj$35rda$1@dont-email.me>
<ucpns9$36iap$1@dont-email.me>
Injection-Date: Thu, 31 Aug 2023 15:22:08 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d86a6a0bd34e9d7e70ab89a57df72b62";
logging-data="3520984"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18L09jofkcy7b9OPvGTB/YZ"
Cancel-Lock: sha1:o4rH9JTBovdneqQ635P0JLn2Vps=
 by: Mutt...@dastardlyhq.com - Thu, 31 Aug 2023 15:22 UTC

On Thu, 31 Aug 2023 11:52:09 +0200
Bonita Montero <Bonita.Montero@gmail.com> wrote:
>Am 31.08.2023 um 10:22 schrieb Muttley@dastardlyhq.com:
>
>> Yes, we know how wonderful your code is after you seem to spend multiple days
>
>> on some trivial task. Obviously no one else could ever manage what you did,
>> you're a coding god.
>
>I just benchmarked my code with an upper bound of 1E3 against your code
>on a Skylake CPU with g++ 12 and -march=native. My code runs about 0.9s,
>your code takes 5.26s. Any questions ?

Yes , do you have a life? My code took about 20 mins to write , you seem to
have been working on yours for over a week now.

Re: Sieve of Eratosthenes

<ucqb8u$3ben2$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1245&group=comp.lang.c%2B%2B#1245

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Mutt...@dastardlyhq.com
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Thu, 31 Aug 2023 15:23:10 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <ucqb8u$3ben2$1@dont-email.me>
References: <ubijff$3ahf3$1@dont-email.me> <ubjedg$3emtj$1@dont-email.me>
<ubjrqh$3g7ve$1@redfloyd.dont-email.me> <86msyq5rqu.fsf@linuxsc.com>
<56146f63-17d7-40cc-8c42-4f29c922a8c4n@googlegroups.com>
<874jkknizq.fsf@bsb.me.uk>
<4f7eeaa9-47d5-4782-864b-476746654325n@googlegroups.com>
<uci8ta$1nj3p$1@dont-email.me>
<1872f8f6-4f5a-4059-b717-b40e8b9c5f3cn@googlegroups.com>
<ucij2p$1pe53$1@dont-email.me> <ucn7hr$2n64m$1@dont-email.me>
<ucnnop$2plof$1@dont-email.me> <ucnqt4$2q4ic$1@dont-email.me>
<ucpikj$35rda$1@dont-email.me>
<ucpkqm$364pb$1@dont-email.me>
Injection-Date: Thu, 31 Aug 2023 15:23:10 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d86a6a0bd34e9d7e70ab89a57df72b62";
logging-data="3521250"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+udCawWdlSo5Tv5km2r9IE"
Cancel-Lock: sha1:8yjWewI5wAumdd1rNAJPY4w6F+k=
 by: Mutt...@dastardlyhq.com - Thu, 31 Aug 2023 15:23 UTC

On Thu, 31 Aug 2023 11:00:06 +0200
Bonita Montero <Bonita.Montero@gmail.com> wrote:
>Am 31.08.2023 um 10:22 schrieb Muttley@dastardlyhq.com:
>
>> To save space? Seriously??
>
>It's my taste.
>
>> Its not just personal taste, it makes the code harder to parse for anyone
>> who has to maintain ...
>
>Not true, you just feel unsecure with that for whaterver reason.

You sound like the python devs who claim there's no problem with significant
whitespace with indentation.

Re: Sieve of Eratosthenes

<ucqbdv$3bfgc$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1246&group=comp.lang.c%2B%2B#1246

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Mutt...@dastardlyhq.com
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Thu, 31 Aug 2023 15:25:51 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <ucqbdv$3bfgc$1@dont-email.me>
References: <ubijff$3ahf3$1@dont-email.me> <ubjrqh$3g7ve$1@redfloyd.dont-email.me> <86msyq5rqu.fsf@linuxsc.com> <56146f63-17d7-40cc-8c42-4f29c922a8c4n@googlegroups.com> <874jkknizq.fsf@bsb.me.uk> <4f7eeaa9-47d5-4782-864b-476746654325n@googlegroups.com> <uci8ta$1nj3p$1@dont-email.me> <1872f8f6-4f5a-4059-b717-b40e8b9c5f3cn@googlegroups.com> <ucij2p$1pe53$1@dont-email.me> <ucn7hr$2n64m$1@dont-email.me> <ucnnop$2plof$1@dont-email.me> <ucnqt4$2q4ic$1@dont-email.me> <ucpikj$35rda$1@dont-email.me>
<qG1IM.472123$xMqa.47393@fx12.iad>
Injection-Date: Thu, 31 Aug 2023 15:25:51 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d86a6a0bd34e9d7e70ab89a57df72b62";
logging-data="3522060"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/yDT7xJBIMZG3VKHBYmDeQ"
Cancel-Lock: sha1:PUrsp8aww27NDFiF3IIhJP5gLgo=
 by: Mutt...@dastardlyhq.com - Thu, 31 Aug 2023 15:25 UTC

On Thu, 31 Aug 2023 14:43:34 GMT
scott@slp53.sl.home (Scott Lurndal) wrote:
>Muttley@dastardlyhq.com writes:
>>On Wed, 30 Aug 2023 18:31:32 +0200
>>Bonita Montero <Bonita.Montero@gmail.com> wrote:
>>>Am 30.08.2023 um 17:38 schrieb Muttley@dastardlyhq.com:
>>>> On Wed, 30 Aug 2023 13:01:16 +0200
>>>> Bonita Montero <Bonita.Montero@gmail.com> wrote:
>>>>> if( argc < 3 || *argv[2] )
>>>>> ofs.exceptions( ofstream::failbit | ofstream::badbit ),
>>>>> ofs.open( argc >= 3 ? argv[2] : "primes.txt", ofstream::trunc ),
>>>>> printBuf.reserve( BUF_SIZE + 31 );
>>>
>>>> Commas as statement seperators instead of using a bracketed block?
>>>> Are you posting this code for lols?
>>>
>>>I often concatenate a small number of statements with the comma-operator
>>>to save screen space. I never had any issues with that. That's just a
>>
>>To save space? Seriously??
>
>cfront used to generate extensive comma laden expressions. It did

I don't even understand why C/C++ allows comma seperation of calls in a block.
It should be restricted to a few specific locations such as inside for().

Re: Sieve of Eratosthenes

<ucqbjq$3bg6h$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1247&group=comp.lang.c%2B%2B#1247

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Thu, 31 Aug 2023 17:28:59 +0200
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <ucqbjq$3bg6h$1@dont-email.me>
References: <ubijff$3ahf3$1@dont-email.me> <ubjedg$3emtj$1@dont-email.me>
<ubjrqh$3g7ve$1@redfloyd.dont-email.me> <86msyq5rqu.fsf@linuxsc.com>
<56146f63-17d7-40cc-8c42-4f29c922a8c4n@googlegroups.com>
<874jkknizq.fsf@bsb.me.uk>
<4f7eeaa9-47d5-4782-864b-476746654325n@googlegroups.com>
<uci8ta$1nj3p$1@dont-email.me>
<1872f8f6-4f5a-4059-b717-b40e8b9c5f3cn@googlegroups.com>
<ucij2p$1pe53$1@dont-email.me> <ucn7hr$2n64m$1@dont-email.me>
<ucnnop$2plof$1@dont-email.me> <ucnqt4$2q4ic$1@dont-email.me>
<ucpikj$35rda$1@dont-email.me> <ucpkqm$364pb$1@dont-email.me>
<ucqb8u$3ben2$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 31 Aug 2023 15:28:58 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ff70a7335e595a5f320387c3a69d8d92";
logging-data="3522769"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/NP6aetxWPbfduy2Irefb9DXH8sHMA12U="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:IM2Q/pZNhj7m8Ve2SBna5qlYseY=
In-Reply-To: <ucqb8u$3ben2$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Thu, 31 Aug 2023 15:28 UTC

Am 31.08.2023 um 17:23 schrieb Muttley@dastardlyhq.com:

> You sound like the python devs who claim there's no problem with significant
> whitespace with indentation.

You're too compulsive for that world.

Re: Sieve of Eratosthenes

<ucqbpu$3bg6h$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1248&group=comp.lang.c%2B%2B#1248

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Sieve of Eratosthenes
Date: Thu, 31 Aug 2023 17:32:15 +0200
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <ucqbpu$3bg6h$2@dont-email.me>
References: <ubijff$3ahf3$1@dont-email.me> <ubjedg$3emtj$1@dont-email.me>
<ubjrqh$3g7ve$1@redfloyd.dont-email.me> <86msyq5rqu.fsf@linuxsc.com>
<56146f63-17d7-40cc-8c42-4f29c922a8c4n@googlegroups.com>
<874jkknizq.fsf@bsb.me.uk>
<4f7eeaa9-47d5-4782-864b-476746654325n@googlegroups.com>
<uci8ta$1nj3p$1@dont-email.me>
<1872f8f6-4f5a-4059-b717-b40e8b9c5f3cn@googlegroups.com>
<ucij2p$1pe53$1@dont-email.me> <ucn7hr$2n64m$1@dont-email.me>
<ucnnop$2plof$1@dont-email.me> <ucnqt4$2q4ic$1@dont-email.me>
<ucpikj$35rda$1@dont-email.me> <ucpns9$36iap$1@dont-email.me>
<ucqb70$3beeo$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 31 Aug 2023 15:32:14 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ff70a7335e595a5f320387c3a69d8d92";
logging-data="3522769"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19OcaPTP3cXZO7xePgtJkQsF8UewqyZ3G0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:qSQ/BJ9Mv/G6CXyMXsnxzb8zHdA=
In-Reply-To: <ucqb70$3beeo$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Thu, 31 Aug 2023 15:32 UTC

Am 31.08.2023 um 17:22 schrieb Muttley@dastardlyhq.com:
> On Thu, 31 Aug 2023 11:52:09 +0200
> Bonita Montero <Bonita.Montero@gmail.com> wrote:
>> Am 31.08.2023 um 10:22 schrieb Muttley@dastardlyhq.com:
>>
>>> Yes, we know how wonderful your code is after you seem to spend multiple days
>>
>>> on some trivial task. Obviously no one else could ever manage what you did,
>>> you're a coding god.
>>
>> I just benchmarked my code with an upper bound of 1E3 against your code
>> on a Skylake CPU with g++ 12 and -march=native. My code runs about 0.9s,
>> your code takes 5.26s. Any questions ?
>
> Yes , do you have a life? My code took about 20 mins to write , you seem to
> have been working on yours for over a week now.

You complained about my code and I explained why it was more complex.
You probably have nothing more to say about that. With the questions
you usually ask about C++, I assume that you would not be able to
write such secure and performance code.
Writing performant code is part of my job. I write software for high
frequency trading, so you have to think about which constructs result
in which code and how efficient it is.


devel / comp.lang.c++ / Re: Sieve of Eratosthenes

Pages:123456
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor