OT: Re: A very slow program
Vir Campestris <[email protected]> Thu, 3 Oct 2024 17:06:13 +0100
| Newsgroups | alt.comp.lang.c,comp.lang.c |
|---|---|
| Organization | A noiseless patient Spider |
| Message-ID | <[email protected]> |
On 02/10/2024 13:44, Bonita Montero wrote: > Ive developed a Sieve of Erastosthenes in C++20 with an unbeaten > performance. With this code I get all primes <= 2 ^ 32 in 140ms > on my AMD 7950X 16-core Zen4-system. > It calculates first only the primes up to the square root of the > maximum. The remaining bits are partitioned according to the num- > ber of CPU-cores. Within each thread the bitmap is partitioned in > parts that fit into the L2-cache (queried via CPUID). > All operations are aligned on a cacheline-boundary to avoid false > sharing and locking of shared words. Unbeaten? This isn't the same program you posted before over on comp.lang.c++, but it builds and runs fine on my machine. for 4e9 primes my machine take nearly 10 seconds for 4294967295 primes. The one I posted before over there takes 1.5 seconds. This version is if anything slightly slower than your other one. You might like to have a look. (And Keith, yes, I realise there is no point whatsoever in doing this... but it's been fun. First time in years I've written anything I'm not getting paid for!) Andy