* Incorrect results from numerical library when using -ftree-ter @ 2012-06-07 16:29 Szabolcs Horvát 2012-06-07 22:51 ` Ian Lance Taylor 0 siblings, 1 reply; 5+ messages in thread From: Szabolcs Horvát @ 2012-06-07 16:29 UTC (permalink / raw) To: gcc-help Hello, I am using the Triangle library <http://www.cs.cmu.edu/~quake/triangle.html> to generate Delaunay triangulations of a large number of points. When I compile this library using the -ftree-ter optimization option only, the library gives me incorrect results for certain inputs. The -ftree-ter option is enabled by optimization level -O1 or higher, which also cause the library to return incorrect results. Question: Does this indicate that there is a bug in gcc or is it more likely that there's a problem in how the library is written? Unfortunately I am not familiar with the code of Triangle, I just compile it and use it. I tried this with gcc 4.6.3 on Ubuntu and gcc 4.7.0 on Windows (from <http://nuwen.net/mingw.html>), both 32-bit. Szabolcs ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Incorrect results from numerical library when using -ftree-ter 2012-06-07 16:29 Incorrect results from numerical library when using -ftree-ter Szabolcs Horvát @ 2012-06-07 22:51 ` Ian Lance Taylor 2012-06-11 12:31 ` Szabolcs Horvát 0 siblings, 1 reply; 5+ messages in thread From: Ian Lance Taylor @ 2012-06-07 22:51 UTC (permalink / raw) To: Szabolcs Horvát; +Cc: gcc-help Szabolcs Horvát <szhorvat@gmail.com> writes: > I am using the Triangle library > <http://www.cs.cmu.edu/~quake/triangle.html> to generate Delaunay > triangulations of a large number of points. When I compile this > library using the -ftree-ter optimization option only, the library > gives me incorrect results for certain inputs. The -ftree-ter option > is enabled by optimization level -O1 or higher, which also cause the > library to return incorrect results. > > Question: Does this indicate that there is a bug in gcc or is it more > likely that there's a problem in how the library is written? > > Unfortunately I am not familiar with the code of Triangle, I just > compile it and use it. > > I tried this with gcc 4.6.3 on Ubuntu and gcc 4.7.0 on Windows (from > <http://nuwen.net/mingw.html>), both 32-bit. While a bug in GCC is always possible, it is more likely that there's a problem in how the library is written. Ian ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Incorrect results from numerical library when using -ftree-ter 2012-06-07 22:51 ` Ian Lance Taylor @ 2012-06-11 12:31 ` Szabolcs Horvát 2012-06-11 13:01 ` Dario Saccavino 0 siblings, 1 reply; 5+ messages in thread From: Szabolcs Horvát @ 2012-06-11 12:31 UTC (permalink / raw) To: Ian Lance Taylor; +Cc: gcc-help On 8 June 2012 00:50, Ian Lance Taylor <iant@google.com> wrote: > Szabolcs Horvát <szhorvat@gmail.com> writes: > >> I am using the Triangle library >> <http://www.cs.cmu.edu/~quake/triangle.html> to generate Delaunay >> triangulations of a large number of points. When I compile this >> library using the -ftree-ter optimization option only, the library >> gives me incorrect results for certain inputs. The -ftree-ter option >> is enabled by optimization level -O1 or higher, which also cause the >> library to return incorrect results. >> >> Question: Does this indicate that there is a bug in gcc or is it more >> likely that there's a problem in how the library is written? >> >> Unfortunately I am not familiar with the code of Triangle, I just >> compile it and use it. >> >> I tried this with gcc 4.6.3 on Ubuntu and gcc 4.7.0 on Windows (from >> <http://nuwen.net/mingw.html>), both 32-bit. > > > While a bug in GCC is always possible, it is more likely that there's a > problem in how the library is written. > Unfortunately I am not in a position to find out if it's a problem with Triangle as I don't know in detail how it works. Triangle is quite extensively used though, and it's last version is from 2005. I wonder why the problem has not come out before. A strange thing is that I get a different kind of incorrect result if I use the -O1 option or if I manually specify all the flags that -O1 is supposed to turn on. What could be the reason for this? I got the list of flags from here: http://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Optimize-Options.html#Optimize-Options Similarly, using -O1 -fno-tree-ter does NOT fix the problem. Specifying all options that -O1 is supposed to imply according to the docs, except -ftree-ter DOES fix the problem. What is the difference between -O1 and listing all options that it implies? ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Incorrect results from numerical library when using -ftree-ter 2012-06-11 12:31 ` Szabolcs Horvát @ 2012-06-11 13:01 ` Dario Saccavino 2012-06-11 15:30 ` Szabolcs Horvát 0 siblings, 1 reply; 5+ messages in thread From: Dario Saccavino @ 2012-06-11 13:01 UTC (permalink / raw) To: Szabolcs Horvát; +Cc: Ian Lance Taylor, gcc-help 2012/6/11 Szabolcs Horvát <szhorvat@gmail.com> > > On 8 June 2012 00:50, Ian Lance Taylor <iant@google.com> wrote: > > Szabolcs Horvát <szhorvat@gmail.com> writes: > > > >> I am using the Triangle library > >> <http://www.cs.cmu.edu/~quake/triangle.html> to generate Delaunay > >> triangulations of a large number of points. When I compile this > >> library using the -ftree-ter optimization option only, the library > >> gives me incorrect results for certain inputs. The -ftree-ter option > >> is enabled by optimization level -O1 or higher, which also cause the > >> library to return incorrect results. > >> > >> Question: Does this indicate that there is a bug in gcc or is it more > >> likely that there's a problem in how the library is written? > >> > >> Unfortunately I am not familiar with the code of Triangle, I just > >> compile it and use it. > >> > >> I tried this with gcc 4.6.3 on Ubuntu and gcc 4.7.0 on Windows (from > >> <http://nuwen.net/mingw.html>), both 32-bit. > > > > > > While a bug in GCC is always possible, it is more likely that there's a > > problem in how the library is written. > > > > Unfortunately I am not in a position to find out if it's a problem > with Triangle as I don't know in detail how it works. Triangle is > quite extensively used though, and it's last version is from 2005. I > wonder why the problem has not come out before. > > A strange thing is that I get a different kind of incorrect result if > I use the -O1 option or if I manually specify all the flags that -O1 > is supposed to turn on. What could be the reason for this? I got the > list of flags from here: > http://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Optimize-Options.html#Optimize-Options That page says "Not all optimizations are controlled directly by a flag. Only optimizations that have a flag are listed in this section." This means specifying -O1 is not equivalent to specifying all the listed options. > > Similarly, using -O1 -fno-tree-ter does NOT fix the problem. > Specifying all options that -O1 is supposed to imply according to the > docs, except -ftree-ter DOES fix the problem. > > What is the difference between -O1 and listing all options that it implies? The library's README file contains the following text: Some processors, including Intel x86 family and possibly Motorola 68xxx family chips, are IEEE conformant but have extended length internal floating-point registers that may defeat Triangle's exact arithmetic routines by failing to cause enough roundoff error! Typically, there is a way to set these internal registers so that they are rounded off to IEEE single or double precision format. I believe (but I'm not certain) that Triangle has the right incantations for x86 chips, if you have gcc running under Linux (define the LINUX compiler symbol) or Microsoft C (define the CPU86 compiler symbol). Unfortunately, the library has not been updated since 2005 and I think "the right incantation" may not work with a modern version of GCC. I suggest trying one of the following: - define LINUX or CPU86 - use the option -fexcess-precision=standard - if your program is not going to run on old hardware, use the options -mfpmath=sse -msse2 Dario ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Incorrect results from numerical library when using -ftree-ter 2012-06-11 13:01 ` Dario Saccavino @ 2012-06-11 15:30 ` Szabolcs Horvát 0 siblings, 0 replies; 5+ messages in thread From: Szabolcs Horvát @ 2012-06-11 15:30 UTC (permalink / raw) To: Dario Saccavino; +Cc: Ian Lance Taylor, gcc-help On 11 June 2012 15:00, Dario Saccavino <kathoum@gmail.com> wrote: > 2012/6/11 Szabolcs Horvát <szhorvat@gmail.com> >> >> On 8 June 2012 00:50, Ian Lance Taylor <iant@google.com> wrote: >> > Szabolcs Horvát <szhorvat@gmail.com> writes: >> > >> >> I am using the Triangle library >> >> <http://www.cs.cmu.edu/~quake/triangle.html> to generate Delaunay >> >> triangulations of a large number of points. When I compile this >> >> library using the -ftree-ter optimization option only, the library >> >> gives me incorrect results for certain inputs. The -ftree-ter option >> >> is enabled by optimization level -O1 or higher, which also cause the >> >> library to return incorrect results. >> >> >> >> Question: Does this indicate that there is a bug in gcc or is it more >> >> likely that there's a problem in how the library is written? >> >> >> >> Unfortunately I am not familiar with the code of Triangle, I just >> >> compile it and use it. >> >> >> >> I tried this with gcc 4.6.3 on Ubuntu and gcc 4.7.0 on Windows (from >> >> <http://nuwen.net/mingw.html>), both 32-bit. >> > >> > >> > While a bug in GCC is always possible, it is more likely that there's a >> > problem in how the library is written. >> > >> >> Unfortunately I am not in a position to find out if it's a problem >> with Triangle as I don't know in detail how it works. Triangle is >> quite extensively used though, and it's last version is from 2005. I >> wonder why the problem has not come out before. >> >> A strange thing is that I get a different kind of incorrect result if >> I use the -O1 option or if I manually specify all the flags that -O1 >> is supposed to turn on. What could be the reason for this? I got the >> list of flags from here: >> http://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Optimize-Options.html#Optimize-Options > > That page says "Not all optimizations are controlled directly by a flag. Only > optimizations that have a flag are listed in this section." > This means specifying -O1 is not equivalent to specifying all the > listed options. > >> >> Similarly, using -O1 -fno-tree-ter does NOT fix the problem. >> Specifying all options that -O1 is supposed to imply according to the >> docs, except -ftree-ter DOES fix the problem. >> >> What is the difference between -O1 and listing all options that it implies? > > The library's README file contains the following text: > > Some processors, including Intel x86 family and possibly Motorola 68xxx > family chips, are IEEE conformant but have extended length internal > floating-point registers that may defeat Triangle's exact arithmetic > routines by failing to cause enough roundoff error! Typically, there is a > way to set these internal registers so that they are rounded off to IEEE > single or double precision format. I believe (but I'm not certain) that > Triangle has the right incantations for x86 chips, if you have gcc running > under Linux (define the LINUX compiler symbol) or Microsoft C (define the > CPU86 compiler symbol). > > Unfortunately, the library has not been updated since 2005 and I think > "the right incantation" may not work with a modern version of GCC. > > I suggest trying one of the following: > - define LINUX or CPU86 > - use the option -fexcess-precision=standard > - if your program is not going to run on old hardware, use the > options -mfpmath=sse -msse2 > Thank you Dario, defining CPU86, and making sure that all other necessary defines are present have solved the problem. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-06-11 15:30 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-06-07 16:29 Incorrect results from numerical library when using -ftree-ter Szabolcs Horvát 2012-06-07 22:51 ` Ian Lance Taylor 2012-06-11 12:31 ` Szabolcs Horvát 2012-06-11 13:01 ` Dario Saccavino 2012-06-11 15:30 ` Szabolcs Horvát
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).