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 autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Not good for Ada endorsement Date: Thu, 15 Jul 2021 18:49:07 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <5a1cegtfm5ibqej3ldebpc4g99ujniqt9u@4ax.com> <0e6ee3e9-baad-47b3-872b-90ec6c735920n@googlegroups.com> <59c3fb8e-6866-4ea9-a1a2-21fdff252095n@googlegroups.com> NNTP-Posting-Host: 5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader02.eternal-september.org comp.lang.ada:62394 List-Id: On 2021-07-15 18:29, Lucretia wrote: > On Thursday, 15 July 2021 at 16:56:40 UTC+1, Jeffrey R. Carter wrote: >> On 7/15/21 5:13 PM, Lucretia wrote: >>> >>> I managed to get just under 4000 passes with a 1 bit array, but not using Ada's packed array. That's actually the slowest method, strangely. >> So you have an array of a modular type, calculate an index and bit within it, >> mask out that bit, and compare it to zero? I would have thought an unpacked >> array of Boolean would be fastest. > > Doesn't seem to be. Unlikely unless compiled into machine-specific instructions. You should inspect the code. > Also, the guy is using the packed bit as the final test of all the languages. > >> A packed array of Boolean requires all the operations above, plus shifting the >> bit to the LSB and treating the result as a Boolean, so it may not be that > > Don't need to shift to the LSB, only need to shift the 1 to the bit location you want to test, invert and then check against 0. Usually masks are either tabulated in a look-up table or are constants in a case choice. >> surprising that it's slower. > > I know. I would've thought the compiler would've handled the packed array as a special case and optimised as much as possible there. It is still unlikely to be faster than all arrays. You should probably try to use different element types and inspect the code. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de