Re: [sqlite] GCC -ffast-math safe version of sqlite3IsNaN
Brown, Daniel wrote: > Thanks for the clarification Roger, I guess it looks like I will need to > modify the compiler settings locally then. If you can modify the amalgamation source code, I would try updating sqlite3IsNan() to use the standard C isnan() macro. DRH commented in one of the tickets that isnan() is not used by default since it is not available on all platforms. (In addition, the custom IsNan removes a dependency on the standard math library.) Assuming that isnan() is available to you (and assuming that it works with --fast-math), you may be able to trade a tricky build-script change for a quick source code change. ~Eric ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] GCC -ffast-math safe version of sqlite3IsNaN
Thanks for the clarification Roger, I guess it looks like I will need to modify the compiler settings locally then. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Roger Binns Sent: Tuesday, August 26, 2008 5:00 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] GCC -ffast-math safe version of sqlite3IsNaN -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Brown, Daniel wrote: > In the process of upgrading to 3.6.1 I've run into the error on line 46 > of util.c about int sqlite3IsNaN(double x) not behaving consistently > with the GCC -ffast-math compiler option (which we have enabled), is > there any alternative function I could use that would be compatible with > GCC -ffast-math? Removing the -ffast-math option from our projects > would be highly undesirable for us, as performance is paramount. If you don't use any floating point with SQLite then just remove the #error. However if you do use floating point with SQLite then you can't use fast math. See the following tickets which show a variety of problematic behaviour with -ffast-math: http://www.sqlite.org/cvstrac/tktview?tn=3101 http://www.sqlite.org/cvstrac/tktview?tn=3186 http://www.sqlite.org/cvstrac/tktview?tn=3194 http://www.sqlite.org/cvstrac/tktview?tn=3202 Roger -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFItJj7mOOfHg372QQRAlXDAJ9n+/Xe1E/1DszYXxCcVPjb+pxHOwCfcB5J XkV7LD9lbEv59oK9WS+r174= =8d1g -END PGP SIGNATURE- ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] GCC -ffast-math safe version of sqlite3IsNaN
Brown, Daniel wrote: >Unfortunately our build system is automated and not particularly agile, it can >be done but it would be preferred not to have to do that and to replace the >offending function instead but I've never had to write a IsNaN test. > > > I had a look at the sourcecode for sqlite3IsNaN(): SQLITE_PRIVATE int sqlite3IsNaN(double x){ /* This NaN test sometimes fails if compiled on GCC with -ffast-math. ** On the other hand, the use of -ffast-math comes with the following ** warning: ** ** This option [-ffast-math] should never be turned on by any ** -O option since it can result in incorrect output for programs ** which depend on an exact implementation of IEEE or ISO ** rules/specifications for math functions. ** ** Under MSVC, this NaN test may fail if compiled with a floating- ** point precision mode other than /fp:precise. From the MSDN ** documentation: ** ** The compiler [with /fp:precise] will properly handle comparisons ** involving NaN. For example, x != x evaluates to true if x is NaN ** ... */ #ifdef __FAST_MATH__ # error SQLite will not work correctly with the -ffast-math option of GCC. #endif volatile double y = x; volatile double z = y; return y!=z; } So it looks as if you have little choice. I'd say, Mike's suggestion is the least painful. Regards, Arjen ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] GCC -ffast-math safe version of sqlite3IsNaN
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Brown, Daniel wrote: > In the process of upgrading to 3.6.1 I've run into the error on line 46 > of util.c about int sqlite3IsNaN(double x) not behaving consistently > with the GCC -ffast-math compiler option (which we have enabled), is > there any alternative function I could use that would be compatible with > GCC -ffast-math? Removing the -ffast-math option from our projects > would be highly undesirable for us, as performance is paramount. If you don't use any floating point with SQLite then just remove the #error. However if you do use floating point with SQLite then you can't use fast math. See the following tickets which show a variety of problematic behaviour with -ffast-math: http://www.sqlite.org/cvstrac/tktview?tn=3101 http://www.sqlite.org/cvstrac/tktview?tn=3186 http://www.sqlite.org/cvstrac/tktview?tn=3194 http://www.sqlite.org/cvstrac/tktview?tn=3202 Roger -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFItJj7mOOfHg372QQRAlXDAJ9n+/Xe1E/1DszYXxCcVPjb+pxHOwCfcB5J XkV7LD9lbEv59oK9WS+r174= =8d1g -END PGP SIGNATURE- ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] GCC -ffast-math safe version of sqlite3IsNaN
Unfortunately our build system is automated and not particularly agile, it can be done but it would be preferred not to have to do that and to replace the offending function instead but I've never had to write a IsNaN test. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Ruck Sent: Tuesday, August 26, 2008 3:59 PM To: 'General Discussion of SQLite Database' Subject: Re: [sqlite] GCC -ffast-math safe version of sqlite3IsNaN Have you tried to compile the util.c/amalgamation file without -ffast-math and use it with your other sources (compiled with -ffast-math)? Mike > -Ursprüngliche Nachricht- > Von: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Im Auftrag von Brown, Daniel > Gesendet: Mittwoch, 27. August 2008 00:38 > An: General Discussion of SQLite Database > Betreff: [sqlite] GCC -ffast-math safe version of sqlite3IsNaN > > Good afternoon list, > > In the process of upgrading to 3.6.1 I've run into the error > on line 46 of util.c about int sqlite3IsNaN(double x) not > behaving consistently with the GCC -ffast-math compiler > option (which we have enabled), is there any alternative > function I could use that would be compatible with GCC > -ffast-math? Removing the -ffast-math option from our > projects would be highly undesirable for us, as performance > is paramount. > > Cheers, > > Daniel Brown > "The best laid schemes o' mice an' men, gang aft agley" > > > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] GCC -ffast-math safe version of sqlite3IsNaN
Have you tried to compile the util.c/amalgamation file without -ffast-math and use it with your other sources (compiled with -ffast-math)? Mike > -Ursprüngliche Nachricht- > Von: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Im Auftrag von Brown, Daniel > Gesendet: Mittwoch, 27. August 2008 00:38 > An: General Discussion of SQLite Database > Betreff: [sqlite] GCC -ffast-math safe version of sqlite3IsNaN > > Good afternoon list, > > In the process of upgrading to 3.6.1 I've run into the error > on line 46 of util.c about int sqlite3IsNaN(double x) not > behaving consistently with the GCC -ffast-math compiler > option (which we have enabled), is there any alternative > function I could use that would be compatible with GCC > -ffast-math? Removing the -ffast-math option from our > projects would be highly undesirable for us, as performance > is paramount. > > Cheers, > > Daniel Brown > "The best laid schemes o' mice an' men, gang aft agley" > > > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] GCC -ffast-math safe version of sqlite3IsNaN
Good afternoon list, In the process of upgrading to 3.6.1 I've run into the error on line 46 of util.c about int sqlite3IsNaN(double x) not behaving consistently with the GCC -ffast-math compiler option (which we have enabled), is there any alternative function I could use that would be compatible with GCC -ffast-math? Removing the -ffast-math option from our projects would be highly undesirable for us, as performance is paramount. Cheers, Daniel Brown "The best laid schemes o' mice an' men, gang aft agley" ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users