Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.arch.embedded > #20077

Re: two fpu compared

From al.basili@gmail.com (alb)
Newsgroups comp.arch.embedded
Subject Re: two fpu compared
Date 2015-02-13 14:14 +0000
Message-ID <ck6f5eF66ovU1@mid.individual.net> (permalink)
References <ck36l8Fak5nU1@mid.individual.net> <mbht2f$v21$1@dont-email.me>

Show all headers | View raw


Hi David,

David Brown <david.brown@hesbynett.no> wrote:
[]
>> assuming two differently implemented FPU, both validated against the 
>> IEEE754, and limiting operations to the golden 5 (+,-, *, /, sqr), can I 
>> be sure that provided the inputs operands are the same the result would 
>> be the same bit wise?
[]
> 
> It is normal to view floating point operations as slightly imprecise -
> there is a rule that you never compare floating point data with ==.
> Even if you are careful to have the same precision and rounding in the
> calculations, there may be other factors - for at least some operations,
> I believe there can be different results from two IEEE754 compatible
> implementations.

the extra bit I got recently is that the result is converted to an 
integer of 11bit which, a priori, means that a lot of the low bit 
precision from the 32bit is anyhow lost.

Indeed I could calculate what the integer LSB corresponds to in terms of 
floating point representation and be more confident on the comparison 
(i.e. if floating point results are not bitwise equal does not necessary 
mean the integer result is going to be different).

> More importantly, however, is that normally you don't want full IEEE754
> compliance - the overhead is too much.  Typically, FPU hardware does not
> provide full support - you need to have extra software handling as well.

AFAIK the implementation we have is 'full IEEE754' and floating points 
operations are using directly the hardware (unless gcc is configured 
otherwise).

> In some aspects, non-compliant code can be significantly more
> efficient.  For example, with "-ffast-math" in gcc, the compiler can
> turn "x = y + z - y" into "x = z", while in compliant mode it has to do
> the full calculation as stated, even though it is slower and gives less
> accurate results.  And for square root, some FPU's may have a fast
> "approximate square root" function that is good enough and much faster.

I see your point, this is certainly an extra bit of info since our 
harwdare is not that performing either and a soft implementation might 
actually be faster.

> The only way to be really sure of bit-accurate results is to use the
> same software floating point library on each system.  But since the
> "golden model" here is a system that you have no control of (matlab plus
> external libraries - and different "standard PC's" can have different
> details in their FPU's), it is basically impossible to guarantee
> bit-accurate copies of the results.

Still can be a viable approach if the result is converted to integer 
with a much lower precision. It is a bet though, since we cannot be 
absolutely sure that it would be the case.

Al

Back to comp.arch.embedded | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

two fpu compared al.basili@gmail.com (alb) - 2015-02-12 08:30 +0000
  Re: two fpu compared David Brown <david.brown@hesbynett.no> - 2015-02-12 10:51 +0100
    Re: two fpu compared al.basili@gmail.com (alb) - 2015-02-13 14:14 +0000
      Re: two fpu compared David Brown <david.brown@hesbynett.no> - 2015-02-13 16:23 +0100
        Re: two fpu compared Colin Paul de Gloucester <not_a_real_email@address.com> - 2015-02-13 17:37 +0100
          Re: two fpu compared al.basili@gmail.com (alb) - 2015-02-16 08:01 +0000
            Re: two fpu compared Colin Paul de Gloucester <not_a_real_email@address.com> - 2015-02-16 11:43 +0100
              Re: two fpu compared al.basili@gmail.com (alb) - 2015-02-17 10:35 +0000
                Re: two fpu compared David Brown <david.brown@hesbynett.no> - 2015-02-17 12:18 +0100
                Re: two fpu compared George Neuner <gneuner2@comcast.net> - 2015-02-17 09:26 -0500
                Re: two fpu compared David Brown <david.brown@hesbynett.no> - 2015-02-17 16:47 +0100
                Re: two fpu compared Dimiter_Popoff <dp@tgi-sci.com> - 2015-02-17 20:54 +0200
        Re: two fpu compared al.basili@gmail.com (alb) - 2015-02-16 07:58 +0000
          Re: two fpu compared David Brown <david.brown@hesbynett.no> - 2015-02-16 09:53 +0100
            Re: two fpu compared al.basili@gmail.com (alb) - 2015-02-16 09:47 +0000
              Re: two fpu compared Richard Damon <Richard@Damon-Family.org> - 2015-02-16 08:27 -0500
        Re: two fpu compared Nobody <nobody@nowhere.invalid> - 2015-02-23 00:13 +0000
      Re: two fpu compared George Neuner <gneuner2@comcast.net> - 2015-02-13 18:43 -0500
      Re: two fpu compared glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-02-14 15:30 +0000
        Re: two fpu compared Dimiter_Popoff <dp@tgi-sci.com> - 2015-02-14 23:19 +0200
          Re: two fpu compared Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2015-02-14 23:28 +0100
          Re: two fpu compared glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-02-15 14:33 +0000
            Re: two fpu compared Dimiter_Popoff <dp@tgi-sci.com> - 2015-02-17 20:53 +0200
              Re: two fpu compared glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-02-18 01:55 +0000
                Re: two fpu compared Dimiter_Popoff <dp@tgi-sci.com> - 2015-02-18 17:54 +0200
                Re: two fpu compared glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-02-18 16:52 +0000
                Re: two fpu compared Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2015-02-18 18:12 +0100
                Re: two fpu compared Robert Wessel <robertwessel2@yahoo.com> - 2015-02-18 18:02 -0600
                Re: two fpu compared Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2015-02-19 09:42 +0200
                Re: two fpu compared Robert Wessel <robertwessel2@yahoo.com> - 2015-02-19 11:04 -0600
                Re: two fpu compared Reinhardt Behm <rbehm@hushmail.com> - 2015-02-19 23:26 +0800
                Re: two fpu compared Dimiter_Popoff <dp@tgi-sci.com> - 2015-02-18 19:18 +0200
                Re: two fpu compared Dimiter_Popoff <dp@tgi-sci.com> - 2015-02-19 02:28 +0200
                Re: two fpu compared glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-02-19 16:29 +0000
                Re: two fpu compared Dimiter_Popoff <dp@tgi-sci.com> - 2015-02-21 16:07 +0200
  Re: two fpu compared glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-02-12 11:26 +0000
  Re: two fpu compared "Boudewijn Dijkstra" <sp4mtr4p.boudewijn@indes.com> - 2015-02-12 12:29 +0100
  Re: two fpu compared Dennis <dennis@none.none> - 2015-02-12 09:45 -0600

csiph-web