From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Not good for Ada endorsement
Date: Thu, 8 Jul 2021 12:42:25 +0200 [thread overview]
Message-ID: <sc6kqh$1sj$1@dont-email.me> (raw)
In-Reply-To: <sc6cgh$9vu$1@dont-email.me>
On 7/8/21 10:20 AM, Jeffrey R. Carter wrote:
>
> Compiling with -gnatp -O3 would undoubtedly speed it up (suppressing checks is
> justified since execution with checks active shows that no checks fail).
>
> Looking casually at the code, the map could be replaced by a constant, as
> Sieve_Size is hard coded to 1,000,000, and the filling of the map is included in
> the timing. The calculation of the square root of 1,000,000 could be replaced by
> a constant. The array of Boolean could be constrained to 3 .. Sieve_Size. The
> function that simply returns (others => True) could be replaced by the
> aggregate, though optimization will probably do that. Long_Long_Integer could be
> replaced by a type with range 0 .. 2 ** 31 - 1, though I don't know if that
> would have any effect. The first inner loop in the sieve algorithm could be
> eliminated, in which case the initialization of Num could also be removed.
Compiling the original code with
gnatmake prime_sieve.adb
gives 408 passes in 5 seconds.
Making the changes listed above (I used Interfaces.Integer_32) and compiling with
gnatmake -O3 prime_sieve.adb
(to ensure that no checks fail) gives 2087 passes in 5 seconds, for a factor of 5.1.
Applying that to the reported 67 passes/second for the original on the test
system implies that this version, compiled with checks enabled and optimization,
would give 343 passes/second.
--
Jeff Carter
"My legs are gray, my ears are gnarled, my eyes are old and bent."
Monty Python's Life of Brian
81
next prev parent reply other threads:[~2021-07-08 10:42 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-07 14:21 Not good for Ada endorsement Richard Iswara
2021-07-07 15:06 ` Luke A. Guest
2021-07-07 15:19 ` Doctor Who
2021-07-07 19:21 ` Simon Wright
2021-07-07 19:49 ` Doctor Who
2021-07-07 20:39 ` Luke A. Guest
2021-07-08 3:46 ` Richard Iswara
2021-07-08 8:20 ` Jeffrey R. Carter
2021-07-08 8:42 ` Dmitry A. Kazakov
2021-07-08 8:52 ` Luke A. Guest
2021-07-08 10:42 ` Jeffrey R. Carter [this message]
2021-07-08 10:51 ` Luke A. Guest
2021-07-08 11:12 ` Jeffrey R. Carter
2021-07-08 17:37 ` Luke A. Guest
2021-07-08 17:43 ` Luke A. Guest
2021-07-08 19:16 ` Luke A. Guest
2021-07-08 19:16 ` Luke A. Guest
2021-07-09 2:47 ` Richard Iswara
2021-07-09 8:10 ` Paul Rubin
2021-07-09 8:24 ` Egil H H
2021-07-09 8:33 ` Egil H H
2021-07-09 9:16 ` Jeffrey R. Carter
2021-07-09 9:21 ` Jeffrey R. Carter
2021-07-15 15:13 ` Lucretia
2021-07-15 15:56 ` Jeffrey R. Carter
2021-07-15 16:29 ` Anh Vo
2021-07-15 17:30 ` Lucretia
2021-07-16 16:27 ` Simon Wright
2021-07-16 16:28 ` Simon Wright
2021-07-23 17:55 ` Luke A. Guest
2021-07-23 17:04 ` Anh Vo
2021-07-23 17:12 ` Luke A. Guest
2021-07-15 16:29 ` Lucretia
2021-07-15 16:49 ` Dmitry A. Kazakov
2021-07-15 21:08 ` Jeffrey R. Carter
2021-07-11 15:54 ` Dennis Lee Bieber
2021-07-18 23:03 ` Mace Ayres
2021-07-19 1:00 ` Paul Rubin
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox