From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9c86eb13dd395066 X-Google-Attributes: gid103376,public From: geert@fozzie.sun3.iaf.nl (Geert Bosch) Subject: Re: CRC in Ada? Date: 1997/03/09 Message-ID: <5fub2s$8k@fozzie.sun3.iaf.nl>#1/1 X-Deja-AN: 224162055 References: <1997Mar2.220652@nova.wright.edu> <1997Mar5.131846.1@eisner> <5fmo1k$adm@mulga.cs.mu.OZ.AU> <1997Mar6.114441.1@eisner> <1997Mar7.090814.1@eisner> <33206340.2616@bix.com> <1997Mar7.202252.1@eisner> Organization: La Calandre Infortunee Newsgroups: comp.lang.ada Date: 1997-03-09T00:00:00+00:00 List-Id: Robert Dewar (dewar@merv.cs.nyu.edu) wrote: Another interesting case of this is a timing comparison that Bob Klungle sent me comparing the use of the official log and the log in the "secret" package Aux. The log in Aux is a direct call to C, the log in Ada has rather different semantics, as you can see from its coding: But what surprises me is that in cases where the argument is *known* to be larger than 1.0 the checks are still being made. Normally I would use a subtype Positive_Float for values which should be positive in a calculation. This will give a good compiler the opportunity to omit the extra comparisons in the Ada code. Sadly enough GNAT is not (yet) such a good compiler in this respect. In fact GNAT should be able to generate faster code for invocations of the log function for such arguments, since it can inline the function to *only* contain the log instruction. There are many real-world examples where optimizations like these can make a difference of a factor 3 and more, so I guess these optimizations satisfy Robert Dewars criterea. Also the requirement to return 0.0 when the argument is 1.0 doesn't need to generate extra code, since the check could be changed in Accurate_Log_1 and then X = 1.0, and the boolean value Accurate_Log_1 can be determined at compile time. (To be honest, this might not be possible for platforms where the program may run on different numeric processors. In this case the check must be done at elaboration time which leaves in the boolean check.) Regards, Geert