From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:a05:622a:34c:: with SMTP id r12mr32589581qtw.196.1625819639453; Fri, 09 Jul 2021 01:33:59 -0700 (PDT) X-Received: by 2002:a25:6b0c:: with SMTP id g12mr40801144ybc.303.1625819639232; Fri, 09 Jul 2021 01:33:59 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!news.mixmin.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 9 Jul 2021 01:33:59 -0700 (PDT) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=89.8.153.148; posting-account=uulyKwoAAAA86DO0ODu--rZtbje8Sytn NNTP-Posting-Host: 89.8.153.148 References: <5a1cegtfm5ibqej3ldebpc4g99ujniqt9u@4ax.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Not good for Ada endorsement From: Egil H H Injection-Date: Fri, 09 Jul 2021 08:33:59 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:62364 List-Id: On Thursday, July 8, 2021 at 7:38:19 PM UTC+2, Luke A. Guest wrote: > On 08/07/2021 12:12, Jeffrey R. Carter wrote: > > >> He also uses clang's -Ofast option to compile for speed over size. > > > > Going back to 64-bit integers gives 1999; with -gnatp, 2098 > > > I've uploaded my version here > https://github.com/Lucretia/Primes/tree/add-optimised-ada/PrimeAda/solution_2 > > It's as straight a conversion from the C++ to Ada. I intend to keep > optimising it. On my computer, at least, GNAT is not happy about incrementing Number by 2 in the inner loop. I get a bit better performance by modifying the check to if Number mod 2 /= 0 and then Sieve.Bits(Index_Type(Number)) then and then incrementing Number by 1. Or even rewriting to a for-loop Is_Prime : for Foo in Index_Type (Factor)..Sieve.Size loop if Foo mod 2 /= 0 and then Sieve.Bits (Foo) then Factor := Integer(Foo); exit Is_Prime; end if; end loop Is_Prime;