From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) 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.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: Quick inverse square root Date: Thu, 7 Jan 2021 17:49:32 -0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <6489a95e-dae1-486e-9aee-78e9d6e50ecan@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 7 Jan 2021 17:49:32 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="338a6547cba25d81a226288193c7b4fa"; logging-data="10413"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18CctYM17JysMuMLQP482FD+FlIeHPvky0=" User-Agent: Pan/0.145 (Duplicitous mercenary valetism; d7e168a git.gnome.org/pan2) Cancel-Lock: sha1:lW524Z5TVPVthQsRpxatFSQcd60= Xref: reader02.eternal-september.org comp.lang.ada:61055 List-Id: On Mon, 04 Jan 2021 12:55:33 -0800, Matt Borchers wrote: > As computers get faster, storage gets larger, and code libraries get > bigger, it is unfortunate that most programmers do not need to be as > clever as they once were required to be. > > Thanks for finding and sharing the PDF paper! I'm amazed someone could > write so many pages on this. Out of curiosity, I need to compare my > computed magic number with theirs from their 64-bit float example. Having spent quite some time elsewhere getting sqrt down to a single clock cycle (throughput : 8 cycle latency) it doesn't surprise me at all. (The name Terje Mathisen comes to mind for assembly language implementations) The odd coding (non use of union, strange use of intermediate variables) may well have been the result of compiler code generation limitations; the "better" form may have compiled to a few more instructions or run a little more slowly; not a good thing for a gamer on limited hardware! Have you benchmarked the pretty Ada version against the original C ... or against a straightforward float operation on modern hardware? -- Brian