Mercurial > octave
changeset 33044:359f922209d4
eliminate OCTAVE_FLOAT_TRUNCATE macro and configure option (bug #65321)
* configure.ac: Eliminate --enable-float-truncate option.
* toplev.cc (__octave_config_info__):
Remove ENABLE_FLOAT_TRUNCATE from struct.
* oct-cmplx.cc: Remove all uses of OCTAVE_FLOAT_TRUNCATE.
* oct-conf-post-public.in.h: Don't define OCTAVE_FLOAT_TRUNCATE.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 17 Feb 2024 22:35:46 -0500 |
parents | 147c69ad945d |
children | 486c3ce9e49b 8bb630882630 |
files | configure.ac libinterp/corefcn/toplev.cc liboctave/util/oct-cmplx.cc oct-conf-post-public.in.h |
diffstat | 4 files changed, 20 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/configure.ac Sat Feb 17 15:59:36 2024 -0500 +++ b/configure.ac Sat Feb 17 22:35:46 2024 -0500 @@ -944,28 +944,6 @@ AC_SUBST(MKOCTFILE_F77) AC_SUBST(MKOCTFILE_RANLIB) -### Enable float truncation to work around issues with x87 co-processors - -dnl When compiling math for x87, problems may arise in some code comparing -dnl floating-point intermediate results. The root cause is the extra precision -dnl (~80 bits) of x87 co-processor registers versus the IEEE standard 64 bits. -dnl Generally, storing the result in a local volatile variable forces a -dnl truncation back to 64 bits, but it also degrades performance. -dnl However, this performance degradation is very minimal, if indeed measurable. -dnl Therefore, it has been enabled for all platforms and compilers. -dnl Reported bugs indicate that --enable-float-truncate is required for MinGW -dnl and Cygwin platforms and for GCC compilers >= 5.0. It should not be -dnl necessary for non-x87 targets or when using modern SSE math. -ENABLE_FLOAT_TRUNCATE=yes -AC_ARG_ENABLE([float-truncate], - [AS_HELP_STRING([--disable-float-truncate], - [truncate intermediate FP results])], - [if test "$enableval" = no; then ENABLE_FLOAT_TRUNCATE=no; fi], []) -if test $ENABLE_FLOAT_TRUNCATE = yes; then - AC_DEFINE(OCTAVE_ENABLE_FLOAT_TRUNCATE, 1, - [Define to 1 to truncate intermediate FP results.]) -fi - ### Enable internal checks ## The checks slow down the execution and are redundant,
--- a/libinterp/corefcn/toplev.cc Sat Feb 17 15:59:36 2024 -0500 +++ b/libinterp/corefcn/toplev.cc Sat Feb 17 22:35:46 2024 -0500 @@ -380,12 +380,6 @@ { "ENABLE_DOCS", false }, #endif -#if defined (OCTAVE_ENABLE_FLOAT_TRUNCATE) - { "ENABLE_FLOAT_TRUNCATE", true }, -#else - { "ENABLE_FLOAT_TRUNCATE", false }, -#endif - #if defined (OCTAVE_ENABLE_OPENMP) { "ENABLE_OPENMP", true }, #else
--- a/liboctave/util/oct-cmplx.cc Sat Feb 17 15:59:36 2024 -0500 +++ b/liboctave/util/oct-cmplx.cc Sat Feb 17 22:35:46 2024 -0500 @@ -46,12 +46,12 @@ template <typename T> \ bool operator OP (const std::complex<T>& a, const std::complex<T>& b) \ { \ - OCTAVE_FLOAT_TRUNCATE const T ax = std::abs (a); \ - OCTAVE_FLOAT_TRUNCATE const T bx = std::abs (b); \ + const T ax = std::abs (a); \ + const T bx = std::abs (b); \ if (ax == bx) \ { \ - OCTAVE_FLOAT_TRUNCATE const T ay = std::arg (a); \ - OCTAVE_FLOAT_TRUNCATE const T by = std::arg (b); \ + const T ay = std::arg (a); \ + const T by = std::arg (b); \ if (ay == static_cast<T> (-M_PI)) \ { \ if (by != static_cast<T> (-M_PI)) \ @@ -69,11 +69,11 @@ template <typename T> \ bool operator OP (const std::complex<T>& a, T b) \ { \ - OCTAVE_FLOAT_TRUNCATE const T ax = std::abs (a); \ - OCTAVE_FLOAT_TRUNCATE const T bx = std::abs (b); \ + const T ax = std::abs (a); \ + const T bx = std::abs (b); \ if (ax == bx) \ { \ - OCTAVE_FLOAT_TRUNCATE const T ay = std::arg (a); \ + const T ay = std::arg (a); \ if (ay == static_cast<T> (-M_PI)) \ return static_cast<T> (M_PI) OP 0; \ return ay OP 0; \ @@ -84,11 +84,11 @@ template <typename T> \ bool operator OP (T a, const std::complex<T>& b) \ { \ - OCTAVE_FLOAT_TRUNCATE const T ax = std::abs (a); \ - OCTAVE_FLOAT_TRUNCATE const T bx = std::abs (b); \ + const T ax = std::abs (a); \ + const T bx = std::abs (b); \ if (ax == bx) \ { \ - OCTAVE_FLOAT_TRUNCATE const T by = std::arg (b); \ + const T by = std::arg (b); \ if (by == static_cast<T> (-M_PI)) \ return 0 OP static_cast<T> (M_PI); \ return 0 OP by; \ @@ -116,12 +116,12 @@ bool operator OP<float> (const std::complex<float>& a, \ const std::complex<float>& b) \ { \ - OCTAVE_FLOAT_TRUNCATE const float ax = std::abs (a); \ - OCTAVE_FLOAT_TRUNCATE const float bx = std::abs (b); \ + const float ax = std::abs (a); \ + const float bx = std::abs (b); \ if (ax == bx) \ { \ - OCTAVE_FLOAT_TRUNCATE const float ay = std::arg (a); \ - OCTAVE_FLOAT_TRUNCATE const float by = std::arg (b); \ + const float ay = std::arg (a); \ + const float by = std::arg (b); \ if (ay == -A_PI) \ { \ if (by != -A_PI) \ @@ -139,11 +139,11 @@ template <> OCTAVE_API \ bool operator OP<float> (const std::complex<float>& a, float b) \ { \ - OCTAVE_FLOAT_TRUNCATE const float ax = std::abs (a); \ - OCTAVE_FLOAT_TRUNCATE const float bx = std::abs (b); \ + const float ax = std::abs (a); \ + const float bx = std::abs (b); \ if (ax == bx) \ { \ - OCTAVE_FLOAT_TRUNCATE const float ay = std::arg (a); \ + const float ay = std::arg (a); \ if (ay == -A_PI) \ return static_cast<float> (M_PI) OP 0; \ return ay OP 0; \ @@ -154,11 +154,11 @@ template <> OCTAVE_API \ bool operator OP<float> (float a, const std::complex<float>& b) \ { \ - OCTAVE_FLOAT_TRUNCATE const float ax = std::abs (a); \ - OCTAVE_FLOAT_TRUNCATE const float bx = std::abs (b); \ + const float ax = std::abs (a); \ + const float bx = std::abs (b); \ if (ax == bx) \ { \ - OCTAVE_FLOAT_TRUNCATE const float by = std::arg (b); \ + const float by = std::arg (b); \ if (by == -A_PI) \ return 0 OP static_cast<float> (M_PI); \ return 0 OP by; \
--- a/oct-conf-post-public.in.h Sat Feb 17 15:59:36 2024 -0500 +++ b/oct-conf-post-public.in.h Sat Feb 17 22:35:46 2024 -0500 @@ -419,9 +419,3 @@ #if defined (OCTAVE_ENABLE_OPENMP) # define HAVE_OPENMP 1 #endif - -#if defined (OCTAVE_ENABLE_FLOAT_TRUNCATE) -# define OCTAVE_FLOAT_TRUNCATE volatile -#else -# define OCTAVE_FLOAT_TRUNCATE -#endif