public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* gcc bug: different results between -O0 and -O1
@ 2001-11-01  9:02 gilles civario
  2001-11-01  9:31 ` egor duda
  2001-11-11  8:26 ` gilles civario
  0 siblings, 2 replies; 10+ messages in thread
From: gilles civario @ 2001-11-01  9:02 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 601 bytes --]

Hello.

Wile developing a performance test program for gettimeofday resolution,
I found a strange behavior for gcc under cygwin with the -O flags.
Everywhere else with native compiler or with gcc, the program return constant
results, with or without optimization. (On Sun, Dec, Linux and Fujitsu)
Only with cygwin, the result is divided by 5000 from -O0 to -O1, both with
gcc version 2.95.3-5 (cygwin special) and gcc version 3.0.2.
But it shouldn't. Ok for a little increase, but not for 5000 !

To test the program, use the makefile and execute both bug0.exe and bug1.exe.

Regards.

Gilles Civario.

[-- Attachment #2: cygcheck.out --]
[-- Type: text/plain, Size: 13682 bytes --]


Cygnus Win95/NT Configuration Diagnostics
Current System Time: Mon Nov 12 11:09:36 2001

WinNT Ver 4.0 build 1381 Service Pack 5

Path:	.
	D:\cygwin\bin
	D:\cygwin\bin
	c:\Program Files\Microsoft Visual Studio\Common\Tools
	c:\Program Files\Microsoft Visual Studio\Common\Msdev98\BIN
	c:\Program Files\Microsoft Visual Studio\DF98\BIN
	c:\Program Files\Microsoft Visual Studio\VC98\BIN
	c:\WINNT\system32
	c:\WINNT
	c:\IWSAAAPI
	d:\util\Python21
	d:\util\Python21\DLLs
	c:\Program Files\MiKTeX\miktex\bin
	.
	D:\cygwin\bin
	D:\cygwin\bin
	D:\cygwin\usr\local\bin
	c:\ispell\bin
	D:\cygwin\usr\X11R6\bin
	D:\cygwin\usr\local\grace\bin

SysDir: C:\WINNT\System32
WinDir: C:\WINNT

HOME = `d:\gilles'
MAKE_MODE = `unix'
PWD = `/cygdrive/d/gilles/tmp'
USER = `gilles'

CLASSPATH = `C:\Program Files\Exceed.nt\hcljrcsv.jar;C:\Program Files\Exceed.nt\;'
COMPUTERNAME = `GLENANS'
COMSPEC = `C:\WINNT\system32\cmd.exe'
CPU = `i386'
DISPLAY = `127.0.0.1:0'
DISTINCTPATH = `C:\PROGRA~1\Distinct;C:\PROGRA~1\COMMON~1\DISTIN~1'
GRACE_HOME = `/usr/local/grace'
HOMEDRIVE = `C:'
HOMEPATH = `\'
HOSTNAME = `GLENANS'
HOSTTYPE = `i686'
INCLUDE = `C:\Program Files\Microsoft Visual Studio\DF98\IMSL\INCLUDE;C:\Program Files\Microsoft Visual Studio\DF98\INCLUDE;C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE'
LIB = `C:\Program Files\Microsoft Visual Studio\DF98\IMSL\LIB;C:\Program Files\Microsoft Visual Studio\DF98\LIB;C:\Program Files\Microsoft Visual Studio\VC98\LIB'
LINK_F90 = `sstatd.lib sstats.lib smathd.lib smaths.lib sf90mp.lib'
LOGONSERVER = `\\GLENANS'
LS_COLORS = `no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:'
MACHTYPE = `i686-pc-cygwin'
MANPAGER = `/usr/bin/less -isFX'
MANPATH = `:/usr/local/share/man:/usr/X11R6/man'
NUMBER_OF_PROCESSORS = `1'
OLDPWD = `/cygdrive/d/gilles'
OS2LIBPATH = `C:\WINNT\system32\os2\dll;'
OS = `Windows_NT'
OSTYPE = `cygwin'
PATHEXT = `.COM;.EXE;.BAT;.CMD'
PROCESSOR_ARCHITECTURE = `x86'
PROCESSOR_IDENTIFIER = `x86 Family 6 Model 5 Stepping 2, GenuineIntel'
PROCESSOR_LEVEL = `6'
PROCESSOR_REVISION = `0502'
PROMPT = `$P$G'
PS1 = `^[]0;\w\a^[[32m\u@\h ^[[33m\w
^[[35m \! ^[[0m> '
SHELL = `/bin/bash'
SHLVL = `1'
SYSTEMDRIVE = `C:'
SYSTEMROOT = `C:\WINNT'
TEMP = `c:\TEMP'
TERM = `cygwin'
TZ = `GMT-2'
USERDOMAIN = `GLENANS'
USERNAME = `gilles'
USERPROFILE = `C:\WINNT\Profiles\gilles'
VNI_F90_MSG = `C:\Program Files\Microsoft Visual Studio\DF98\IMSL\MESSAGE'
WINDIR = `C:\WINNT'
XKEYSYMDB = `/usr/local/grace/XKeysymDB'
_ = `/usr/bin/cygcheck'

HKEY_CURRENT_USER\Software\Cygnus Solutions
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2
  (default) = `/cygdrive'
  cygdrive flags = 0x00000022
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\Program Options
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/
  (default) = `D:/cygwin'
  flags = 0x0000000a
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/usr/bin
  (default) = `D:/cygwin/bin'
  flags = 0x0000000a
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/usr/lib
  (default) = `D:/cygwin/lib'
  flags = 0x0000000a
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\Program Options

a:  fd           N/A    N/A                    
c:  hd  FAT     2044Mb  94% CP    UN           ABDYN30ABF
d:  hd  FAT     2044Mb  78% CP    UN           VOL_LOG1
e:  cd           N/A    N/A                    

.              /cygdrive  user    binmode,noumount
D:/cygwin      /          system  binmode
D:/cygwin/bin  /usr/bin   system  binmode
D:/cygwin/lib  /usr/lib   system  binmode

Found: D:\cygwin\bin\bash.exe
Found: D:\cygwin\bin\cat.exe
Found: D:\cygwin\bin\cpp.exe
Found: D:\cygwin\usr\local\bin\cpp.exe
Warning: D:\cygwin\bin\cpp.exe hides D:\cygwin\usr\local\bin\cpp.exe
Found: D:\cygwin\bin\find.exe
Found: D:\cygwin\bin\gcc.exe
Found: D:\cygwin\usr\local\bin\gcc.exe
Warning: D:\cygwin\bin\gcc.exe hides D:\cygwin\usr\local\bin\gcc.exe
Found: D:\cygwin\bin\gdb.exe
Found: D:\cygwin\bin\ld.exe
Found: D:\cygwin\bin\ls.exe
Found: D:\cygwin\bin\make.exe
Found: D:\cygwin\bin\sh.exe

   49k 2001/02/03 D:\cygwin\bin\cygz.dll - os=4.0 img=1.0 sys=4.0
                  "cygz.dll" v0.0 ts=2001/2/3 22:35
  163k 2001/05/06 D:\cygwin\bin\cygpng2.dll - os=4.0 img=1.0 sys=4.0
                  "cygpng2.dll" v0.0 ts=2001/5/6 6:05
   18k 2000/10/23 D:\cygwin\bin\cyggdbm.dll - os=4.0 img=1.0 sys=4.0
                  "cyggdbm.dll" v0.0 ts=2000/10/23 4:26
   21k 2001/06/20 D:\cygwin\bin\cygintl.dll - os=4.0 img=1.0 sys=4.0
                  "cygintl.dll" v0.0 ts=2001/6/20 19:09
   45k 2001/07/04 D:\cygwin\bin\cygjbig1.dll - os=4.0 img=1.0 sys=4.0
                  "cygjbig1.dll" v0.0 ts=2001/7/4 5:25
  119k 2001/06/06 D:\cygwin\bin\cygjpeg6b.dll - os=4.0 img=1.0 sys=4.0
                  "cygjpeg6b.dll" v0.0 ts=2001/6/6 6:27
   45k 2001/04/25 D:\cygwin\bin\cygform5.dll - os=4.0 img=1.0 sys=4.0
                  "cygform5.dll" v0.0 ts=2001/4/25 7:28
   26k 2001/04/25 D:\cygwin\bin\cygmenu5.dll - os=4.0 img=1.0 sys=4.0
                  "cygmenu5.dll" v0.0 ts=2001/4/25 7:27
  156k 2001/04/25 D:\cygwin\bin\cygncurses++5.dll - os=4.0 img=1.0 sys=4.0
                  "cygncurses++5.dll" v0.0 ts=2001/4/25 7:29
  226k 2001/04/25 D:\cygwin\bin\cygncurses5.dll - os=4.0 img=1.0 sys=4.0
                  "cygncurses5.dll" v0.0 ts=2001/4/25 7:17
   15k 2001/04/25 D:\cygwin\bin\cygpanel5.dll - os=4.0 img=1.0 sys=4.0
                  "cygpanel5.dll" v0.0 ts=2001/4/25 7:27
   81k 2001/10/20 D:\cygwin\bin\cygitcl30.dll - os=4.0 img=1.0 sys=4.0
                  "cygitcl30.dll" v0.0 ts=2001/10/20 2:25
   35k 2001/10/20 D:\cygwin\bin\cygitk30.dll - os=4.0 img=1.0 sys=4.0
                  "cygitk30.dll" v0.0 ts=2001/10/20 2:25
  245k 2001/06/12 D:\cygwin\bin\cygtiff3.dll - os=4.0 img=1.0 sys=4.0
                  "cygtiff3.dll" v0.0 ts=2001/6/12 19:25
   41k 2001/07/04 D:\cygwin\bin\cygXpm-noX4.dll - os=4.0 img=1.0 sys=4.0
                  "cygXpm-noX4.dll" v0.0 ts=2001/7/4 3:21
   45k 2001/07/04 D:\cygwin\bin\cygXpm-X4.dll - os=4.0 img=1.0 sys=4.0
                  "cygXpm-X4.dll" v0.0 ts=2000/11/20 4:45
  390k 2001/10/20 D:\cygwin\bin\cygtcl80.dll - os=4.0 img=1.0 sys=4.0
                  "cygtcl80.dll" v0.0 ts=2001/10/20 2:24
   56k 2000/12/03 D:\cygwin\bin\cygbz21.0.dll - os=4.0 img=1.0 sys=4.0
                  "cygbz21.0.dll" v0.0 ts=2000/11/21 1:53
    5k 2001/10/20 D:\cygwin\bin\cygtclpip80.dll - os=4.0 img=1.0 sys=4.0
   10k 2001/10/20 D:\cygwin\bin\cygtclreg80.dll - os=4.0 img=1.0 sys=4.0
                  "cygtclreg80.dll" v0.0 ts=2001/10/20 2:24
  623k 2001/10/20 D:\cygwin\bin\cygtk80.dll - os=4.0 img=1.0 sys=4.0
                  "cygtk80.dll" v0.0 ts=2001/10/20 2:25
   34k 2001/09/30 D:\cygwin\bin\cygform6.dll - os=4.0 img=1.0 sys=4.0
                  "cygform6.dll" v0.0 ts=2001/9/30 4:43
   19k 2001/09/30 D:\cygwin\bin\cygmenu6.dll - os=4.0 img=1.0 sys=4.0
                  "cygmenu6.dll" v0.0 ts=2001/9/30 4:43
   17k 2001/06/28 D:\cygwin\bin\cyghistory4.dll - os=4.0 img=1.0 sys=4.0
                  "cyghistory4.dll" v0.0 ts=2001/1/7 6:34
   21k 2001/06/28 D:\cygwin\bin\cyghistory5.dll - os=4.0 img=1.0 sys=4.0
                  "cyghistory5.dll" v0.0 ts=2001/6/28 4:27
  108k 2001/06/28 D:\cygwin\bin\cygreadline4.dll - os=4.0 img=1.0 sys=4.0
                  "cygreadline4.dll" v0.0 ts=2001/1/7 6:34
  135k 2001/06/28 D:\cygwin\bin\cygreadline5.dll - os=4.0 img=1.0 sys=4.0
                  "cygreadline5.dll" v0.0 ts=2001/6/28 4:27
  175k 2001/09/30 D:\cygwin\bin\cygncurses++6.dll - os=4.0 img=1.0 sys=4.0
                  "cygncurses++6.dll" v0.0 ts=2001/9/30 4:45
  201k 2001/09/30 D:\cygwin\bin\cygncurses6.dll - os=4.0 img=1.0 sys=4.0
                  "cygncurses6.dll" v0.0 ts=2001/9/30 4:42
   12k 2001/09/30 D:\cygwin\bin\cygpanel6.dll - os=4.0 img=1.0 sys=4.0
                  "cygpanel6.dll" v0.0 ts=2001/9/30 4:43
  714k 2001/11/12 D:\cygwin\bin\cygwin1.dll - os=4.0 img=1.0 sys=4.0
                  "cygwin1.dll" v0.0 ts=2001/11/12 2:01
    Cygwin DLL version info:
        DLL version: 1.3.5
        DLL epoch: 19
        DLL bad signal mask: 19005
        DLL old termios: 5
        DLL malloc env: 28
        API major: 0
        API minor: 47
        Shared data: 3
        DLL identifier: cygwin1
        Mount registry: 2
        Cygnus registry name: Cygnus Solutions
        Cygwin registry name: Cygwin
        Program options name: Program Options
        Cygwin mount registry name: mounts v2
        Cygdrive flags: cygdrive flags
        Cygdrive prefix: cygdrive prefix
        Cygdrive default prefix: 
        Build date: Sun Nov 11 19:01:54 EST 2001
        Shared id: cygwin1S3

  119k 2001/06/06 D:\cygwin\usr\local\grace\bin\cygjpeg6b.dll - os=4.0 img=1.0 sys=4.0
                  "cygjpeg6b.dll" v0.0 ts=2001/6/6 6:27
  163k 2001/05/06 D:\cygwin\usr\local\grace\bin\cygpng2.dll - os=4.0 img=1.0 sys=4.0
                  "cygpng2.dll" v0.0 ts=2001/5/6 6:05
  245k 2001/06/12 D:\cygwin\usr\local\grace\bin\cygtiff3.dll - os=4.0 img=1.0 sys=4.0
                  "cygtiff3.dll" v0.0 ts=2001/6/12 19:25
   49k 2001/02/03 D:\cygwin\usr\local\grace\bin\cygz.dll - os=4.0 img=1.0 sys=4.0
                  "cygz.dll" v0.0 ts=2001/2/3 22:35
Cygwin Package Information
Last downloaded files to: 
Last downloaded files from: ftp://mirrors.rcn.net/mirrors/sources.redhat.com/cygwin

Package             Version             
ash                 20011018-1          
autoconf            2.52-1              
automake            1.5-1               
bash                2.05-8              
binutils            20011002-1          
bison               1.28-1              
byacc               0.0                 
bzip2               1.0.1-6             
clear               1.0                 
cpio                2.4.2               
cron                3.0.1-5             
crypt               1.0-1               
ctags               5.0.1-1             
cvs                 1.11.0-1            
cygrunsrv           0.94-2              
cygwin              1.3.5-1             
dejagnu             20010117-1          
diff                0.0                 
expect              20010117-1          
file                3.33-1              
fileutils           4.1-1               
findutils           0.0                 
flex                2.5.4-1             
gawk                3.0.4-1             
gcc                 2.95.3-5            
gdb                 20010428-3          
gdbm                1.8.0-3             
gettext             0.10.38-2           
ghostscript         6.51-1              
gperf               0.0                 
grep                2.4.2-1             
groff               1.16.1-1            
gzip                1.3-1               
inetutils           1.3.2-15            
irc                 20010101-1          
jbigkit             1.2-4               
jpeg                6b-4                
less                358-3               
libncurses5         5.2-1               
libncurses6         5.2-2               
libpng              1.0.11-1            
login               1.4-2               
lynx                2.8.4-1             
m4                  0.0                 
make                3.79.1-4            
man                 1.5g-2              
mingw               20010917-1          
mingw-runtime       1.1-1               
mt                  1.9.2-1             
mutt                1.2.5i-5            
ncftp               3.0.2-2             
ncurses             5.2-7               
newlib-man          20001118-1          
opengl              1.1.0-5             
openssh             3.0p1-1             
openssl             0.9.6b-1            
patch               2.5-2               
pcre                3.4-2               
perl                5.6.1-2             
popt                1.6.1-1             
postgresql          7.1.3-1             
python              2.1.1-2             
readline            4.2-3               
regex               4.4                 
rsync               2.4.6-2             
rxvt                2.7.2-6             
sed                 3.02-1              
sh-utils            2.0-2               
shellutils          0.0                 
squid               2.4-STABLE20010508  
ssmtp               2.38.7-3            
tar                 1.13.19-1           
tcltk               20001125-1          
tcsh                6.10.00-3           
termcap             20010825-1          
terminfo            5.2-1               
tetex-beta          20001218-1          
texinfo             4.0-4               
textutils           2.0.16-1            
tiff                3.5.6beta-2         
time                1.7-1               
unzip               5.41-1              
vim                 6.0.93-1            
w32api              1.1-1               
wget                1.7-1               
which               1.4                 
xpm                 4.0.0-2             
xpm-nox             4.1.0-1             
zip                 2.3-1               
zlib                1.1.3-6             

Use -h to see help about each section

[-- Attachment #3: optimizeBug.tgz --]
[-- Type: application/x-compressed, Size: 793 bytes --]

[-- Attachment #4: Type: text/plain, Size: 214 bytes --]

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gcc bug: different results between -O0 and -O1
  2001-11-01  9:02 gcc bug: different results between -O0 and -O1 gilles civario
@ 2001-11-01  9:31 ` egor duda
  2001-11-01 19:59   ` gilles civario
  2001-11-11  8:26   ` egor duda
  2001-11-11  8:26 ` gilles civario
  1 sibling, 2 replies; 10+ messages in thread
From: egor duda @ 2001-11-01  9:31 UTC (permalink / raw)
  To: gilles civario; +Cc: cygwin

Hi!

Monday, 12 November, 2001 gilles civario civario@mimosa.ceng.cea.fr wrote:

gc> Wile developing a performance test program for gettimeofday resolution,
gc> I found a strange behavior for gcc under cygwin with the -O flags.
gc> Everywhere else with native compiler or with gcc, the program return constant
gc> results, with or without optimization. (On Sun, Dec, Linux and Fujitsu)
gc> Only with cygwin, the result is divided by 5000 from -O0 to -O1, both with
gc> gcc version 2.95.3-5 (cygwin special) and gcc version 3.0.2.
gc> But it shouldn't. Ok for a little increase, but not for 5000 !

you cannot reliably test float values for equality. you should rethink
the logic of your boucle () function to get reliable results.

Egor.            mailto:deo@logos-m.ru ICQ 5165414 FidoNet 2:5020/496.19


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gcc bug: different results between -O0 and -O1
  2001-11-01  9:31 ` egor duda
@ 2001-11-01 19:59   ` gilles civario
  2001-11-01 21:37     ` Mark Gordon
  2001-11-11  8:26     ` gilles civario
  2001-11-11  8:26   ` egor duda
  1 sibling, 2 replies; 10+ messages in thread
From: gilles civario @ 2001-11-01 19:59 UTC (permalink / raw)
  To: cygwin


Hello.

egor duda a \xE9crit :
> Monday, 12 November, 2001 gilles civario civario@mimosa.ceng.cea.fr wrote:
> 
> gc> Wile developing a performance test program for gettimeofday resolution,
> gc> I found a strange behavior for gcc under cygwin with the -O flags.
> gc> Everywhere else with native compiler or with gcc, the program return constant
> gc> results, with or without optimization. (On Sun, Dec, Linux and Fujitsu)
> gc> Only with cygwin, the result is divided by 5000 from -O0 to -O1, both with
> gc> gcc version 2.95.3-5 (cygwin special) and gcc version 3.0.2.
> gc> But it shouldn't. Ok for a little increase, but not for 5000 !
> 
> you cannot reliably test float values for equality. you should rethink
> the logic of your boucle () function to get reliable results.

I'm not sure that the problem is mine.
First, consider that this little program works fine on a large variety of
different machine, event on Linux PCs.
But, I've tried a different test for my float values :
Instead of (t2 != t1), when I use ((t2-t1)>1.E-10), I got the same results
with -O1 than with -O0. Alleluia !!! But when I use ((t2-t1)>1.E-20), I've
got the initial results and the enormous differences between the two optimization
modes. Why such a comparison gives different results when changing an
optimization flag ? And only with Cygwin ?

Regards

Gilles Civario.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gcc bug: different results between -O0 and -O1
  2001-11-01 19:59   ` gilles civario
@ 2001-11-01 21:37     ` Mark Gordon
  2001-11-02  7:44       ` Danny Smith
  2001-11-11  8:26       ` Mark Gordon
  2001-11-11  8:26     ` gilles civario
  1 sibling, 2 replies; 10+ messages in thread
From: Mark Gordon @ 2001-11-01 21:37 UTC (permalink / raw)
  To: gilles civario; +Cc: cygwin

On Tue, 13 Nov 2001 07:57:57 +0100, gilles civario
<civario@mimosa.ceng.cea.fr> wrote:

>egor duda a \xE9crit :
>> Monday, 12 November, 2001 gilles civario civario@mimosa.ceng.cea.fr wrote:
>> 
>> gc> Wile developing a performance test program for gettimeofday resolution,
>> gc> I found a strange behavior for gcc under cygwin with the -O flags.
>> gc> Everywhere else with native compiler or with gcc, the program return constant
>> gc> results, with or without optimization. (On Sun, Dec, Linux and Fujitsu)
>> gc> Only with cygwin, the result is divided by 5000 from -O0 to -O1, both with
>> gc> gcc version 2.95.3-5 (cygwin special) and gcc version 3.0.2.
>> gc> But it shouldn't. Ok for a little increase, but not for 5000 !
>> 
>> you cannot reliably test float values for equality. you should rethink
>> the logic of your boucle () function to get reliable results.
>
>I'm not sure that the problem is mine.
>First, consider that this little program works fine on a large variety of
>different machine, event on Linux PCs.
>But, I've tried a different test for my float values :
>Instead of (t2 != t1), when I use ((t2-t1)>1.E-10), I got the same results
>with -O1 than with -O0. Alleluia !!! But when I use ((t2-t1)>1.E-20), I've
>got the initial results and the enormous differences between the two optimization
>modes. Why such a comparison gives different results when changing an
>optimization flag ? And only with Cygwin ?

When compiling your code the compiler is at liberty to rearrange the
arithmetic (within certain parameters) if it wants. When enabling
optimisation at different levels it is quite possible that it would do
this and as a result cause different rounding errors. Since the C
standard does not specify what goes on here it is not a bug.

As to why gcc behaves differently on Cygwin to Linux or even,
potentially Windows without Cygwin, this could be caused by
differences in how library functions (or anything else) are
implemented leading that different combinations of registers will be
free making a different route optimal for different types of
optimisation.

If you want to know what it is doing get gcc to produce assembler
files so that you can compare how it has optimised the code in
different situations and on different OSs.
-- 
Mark Gordon - To email me replace spamtrap with mark.gordon
	Dyslexics are teople poo.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gcc bug: different results between -O0 and -O1
  2001-11-01 21:37     ` Mark Gordon
@ 2001-11-02  7:44       ` Danny Smith
  2001-11-11  8:26         ` Danny Smith
  2001-11-11  8:26       ` Mark Gordon
  1 sibling, 1 reply; 10+ messages in thread
From: Danny Smith @ 2001-11-02  7:44 UTC (permalink / raw)
  To: gilles civario; +Cc: cygwin

 --- Mark Gordon <spamtrap@ruddygore.net> wrote: > On Tue, 13 Nov 2001
07:57:57 +0100, gilles civario
> <civario@mimosa.ceng.cea.fr> wrote:
> 
> >egor duda a \xE9crit :
> >> Monday, 12 November, 2001 gilles civario civario@mimosa.ceng.cea.fr
> wrote:
> >> 
> >> gc> Wile developing a performance test program for gettimeofday
> resolution,
> >> gc> I found a strange behavior for gcc under cygwin with the -O flags.
> >> gc> Everywhere else with native compiler or with gcc, the program
> return constant
> >> gc> results, with or without optimization. (On Sun, Dec, Linux and
> Fujitsu)
> >> gc> Only with cygwin, the result is divided by 5000 from -O0 to -O1,
> both with
> >> gc> gcc version 2.95.3-5 (cygwin special) and gcc version 3.0.2.
> >> gc> But it shouldn't. Ok for a little increase, but not for 5000 !
> >> 
> >> you cannot reliably test float values for equality. you should rethink
> >> the logic of your boucle () function to get reliable results.
> >


Have a look at the documentation for -mieee-fp switch.  Also -ffloat-store.
Then try your test case out with these switches,

In C99 standard there are additional functions to control fp rounding
modes.  In the meantime, for more control over fp precision and unordered
comparisons you could provide your own soft float library.

Danny


http://briefcase.yahoo.com.au - Yahoo! Briefcase
- Manage your files online.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* gcc bug: different results between -O0 and -O1
  2001-11-01  9:02 gcc bug: different results between -O0 and -O1 gilles civario
  2001-11-01  9:31 ` egor duda
@ 2001-11-11  8:26 ` gilles civario
  1 sibling, 0 replies; 10+ messages in thread
From: gilles civario @ 2001-11-11  8:26 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 601 bytes --]

Hello.

Wile developing a performance test program for gettimeofday resolution,
I found a strange behavior for gcc under cygwin with the -O flags.
Everywhere else with native compiler or with gcc, the program return constant
results, with or without optimization. (On Sun, Dec, Linux and Fujitsu)
Only with cygwin, the result is divided by 5000 from -O0 to -O1, both with
gcc version 2.95.3-5 (cygwin special) and gcc version 3.0.2.
But it shouldn't. Ok for a little increase, but not for 5000 !

To test the program, use the makefile and execute both bug0.exe and bug1.exe.

Regards.

Gilles Civario.

[-- Attachment #2: cygcheck.out --]
[-- Type: text/plain, Size: 13682 bytes --]


Cygnus Win95/NT Configuration Diagnostics
Current System Time: Mon Nov 12 11:09:36 2001

WinNT Ver 4.0 build 1381 Service Pack 5

Path:	.
	D:\cygwin\bin
	D:\cygwin\bin
	c:\Program Files\Microsoft Visual Studio\Common\Tools
	c:\Program Files\Microsoft Visual Studio\Common\Msdev98\BIN
	c:\Program Files\Microsoft Visual Studio\DF98\BIN
	c:\Program Files\Microsoft Visual Studio\VC98\BIN
	c:\WINNT\system32
	c:\WINNT
	c:\IWSAAAPI
	d:\util\Python21
	d:\util\Python21\DLLs
	c:\Program Files\MiKTeX\miktex\bin
	.
	D:\cygwin\bin
	D:\cygwin\bin
	D:\cygwin\usr\local\bin
	c:\ispell\bin
	D:\cygwin\usr\X11R6\bin
	D:\cygwin\usr\local\grace\bin

SysDir: C:\WINNT\System32
WinDir: C:\WINNT

HOME = `d:\gilles'
MAKE_MODE = `unix'
PWD = `/cygdrive/d/gilles/tmp'
USER = `gilles'

CLASSPATH = `C:\Program Files\Exceed.nt\hcljrcsv.jar;C:\Program Files\Exceed.nt\;'
COMPUTERNAME = `GLENANS'
COMSPEC = `C:\WINNT\system32\cmd.exe'
CPU = `i386'
DISPLAY = `127.0.0.1:0'
DISTINCTPATH = `C:\PROGRA~1\Distinct;C:\PROGRA~1\COMMON~1\DISTIN~1'
GRACE_HOME = `/usr/local/grace'
HOMEDRIVE = `C:'
HOMEPATH = `\'
HOSTNAME = `GLENANS'
HOSTTYPE = `i686'
INCLUDE = `C:\Program Files\Microsoft Visual Studio\DF98\IMSL\INCLUDE;C:\Program Files\Microsoft Visual Studio\DF98\INCLUDE;C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE'
LIB = `C:\Program Files\Microsoft Visual Studio\DF98\IMSL\LIB;C:\Program Files\Microsoft Visual Studio\DF98\LIB;C:\Program Files\Microsoft Visual Studio\VC98\LIB'
LINK_F90 = `sstatd.lib sstats.lib smathd.lib smaths.lib sf90mp.lib'
LOGONSERVER = `\\GLENANS'
LS_COLORS = `no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:'
MACHTYPE = `i686-pc-cygwin'
MANPAGER = `/usr/bin/less -isFX'
MANPATH = `:/usr/local/share/man:/usr/X11R6/man'
NUMBER_OF_PROCESSORS = `1'
OLDPWD = `/cygdrive/d/gilles'
OS2LIBPATH = `C:\WINNT\system32\os2\dll;'
OS = `Windows_NT'
OSTYPE = `cygwin'
PATHEXT = `.COM;.EXE;.BAT;.CMD'
PROCESSOR_ARCHITECTURE = `x86'
PROCESSOR_IDENTIFIER = `x86 Family 6 Model 5 Stepping 2, GenuineIntel'
PROCESSOR_LEVEL = `6'
PROCESSOR_REVISION = `0502'
PROMPT = `$P$G'
PS1 = `^[]0;\w\a^[[32m\u@\h ^[[33m\w
^[[35m \! ^[[0m> '
SHELL = `/bin/bash'
SHLVL = `1'
SYSTEMDRIVE = `C:'
SYSTEMROOT = `C:\WINNT'
TEMP = `c:\TEMP'
TERM = `cygwin'
TZ = `GMT-2'
USERDOMAIN = `GLENANS'
USERNAME = `gilles'
USERPROFILE = `C:\WINNT\Profiles\gilles'
VNI_F90_MSG = `C:\Program Files\Microsoft Visual Studio\DF98\IMSL\MESSAGE'
WINDIR = `C:\WINNT'
XKEYSYMDB = `/usr/local/grace/XKeysymDB'
_ = `/usr/bin/cygcheck'

HKEY_CURRENT_USER\Software\Cygnus Solutions
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2
  (default) = `/cygdrive'
  cygdrive flags = 0x00000022
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\Program Options
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/
  (default) = `D:/cygwin'
  flags = 0x0000000a
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/usr/bin
  (default) = `D:/cygwin/bin'
  flags = 0x0000000a
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/usr/lib
  (default) = `D:/cygwin/lib'
  flags = 0x0000000a
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\Program Options

a:  fd           N/A    N/A                    
c:  hd  FAT     2044Mb  94% CP    UN           ABDYN30ABF
d:  hd  FAT     2044Mb  78% CP    UN           VOL_LOG1
e:  cd           N/A    N/A                    

.              /cygdrive  user    binmode,noumount
D:/cygwin      /          system  binmode
D:/cygwin/bin  /usr/bin   system  binmode
D:/cygwin/lib  /usr/lib   system  binmode

Found: D:\cygwin\bin\bash.exe
Found: D:\cygwin\bin\cat.exe
Found: D:\cygwin\bin\cpp.exe
Found: D:\cygwin\usr\local\bin\cpp.exe
Warning: D:\cygwin\bin\cpp.exe hides D:\cygwin\usr\local\bin\cpp.exe
Found: D:\cygwin\bin\find.exe
Found: D:\cygwin\bin\gcc.exe
Found: D:\cygwin\usr\local\bin\gcc.exe
Warning: D:\cygwin\bin\gcc.exe hides D:\cygwin\usr\local\bin\gcc.exe
Found: D:\cygwin\bin\gdb.exe
Found: D:\cygwin\bin\ld.exe
Found: D:\cygwin\bin\ls.exe
Found: D:\cygwin\bin\make.exe
Found: D:\cygwin\bin\sh.exe

   49k 2001/02/03 D:\cygwin\bin\cygz.dll - os=4.0 img=1.0 sys=4.0
                  "cygz.dll" v0.0 ts=2001/2/3 22:35
  163k 2001/05/06 D:\cygwin\bin\cygpng2.dll - os=4.0 img=1.0 sys=4.0
                  "cygpng2.dll" v0.0 ts=2001/5/6 6:05
   18k 2000/10/23 D:\cygwin\bin\cyggdbm.dll - os=4.0 img=1.0 sys=4.0
                  "cyggdbm.dll" v0.0 ts=2000/10/23 4:26
   21k 2001/06/20 D:\cygwin\bin\cygintl.dll - os=4.0 img=1.0 sys=4.0
                  "cygintl.dll" v0.0 ts=2001/6/20 19:09
   45k 2001/07/04 D:\cygwin\bin\cygjbig1.dll - os=4.0 img=1.0 sys=4.0
                  "cygjbig1.dll" v0.0 ts=2001/7/4 5:25
  119k 2001/06/06 D:\cygwin\bin\cygjpeg6b.dll - os=4.0 img=1.0 sys=4.0
                  "cygjpeg6b.dll" v0.0 ts=2001/6/6 6:27
   45k 2001/04/25 D:\cygwin\bin\cygform5.dll - os=4.0 img=1.0 sys=4.0
                  "cygform5.dll" v0.0 ts=2001/4/25 7:28
   26k 2001/04/25 D:\cygwin\bin\cygmenu5.dll - os=4.0 img=1.0 sys=4.0
                  "cygmenu5.dll" v0.0 ts=2001/4/25 7:27
  156k 2001/04/25 D:\cygwin\bin\cygncurses++5.dll - os=4.0 img=1.0 sys=4.0
                  "cygncurses++5.dll" v0.0 ts=2001/4/25 7:29
  226k 2001/04/25 D:\cygwin\bin\cygncurses5.dll - os=4.0 img=1.0 sys=4.0
                  "cygncurses5.dll" v0.0 ts=2001/4/25 7:17
   15k 2001/04/25 D:\cygwin\bin\cygpanel5.dll - os=4.0 img=1.0 sys=4.0
                  "cygpanel5.dll" v0.0 ts=2001/4/25 7:27
   81k 2001/10/20 D:\cygwin\bin\cygitcl30.dll - os=4.0 img=1.0 sys=4.0
                  "cygitcl30.dll" v0.0 ts=2001/10/20 2:25
   35k 2001/10/20 D:\cygwin\bin\cygitk30.dll - os=4.0 img=1.0 sys=4.0
                  "cygitk30.dll" v0.0 ts=2001/10/20 2:25
  245k 2001/06/12 D:\cygwin\bin\cygtiff3.dll - os=4.0 img=1.0 sys=4.0
                  "cygtiff3.dll" v0.0 ts=2001/6/12 19:25
   41k 2001/07/04 D:\cygwin\bin\cygXpm-noX4.dll - os=4.0 img=1.0 sys=4.0
                  "cygXpm-noX4.dll" v0.0 ts=2001/7/4 3:21
   45k 2001/07/04 D:\cygwin\bin\cygXpm-X4.dll - os=4.0 img=1.0 sys=4.0
                  "cygXpm-X4.dll" v0.0 ts=2000/11/20 4:45
  390k 2001/10/20 D:\cygwin\bin\cygtcl80.dll - os=4.0 img=1.0 sys=4.0
                  "cygtcl80.dll" v0.0 ts=2001/10/20 2:24
   56k 2000/12/03 D:\cygwin\bin\cygbz21.0.dll - os=4.0 img=1.0 sys=4.0
                  "cygbz21.0.dll" v0.0 ts=2000/11/21 1:53
    5k 2001/10/20 D:\cygwin\bin\cygtclpip80.dll - os=4.0 img=1.0 sys=4.0
   10k 2001/10/20 D:\cygwin\bin\cygtclreg80.dll - os=4.0 img=1.0 sys=4.0
                  "cygtclreg80.dll" v0.0 ts=2001/10/20 2:24
  623k 2001/10/20 D:\cygwin\bin\cygtk80.dll - os=4.0 img=1.0 sys=4.0
                  "cygtk80.dll" v0.0 ts=2001/10/20 2:25
   34k 2001/09/30 D:\cygwin\bin\cygform6.dll - os=4.0 img=1.0 sys=4.0
                  "cygform6.dll" v0.0 ts=2001/9/30 4:43
   19k 2001/09/30 D:\cygwin\bin\cygmenu6.dll - os=4.0 img=1.0 sys=4.0
                  "cygmenu6.dll" v0.0 ts=2001/9/30 4:43
   17k 2001/06/28 D:\cygwin\bin\cyghistory4.dll - os=4.0 img=1.0 sys=4.0
                  "cyghistory4.dll" v0.0 ts=2001/1/7 6:34
   21k 2001/06/28 D:\cygwin\bin\cyghistory5.dll - os=4.0 img=1.0 sys=4.0
                  "cyghistory5.dll" v0.0 ts=2001/6/28 4:27
  108k 2001/06/28 D:\cygwin\bin\cygreadline4.dll - os=4.0 img=1.0 sys=4.0
                  "cygreadline4.dll" v0.0 ts=2001/1/7 6:34
  135k 2001/06/28 D:\cygwin\bin\cygreadline5.dll - os=4.0 img=1.0 sys=4.0
                  "cygreadline5.dll" v0.0 ts=2001/6/28 4:27
  175k 2001/09/30 D:\cygwin\bin\cygncurses++6.dll - os=4.0 img=1.0 sys=4.0
                  "cygncurses++6.dll" v0.0 ts=2001/9/30 4:45
  201k 2001/09/30 D:\cygwin\bin\cygncurses6.dll - os=4.0 img=1.0 sys=4.0
                  "cygncurses6.dll" v0.0 ts=2001/9/30 4:42
   12k 2001/09/30 D:\cygwin\bin\cygpanel6.dll - os=4.0 img=1.0 sys=4.0
                  "cygpanel6.dll" v0.0 ts=2001/9/30 4:43
  714k 2001/11/12 D:\cygwin\bin\cygwin1.dll - os=4.0 img=1.0 sys=4.0
                  "cygwin1.dll" v0.0 ts=2001/11/12 2:01
    Cygwin DLL version info:
        DLL version: 1.3.5
        DLL epoch: 19
        DLL bad signal mask: 19005
        DLL old termios: 5
        DLL malloc env: 28
        API major: 0
        API minor: 47
        Shared data: 3
        DLL identifier: cygwin1
        Mount registry: 2
        Cygnus registry name: Cygnus Solutions
        Cygwin registry name: Cygwin
        Program options name: Program Options
        Cygwin mount registry name: mounts v2
        Cygdrive flags: cygdrive flags
        Cygdrive prefix: cygdrive prefix
        Cygdrive default prefix: 
        Build date: Sun Nov 11 19:01:54 EST 2001
        Shared id: cygwin1S3

  119k 2001/06/06 D:\cygwin\usr\local\grace\bin\cygjpeg6b.dll - os=4.0 img=1.0 sys=4.0
                  "cygjpeg6b.dll" v0.0 ts=2001/6/6 6:27
  163k 2001/05/06 D:\cygwin\usr\local\grace\bin\cygpng2.dll - os=4.0 img=1.0 sys=4.0
                  "cygpng2.dll" v0.0 ts=2001/5/6 6:05
  245k 2001/06/12 D:\cygwin\usr\local\grace\bin\cygtiff3.dll - os=4.0 img=1.0 sys=4.0
                  "cygtiff3.dll" v0.0 ts=2001/6/12 19:25
   49k 2001/02/03 D:\cygwin\usr\local\grace\bin\cygz.dll - os=4.0 img=1.0 sys=4.0
                  "cygz.dll" v0.0 ts=2001/2/3 22:35
Cygwin Package Information
Last downloaded files to: 
Last downloaded files from: ftp://mirrors.rcn.net/mirrors/sources.redhat.com/cygwin

Package             Version             
ash                 20011018-1          
autoconf            2.52-1              
automake            1.5-1               
bash                2.05-8              
binutils            20011002-1          
bison               1.28-1              
byacc               0.0                 
bzip2               1.0.1-6             
clear               1.0                 
cpio                2.4.2               
cron                3.0.1-5             
crypt               1.0-1               
ctags               5.0.1-1             
cvs                 1.11.0-1            
cygrunsrv           0.94-2              
cygwin              1.3.5-1             
dejagnu             20010117-1          
diff                0.0                 
expect              20010117-1          
file                3.33-1              
fileutils           4.1-1               
findutils           0.0                 
flex                2.5.4-1             
gawk                3.0.4-1             
gcc                 2.95.3-5            
gdb                 20010428-3          
gdbm                1.8.0-3             
gettext             0.10.38-2           
ghostscript         6.51-1              
gperf               0.0                 
grep                2.4.2-1             
groff               1.16.1-1            
gzip                1.3-1               
inetutils           1.3.2-15            
irc                 20010101-1          
jbigkit             1.2-4               
jpeg                6b-4                
less                358-3               
libncurses5         5.2-1               
libncurses6         5.2-2               
libpng              1.0.11-1            
login               1.4-2               
lynx                2.8.4-1             
m4                  0.0                 
make                3.79.1-4            
man                 1.5g-2              
mingw               20010917-1          
mingw-runtime       1.1-1               
mt                  1.9.2-1             
mutt                1.2.5i-5            
ncftp               3.0.2-2             
ncurses             5.2-7               
newlib-man          20001118-1          
opengl              1.1.0-5             
openssh             3.0p1-1             
openssl             0.9.6b-1            
patch               2.5-2               
pcre                3.4-2               
perl                5.6.1-2             
popt                1.6.1-1             
postgresql          7.1.3-1             
python              2.1.1-2             
readline            4.2-3               
regex               4.4                 
rsync               2.4.6-2             
rxvt                2.7.2-6             
sed                 3.02-1              
sh-utils            2.0-2               
shellutils          0.0                 
squid               2.4-STABLE20010508  
ssmtp               2.38.7-3            
tar                 1.13.19-1           
tcltk               20001125-1          
tcsh                6.10.00-3           
termcap             20010825-1          
terminfo            5.2-1               
tetex-beta          20001218-1          
texinfo             4.0-4               
textutils           2.0.16-1            
tiff                3.5.6beta-2         
time                1.7-1               
unzip               5.41-1              
vim                 6.0.93-1            
w32api              1.1-1               
wget                1.7-1               
which               1.4                 
xpm                 4.0.0-2             
xpm-nox             4.1.0-1             
zip                 2.3-1               
zlib                1.1.3-6             

Use -h to see help about each section

[-- Attachment #3: optimizeBug.tgz --]
[-- Type: application/x-compressed, Size: 793 bytes --]

[-- Attachment #4: Type: text/plain, Size: 214 bytes --]

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gcc bug: different results between -O0 and -O1
  2001-11-01 19:59   ` gilles civario
  2001-11-01 21:37     ` Mark Gordon
@ 2001-11-11  8:26     ` gilles civario
  1 sibling, 0 replies; 10+ messages in thread
From: gilles civario @ 2001-11-11  8:26 UTC (permalink / raw)
  To: cygwin


Hello.

egor duda a écrit :
> Monday, 12 November, 2001 gilles civario civario@mimosa.ceng.cea.fr wrote:
> 
> gc> Wile developing a performance test program for gettimeofday resolution,
> gc> I found a strange behavior for gcc under cygwin with the -O flags.
> gc> Everywhere else with native compiler or with gcc, the program return constant
> gc> results, with or without optimization. (On Sun, Dec, Linux and Fujitsu)
> gc> Only with cygwin, the result is divided by 5000 from -O0 to -O1, both with
> gc> gcc version 2.95.3-5 (cygwin special) and gcc version 3.0.2.
> gc> But it shouldn't. Ok for a little increase, but not for 5000 !
> 
> you cannot reliably test float values for equality. you should rethink
> the logic of your boucle () function to get reliable results.

I'm not sure that the problem is mine.
First, consider that this little program works fine on a large variety of
different machine, event on Linux PCs.
But, I've tried a different test for my float values :
Instead of (t2 != t1), when I use ((t2-t1)>1.E-10), I got the same results
with -O1 than with -O0. Alleluia !!! But when I use ((t2-t1)>1.E-20), I've
got the initial results and the enormous differences between the two optimization
modes. Why such a comparison gives different results when changing an
optimization flag ? And only with Cygwin ?

Regards

Gilles Civario.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gcc bug: different results between -O0 and -O1
  2001-11-02  7:44       ` Danny Smith
@ 2001-11-11  8:26         ` Danny Smith
  0 siblings, 0 replies; 10+ messages in thread
From: Danny Smith @ 2001-11-11  8:26 UTC (permalink / raw)
  To: gilles civario; +Cc: cygwin

 --- Mark Gordon <spamtrap@ruddygore.net> wrote: > On Tue, 13 Nov 2001
07:57:57 +0100, gilles civario
> <civario@mimosa.ceng.cea.fr> wrote:
> 
> >egor duda a écrit :
> >> Monday, 12 November, 2001 gilles civario civario@mimosa.ceng.cea.fr
> wrote:
> >> 
> >> gc> Wile developing a performance test program for gettimeofday
> resolution,
> >> gc> I found a strange behavior for gcc under cygwin with the -O flags.
> >> gc> Everywhere else with native compiler or with gcc, the program
> return constant
> >> gc> results, with or without optimization. (On Sun, Dec, Linux and
> Fujitsu)
> >> gc> Only with cygwin, the result is divided by 5000 from -O0 to -O1,
> both with
> >> gc> gcc version 2.95.3-5 (cygwin special) and gcc version 3.0.2.
> >> gc> But it shouldn't. Ok for a little increase, but not for 5000 !
> >> 
> >> you cannot reliably test float values for equality. you should rethink
> >> the logic of your boucle () function to get reliable results.
> >


Have a look at the documentation for -mieee-fp switch.  Also -ffloat-store.
Then try your test case out with these switches,

In C99 standard there are additional functions to control fp rounding
modes.  In the meantime, for more control over fp precision and unordered
comparisons you could provide your own soft float library.

Danny


http://briefcase.yahoo.com.au - Yahoo! Briefcase
- Manage your files online.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gcc bug: different results between -O0 and -O1
  2001-11-01 21:37     ` Mark Gordon
  2001-11-02  7:44       ` Danny Smith
@ 2001-11-11  8:26       ` Mark Gordon
  1 sibling, 0 replies; 10+ messages in thread
From: Mark Gordon @ 2001-11-11  8:26 UTC (permalink / raw)
  To: gilles civario; +Cc: cygwin

On Tue, 13 Nov 2001 07:57:57 +0100, gilles civario
<civario@mimosa.ceng.cea.fr> wrote:

>egor duda a écrit :
>> Monday, 12 November, 2001 gilles civario civario@mimosa.ceng.cea.fr wrote:
>> 
>> gc> Wile developing a performance test program for gettimeofday resolution,
>> gc> I found a strange behavior for gcc under cygwin with the -O flags.
>> gc> Everywhere else with native compiler or with gcc, the program return constant
>> gc> results, with or without optimization. (On Sun, Dec, Linux and Fujitsu)
>> gc> Only with cygwin, the result is divided by 5000 from -O0 to -O1, both with
>> gc> gcc version 2.95.3-5 (cygwin special) and gcc version 3.0.2.
>> gc> But it shouldn't. Ok for a little increase, but not for 5000 !
>> 
>> you cannot reliably test float values for equality. you should rethink
>> the logic of your boucle () function to get reliable results.
>
>I'm not sure that the problem is mine.
>First, consider that this little program works fine on a large variety of
>different machine, event on Linux PCs.
>But, I've tried a different test for my float values :
>Instead of (t2 != t1), when I use ((t2-t1)>1.E-10), I got the same results
>with -O1 than with -O0. Alleluia !!! But when I use ((t2-t1)>1.E-20), I've
>got the initial results and the enormous differences between the two optimization
>modes. Why such a comparison gives different results when changing an
>optimization flag ? And only with Cygwin ?

When compiling your code the compiler is at liberty to rearrange the
arithmetic (within certain parameters) if it wants. When enabling
optimisation at different levels it is quite possible that it would do
this and as a result cause different rounding errors. Since the C
standard does not specify what goes on here it is not a bug.

As to why gcc behaves differently on Cygwin to Linux or even,
potentially Windows without Cygwin, this could be caused by
differences in how library functions (or anything else) are
implemented leading that different combinations of registers will be
free making a different route optimal for different types of
optimisation.

If you want to know what it is doing get gcc to produce assembler
files so that you can compare how it has optimised the code in
different situations and on different OSs.
-- 
Mark Gordon - To email me replace spamtrap with mark.gordon
	Dyslexics are teople poo.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gcc bug: different results between -O0 and -O1
  2001-11-01  9:31 ` egor duda
  2001-11-01 19:59   ` gilles civario
@ 2001-11-11  8:26   ` egor duda
  1 sibling, 0 replies; 10+ messages in thread
From: egor duda @ 2001-11-11  8:26 UTC (permalink / raw)
  To: gilles civario; +Cc: cygwin

Hi!

Monday, 12 November, 2001 gilles civario civario@mimosa.ceng.cea.fr wrote:

gc> Wile developing a performance test program for gettimeofday resolution,
gc> I found a strange behavior for gcc under cygwin with the -O flags.
gc> Everywhere else with native compiler or with gcc, the program return constant
gc> results, with or without optimization. (On Sun, Dec, Linux and Fujitsu)
gc> Only with cygwin, the result is divided by 5000 from -O0 to -O1, both with
gc> gcc version 2.95.3-5 (cygwin special) and gcc version 3.0.2.
gc> But it shouldn't. Ok for a little increase, but not for 5000 !

you cannot reliably test float values for equality. you should rethink
the logic of your boucle () function to get reliable results.

Egor.            mailto:deo@logos-m.ru ICQ 5165414 FidoNet 2:5020/496.19


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2001-11-13 20:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-01  9:02 gcc bug: different results between -O0 and -O1 gilles civario
2001-11-01  9:31 ` egor duda
2001-11-01 19:59   ` gilles civario
2001-11-01 21:37     ` Mark Gordon
2001-11-02  7:44       ` Danny Smith
2001-11-11  8:26         ` Danny Smith
2001-11-11  8:26       ` Mark Gordon
2001-11-11  8:26     ` gilles civario
2001-11-11  8:26   ` egor duda
2001-11-11  8:26 ` gilles civario

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).