floating point precision with -O2 optimization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello

When I compile my program with -O0 and with -O2 I have two different comportement

here the output of the program with -O0

PseudoAxesEngine : "eulerians" eulerians
     "solution" : 1.0000000 [0.0000000 : 1.0000000]

     "omega" : -180.0000000 ° [-180.0000000 : 180.0000000] 0x8e6c9d8
     "chi" : -90.0000000 ° [-180.0000000 : 180.0000000] 0x8e6c9d8
     "phi" : 180.0000000 ° [-180.0000000 : 180.0000000] 0x8e6c9d8
   multiply method: 0x400319e8 
                     mu             komega              kappa               kphi              gamma              delta
0 :  0.000000000000000 °  32.954835326713123 °  134.755927383623572 ° -147.045164673286877 °  0.000000000000000 °  0.000000000000000 °
     0.000000000000000 °  32.954835326713123 °  134.755927383623572 ° -147.045164673286877 °  0.000000000000000 °  0.000000000000000 °

1 :  0.000000000000000 ° -32.954835326713123 ° -134.755927383623572 °  147.045164673286877 °  0.000000000000000 °  0.000000000000000 °
     0.000000000000000 ° -32.954835326713123 ° -134.755927383623572 °  147.045164673286877 °  0.000000000000000 °  0.000000000000000 °


PseudoAxesEngine : "eulerians" eulerians
     "solution" : 1.0000000 [0.0000000 : 1.0000000]

     "omega" : 0.0000000 ° [-180.0000000 : 180.0000000] 0x8e6c9d8
     "chi" : 90.0000000 ° [-180.0000000 : 180.0000000] 0x8e6c9d8
     "phi" : 0.0000000 ° [-180.0000000 : 180.0000000] 0x8e6c9d8
   multiply method: 0x400319e8 
                     mu             komega              kappa               kphi              gamma              delta
0 :  0.000000000000000 °  32.954835326713123 °  134.755927383623572 ° -147.045164673286877 °  0.000000000000000 °  0.000000000000000 °
     0.000000000000000 °  32.954835326713123 °  134.755927383623572 ° -147.045164673286877 °  0.000000000000000 °  0.000000000000000 °

1 :  0.000000000000000 ° -32.954835326713123 ° -134.755927383623572 °  147.045164673286877 °  0.000000000000000 °  0.000000000000000 °
     0.000000000000000 ° -32.954835326713123 ° -134.755927383623572 °  147.045164673286877 °  0.000000000000000 °  0.000000000000000 °


now with -O2

PseudoAxesEngine : "eulerians" eulerians
     "solution" : 1.0000000 [0.0000000 : 1.0000000]

     "omega" : 0.0000000 ° [-180.0000000 : 180.0000000] 0x951d768
     "chi" : 90.0000000 ° [-180.0000000 : 180.0000000] 0x951d768
     "phi" : 0.0000000 ° [-180.0000000 : 180.0000000] 0x951d768
   multiply method: 0x4002fbe0 
                     mu             komega              kappa               kphi              gamma              delta
0 :  0.000000000000000 ° -32.954835326713116 ° -134.755927383623572 °  147.045164673286877 °  0.000000000000000 °  0.000000000000000 °
     0.000000000000000 ° -32.954835326713116 ° -134.755927383623572 °  147.045164673286877 °  0.000000000000000 °  0.000000000000000 °

1 :  0.000000000000000 °  32.954835326713123 °  134.755927383623572 ° -147.045164673286877 °  0.000000000000000 °  0.000000000000000 °
     0.000000000000000 °  32.954835326713123 °  134.755927383623572 ° -147.045164673286877 °  0.000000000000000 °  0.000000000000000 °


PseudoAxesEngine : "eulerians" eulerians
     "solution" : 1.0000000 [0.0000000 : 1.0000000]

     "omega" : -180.0000000 ° [-180.0000000 : 180.0000000] 0x951d768
     "chi" : -90.0000000 ° [-180.0000000 : 180.0000000] 0x951d768
     "phi" : 180.0000000 ° [-180.0000000 : 180.0000000] 0x951d768
   multiply method: 0x4002fbe0 
                     mu             komega              kappa               kphi              gamma              delta
0 :  0.000000000000000 ° -32.954835326713116 ° -134.755927383623572 °  147.045164673286877 °  0.000000000000000 °  0.000000000000000 °
     0.000000000000000 ° -32.954835326713116 ° -134.755927383623572 °  147.045164673286877 °  0.000000000000000 °  0.000000000000000 °

1 :  0.000000000000000 °  32.954835326713123 °  134.755927383623572 ° -147.045164673286877 °  0.000000000000000 °  0.000000000000000 °
     0.000000000000000 °  32.954835326713123 °  134.755927383623572 ° -147.045164673286877 °  0.000000000000000 °  0.000000000000000 °


As you can see it looks like it is similar except for values of komega.

-O0 32.954835326713123 / -32.954835326713123 (symetric ok)
-O2 32.954835326713123 / -32.954835326713116 (not symetric ko ?)

So first my question is: is it normal to have different numerical computation in O2 vs O0 ?

thanks

Frederic


PS: I am using

gcc (Debian 4.3.4-6) 4.3.4
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

on this processor

processor       : 0
vendor_id       : GenuineIntel
cpu family      : 15
model           : 4
model name      : Intel(R) Pentium(R) 4 CPU 3.20GHz
stepping        : 1
cpu MHz         : 3191.950
cache size      : 1024 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 1
apicid          : 0
initial apicid  : 0
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 5
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx constant_tsc pebs bts pni dtes64 monitor ds_cpl cid xtpr
bogomips        : 6383.90
clflush size    : 64
power management:

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 15
model           : 4
model name      : Intel(R) Pentium(R) 4 CPU 3.20GHz
stepping        : 1
cpu MHz         : 3191.950
cache size      : 1024 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 1
apicid          : 1
initial apicid  : 1
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 5
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx constant_tsc pebs bts pni dtes64 monitor ds_cpl cid xtpr
bogomips        : 6384.02
clflush size    : 64
power management:

-- 
GPG public key   1024D/A59B1171 2009-08-11
    fingerprint = 1688 A3D6 F0BD E4DF 2E6B  06AA B6A9 BA6A A59B 1171
uid  Picca Frédéric-Emmanuel <picca@xxxxxxxxxxxxxxxxxxxxx>

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux